需要帮助调试Javacard



我只是想看看是否能在这方面得到一些帮助,我才开始使用javacard大约两周,说它很有趣吧!哈哈,但说真的。这是我在函数中调用的代码,它非常简单,我有一点随机生成的数据,并将其中一个数组加密到apdu中作为响应发送回来,其他命令和mem方法一样工作得很好,但那个方法总是失败。

private void initi(APDU apdu){
byte[] buf = apdu.getBuffer();
cdataoffset = (short)buf[ISO7816.OFFSET_CDATA];
len = Util.getShort(buf, cdataoffset);

try{
rd.generateData(tempbuf, (short) 0, (short) 32);
rd.generateData(serial, (short) 0, (short) 16);
rd.generateData(salt, (short) 0, (short) 6);
}
catch(CryptoException e){
ISOException.throwIt((short)(0x6900 | e.getReason()));
}
try{
privKey.setKey(tempbuf, (short) 0);
}
catch(ArrayIndexOutOfBoundsException e){}
catch(NullPointerException e){}
try{
cipherPriv.init(privKey, Cipher.MODE_ENCRYPT);
}
catch(CryptoException e){
ISOException.throwIt((short)(0x6900 | e.getReason()));
}
try{
cipherPriv.doFinal(serial, (short) 0, (short) 30, buf, cdataoffset);
}
catch(CryptoException e){
ISOException.throwIt((short)(0x6900 | e.getReason()));
}
apdu.setOutgoingAndSend((short) 0, len);


private void mem(APDU apdu){
byte[] buf = apdu.getBuffer();
short availableNVM = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);
short availableVM = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT);
Util.setShort(buf, (short) 0, availableNVM);
Util.setShort(buf, (short) 2, availableVM);
apdu.setOutgoingAndSend((short) 0, (short) 4);
}

BTW im使用JCOP J3A081卡和gppro/antbuilder由martin用于构建/安装

卡的响应:

A>>T=1(4+0000(B0120000 A<lt;(0000+2((89ms(6901SCardDisconnect("Identiv SCR3500 A Contact Reader",true(

我的另一个理论是,我实际上收到了我的异常抛出加上一个值,但我觉得这不太可能,但我真的不确定哈哈

更改不同捕获线的值,使它们都不同,并且BAM我不确定的理论是正确的。这是我的异常被捕获,通过更改短值(即6900、6800、6700(,我成功地捕捉到了哪个部分给我带来了麻烦!

最新更新