我有一个简单的 JavaCard HelloWorld 脚本,我在 JCIDE 中使用虚拟阅读器执行它,然后我从 pyapdutool 发送 apdu 命令:00a404000e 辅助然后 80000000 并且我收到 javacard 字符串,一切运行正常。我的问题是:我怎样才能返回一个 tlv 格式的数据而不是那个响应?我在 emv book 4.3 中查找关于此的内容,并且在 google 上也没有找到在 javacard 脚本中实现 emv tlv 标签的单个示例。有人可以让我走上正确的道路来理解这一点吗?
package helloworld;
import javacard.framework.*;
public class helloworld extends Applet
{
private static final byte[] javacard = {(byte)'J',(byte)'a',(byte)'v'(byte)'a',(byte)' ',(byte)'C',(byte)'a',(byte)'r',(byte)'d',(byte)'!',};
private static final byte JC_CLA = (byte)0x80;
private static final byte JC_INS = (byte)0x00;
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new helloworld().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
byte CLA = (byte) (buf[ISO7816.OFFSET_CLA] & 0xFF);
byte INS = (byte) (buf[ISO7816.OFFSET_INS] & 0xFF);
if (CLA != JC_CLA)
{
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
}
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
OutPut(apdu);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
private void OutPut( APDU apdu)
{
byte[] buffer = apdu.getBuffer();
short length = (short) javacard.length;
Util.arrayCopyNonAtomic(javacard, (short)0, buffer, (short)0, (short) length);
apdu.setOutgoingAndSend((short)0, length);
}
}
简而言之:我希望能够以这种格式发送响应,例如:6F1A840E315041592E5359532E4444463031A5088801025F2D02656E 然后当我访问http://www.emvlab.org/tlvutils/时能够对其进行解码。