我正在尝试将小程序安装到J3A040 JCOP卡中。
作为安装方法,我有以下内容:
protected MainApplet() {
try {
// CREATE RSA KEYS AND PAIR
m_keyPair = new KeyPair(KeyPair.ALG_RSA_CRT, KeyBuilder.LENGTH_RSA_2048);
// STARTS ON-CARD KEY GENERATION PROCESS
m_keyPair.genKeyPair();
// OBTAIN KEY REFERENCES
m_publicKey = (RSAPublicKey) m_keyPair.getPublic();
m_privateKey = (RSAPrivateKey) m_keyPair.getPrivate();
} catch (CryptoException c) {
//this line will give you the reason of problem
short reason = c.getReason();
ISOException.throwIt(reason); // for check
}
register();
}安装总是失败,但有以下错误:
pro.javacard.gp.GPException: Install for Install and make selectable failed SW: 6A80
at pro.javacard.gp.GlobalPlatform.check(GlobalPlatform.java:1092)
at pro.javacard.gp.GlobalPlatform.installAndMakeSelectable(GlobalPlatform.java:798)
at pro.javacard.gp.GPTool.main(GPTool.java:478)然而,如果我删除键盘生成,一切正常工作。我已阅读了卡片的规格说明,其内容如下:
。在安全的环境中,RSA和RSA CRT (1280到2048位密钥)用于en/解密和签名生成,verification1 d. RSA CRT密钥生成(1280到2048位密钥)。
我想应该没什么问题吧。
有什么猜测吗?
发布于 2015-04-02 13:08:55
这个问题是由无效的强制转换引起的:您要求使用中文提醒定理格式(ALG_RSA_CRT)中的私钥的RSA KeyPair。
这就是为什么getPrivate()方法不返回RsaPrivateKey实例,而是返回RsaPrivateCrtKey实例的原因。转换为RsaPrivateKey会导致6A80状态字。
因此,您应该要么使用标准算法:
m_keyPair = new KeyPair(KeyPair.ALG_RSA, KeyBuilder.LENGTH_RSA_2048);,或使用正确的演员阵容:
m_publicKey = (RSAPublicKey) m_keyPair.getPublic();
m_privateKey = (RSAPrivateCrtKey) m_keyPair.getPrivate();https://stackoverflow.com/questions/29400514
复制相似问题