📄 rsakeygen.java
字号:
package RSA;import javacard.framework.*;import javacard.security.*;import javacardx.crypto.*;public class RSAKeyGen extends Applet { // code of CLA byte in the command APDU header final static byte CLA =(byte)0x80; // codes of INS byte in the command APDU header final static byte INS_CREATE_RSA_KEYPAIR = (byte) 0x20; // RSA private KeyPair rsaPair; private RSAPublicKey rsaPubKey; private RSAPrivateKey rsaPrivKey; public static void install(byte[] bArray, short bOffset, byte bLength) { new RSAKeyGen(bArray, bOffset, bLength); } /** * Performs memory allocations, initialization, and applet registration. * * @param bArray to pass to register() method. * @param bOffset to pass to register() method. * @param bLength to pass to register() method. */ protected RSAKeyGen(byte[] bArray, short bOffset, byte bLength) { rsaPair = new KeyPair(KeyPair.ALG_RSA_CRT,(short)1024); register(); } /** * Dispatches APDU commands. * @param apdu APDU object */ public void process(APDU apdu) { if (selectingApplet()) return; byte[] buffer = apdu.getBuffer(); if (buffer[ISO7816.OFFSET_CLA] != CLA) ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED); switch (buffer[ISO7816.OFFSET_INS]) { case INS_CREATE_RSA_KEYPAIR: genRSAKeyPair(apdu); return; default: ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); } } public void genRSAKeyPair(APDU apdu) { rsaPair.genKeyPair(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -