【发布时间】:2016-02-05 16:41:23
【问题描述】:
我的 javacard 小程序中有这个方法:
public void process(APDU apdu)
{
byte[] buf = apdu.getBuffer() ;
switch(buf[ISO7816.OFFSET_INS])
{
case 0x40:
Util.arrayCopy(hello,(byte)0,buf,ISO7816.OFFSET_CDATA,(byte)5);
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA,(byte)5);
break;
default: ISOException.throwIt(ISO7816.SW_WRONG_INS) ;
}
}
你好:
private final static byte[] hello = {0x48, 0x65, 0x6c, 0x6c, 0x6f };
我在脚本中发送命令如下:
powerup;
// Select the installer applet
0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
// create TestApplet applet
0x80 0xB8 0x00 0x00 0xd 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00 0x7F;
//show hello message
0x40 0x00 0x00 0x00; //this is the command mentioned in tutorial which gave error
powerdown;
前两个命令成功,但最后一个由于命令格式不正确而出错。
我也试过这个命令:
0x00 0x40 0x00 0x00 0x00 0x7f;
但它给了我回复6d00,这意味着不支持INS vlaue。
这是实际的响应:
CLA: 80, INS:40, P1:00,P2:00,Lc:00,Le:00,SW1:6d,SW2:00
预期的响应是获取 hello 值以及成功响应 9000
我在关注tutorial
发出 APDU 命令的正确方法是什么?
【问题讨论】: