为什么我收不到 APDU 缓冲区的内容?
Why I can't receive APDU buffer contents?
我写了下面的程序return接收到每个 APDU 命令时的所有 APDU 缓冲区内容:
package testPack;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
public class BufferReturner extends Applet {
private BufferReturner() {
}
public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException {
new BufferReturner().register();
}
public void process(APDU arg0) throws ISOException {
if(selectingApplet()){
return;
}
arg0.setOutgoingAndSend((short)0, (short)255);
}
}
当我使用 T=0
协议通过接触界面发送命令时,我收到以下结果:
Connect successful.
Send: 00 A4 04 00 06 01 02 03 04 05 00 00
Recv: 90 00
Time used: 8.000 ms
Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 00
Send Apdu error: A device attached to the system is not functioning.
Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 00
Recv: 6C FF
Time used: 5.000 ms
Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 FF
Recv: 6C FF
Time used: 5.000 ms
Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 FF
Recv: 6C FF
Time used: 5.000 ms
Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 FF
Recv: 6C FF
Time used: 6.000 ms
Send: 00 C0 00 00 FF
Send Apdu error: A device attached to the system is not functioning.
Send: 00 C0 00 00 FF
Send Apdu error: A device attached to the system is not functioning.
如您所见,我无法接收 APDU 缓冲区内容。怎么了?
就像 一样,您的卡没有任何问题,这是 "expected" 的行为。
对于setOutgoing()
方法(setOutgoingAndSend()
只是包装setOutgoing()
的一种便捷方法),Java卡API规范明确指出:
On a case 4 command, the setIncomingAndReceive()
must be invoked prior to calling this method. Otherwise, erroneous behavior may result in T=0 protocol.
因此,您看到的正是 API 规范中指出的“错误行为”。
我写了下面的程序return接收到每个 APDU 命令时的所有 APDU 缓冲区内容:
package testPack;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
public class BufferReturner extends Applet {
private BufferReturner() {
}
public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException {
new BufferReturner().register();
}
public void process(APDU arg0) throws ISOException {
if(selectingApplet()){
return;
}
arg0.setOutgoingAndSend((short)0, (short)255);
}
}
当我使用 T=0
协议通过接触界面发送命令时,我收到以下结果:
Connect successful. Send: 00 A4 04 00 06 01 02 03 04 05 00 00 Recv: 90 00 Time used: 8.000 ms Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 00 Send Apdu error: A device attached to the system is not functioning. Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 00 Recv: 6C FF Time used: 5.000 ms Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 FF Recv: 6C FF Time used: 5.000 ms Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 FF Recv: 6C FF Time used: 5.000 ms Send: 00 00 00 00 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 FF Recv: 6C FF Time used: 6.000 ms Send: 00 C0 00 00 FF Send Apdu error: A device attached to the system is not functioning. Send: 00 C0 00 00 FF Send Apdu error: A device attached to the system is not functioning.
如您所见,我无法接收 APDU 缓冲区内容。怎么了?
就像
对于setOutgoing()
方法(setOutgoingAndSend()
只是包装setOutgoing()
的一种便捷方法),Java卡API规范明确指出:
On a case 4 command, the
setIncomingAndReceive()
must be invoked prior to calling this method. Otherwise, erroneous behavior may result in T=0 protocol.
因此,您看到的正是 API 规范中指出的“错误行为”。