【发布时间】:2018-03-06 19:34:54
【问题描述】:
这里有一个简单的测试小程序,我已经编写并安装在我的 Javacard 上,作为“默认选择的小程序”。如您所见,它会在接收到任何具有 INS = 0X00 的 APDU 命令时抛出 0x6a6a:
package testPack;
import javacard.framework.*;
public class TestApplet extends Applet implements MultiSelectable
{
public boolean select(boolean appInstAlreadySelected) {
return true;
}
public void deselect(boolean appInstStillSelected) {
}
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new TestApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
ISOException.throwIt((short)0x6A6A);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
如下所示,在卡热复位后,我向卡发送了一些 APDU 命令:
Reset successful.
Send: 00 00 00 00 01
Recv: 6A 6A
Send: 10 00 00 00 01
Recv: 6A 6A
Send: 80 00 00 00 01
Recv: 6A 6A
Send: E0 00 00 00 01
Recv: 68 81 <====
问题 1: 为什么我会收到 0x6881 for CLA = 0XE0?
您可以在下面看到卡热重置后的另一个命令序列:
Reset successful.
Send: 00 00 00 00 00
Recv: 6A 6A
Send: 01 00 00 00 00 // Try to send commands with logical channel 1 instead of 0
Recv: 68 81 //Error because the channel is not open.
Send: 00 70 00 01 00 // Opening the channel with MANAGE CHANNEL APDU command
Recv: 90 00
Send: 01 00 00 00 00
Recv: 6A 6A
Send: 11 00 00 00 00
Recv: 6A 6A
Send: 81 00 00 00 00
Recv: 6A 6A
Send: E1 00 00 00 00
Recv: 68 81 <== Same Error as before!
问题 2: 有没有办法让所有逻辑通道默认打开?我的意思是有什么方法可以从序列中删除 MANAGE CHANNEL APDU 命令?
问题3:为什么CLA = 0xE1返回0x6881?
问题 4: 我的小程序是默认选择的小程序。所以我除了我的小程序来接收除了 SELECT APDU 命令而不是卡管理器(安全域)之外的所有 APDU 命令。那么 MANAGE CHANNEL APDU 命令有效吗?我的意思是,为什么 Card Manager 会收到该命令而不是我的小程序? Card Manager 会解析哪些命令而不是我的小程序?
【问题讨论】: