我有一个简单的JavaCard HelloWorld脚本,我在JCIDE中使用虚拟读取器执行它,然后从pyapdutool: 00a404000 e援助发送apdu命令,然后接收javacard字符串,一切正常运行。我的问题是:如何返回tlv格式的数据而不是响应?我在emv书4.3中找到了这方面的内容,而且google还没有找到一个在javacard脚本中实现emv标记的例子。有人能让我走上正确的道路来理解这一点吗?
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/去解码它。
发布于 2016-04-04 08:11:02
Javacard中有几个TLV类,但它们是可选的,据我所知,没有任何发卡者实现这些类。所以你可以:
在javacard中,最后一个选项很难成为无错误和可执行的选项,所以如果您是初学者,那么如果您对第一个选项过于恼火,您可以尝试构建一个tlv解析器。
https://stackoverflow.com/questions/36375710
复制相似问题