0
我有一個簡單的JavaCard HelloWorld腳本,我使用虛擬閱讀器在JCIDE中執行它,然後從pyapdutool發送apdu命令:00a404000e aid然後80000000,並且我收到javacard字符串,一切運行良好。我的問題是:如何返回tlv格式數據而不是該響應?我正在查看關於這個的emv書4.3以及谷歌還沒有找到一個在javacard腳本中實現emv tlv標籤的例子。 有人能幫我理解這個嗎?TLV格式的EMV JavaCard APDU響應
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/才能夠對它進行解碼。
我不太喜歡JavaCard API。這是複雜的,資源飢餓,並不完全正確。一個簡單的TLV解析器/發生器可能應該是首選。不能分享我的。 –