简体   繁体   English

Javax SmartCardIO奇怪的错误6700长度不正确

[英]Javax SmartCardIO Weird Error 6700 Length Incorrect

I'm doing some testing against a few unknown smart cards that I know to be ISO7816-4 compliant. 我正在对一些我知道符合ISO7816-4标准的未知智能卡进行测试。 The cards I have collected are all from the same operator and all of them can work interchangeably. 我收集的卡都是来自同一运营商的,它们都可以互换使用。

I have been sending APDU commands to the card via the Java SmartCardIO library and an ACR122U reader and also using a Android phone via the ISODEP library. 我一直在通过Java SmartCardIO库和ACR122U阅读器向卡发送APDU命令,还通过ISODEP库使用Android手机。

On my android device, I have sent the following apdu and everything works fine, 在我的android设备上,我发送了以下apdu,一切正常,

tag.transceive(new byte[] {(byte)0x80, (byte)0x30, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00 })

All 10 out of 10 cards work find. 10张卡片中的10张都能找到。

On my desktop I have the following code: 在我的桌面上,我有以下代码:

answer = channel.transmit(new CommandAPDU( new byte[] { (byte)0x80, (byte)0x30, (byte)0x03, (byte)0x00, (byte)0x00 } ));

this code works fine with 3 out of 10 cards, the other 7 I get a 6700 length incorrect error. 这段代码可以在10张卡中的3张上正常工作,另外7张我得到6700长度错误。 For the remaining 7 I have to use this code, 对于剩下的7个,我必须使用此代码,

answer = channel.transmit(new CommandAPDU( new byte[] { (byte)0x90, (byte)0x32, (byte)0x03, (byte)0x00, (byte)0x00,(byte)0x00, (byte)0x00 } ));

I also cannot use this code for the above 3 cards, I get a length incorrect error. 我也不能在上面的三张卡上使用此代码,我得到一个长度错误的错误。

I can't figure out what is the issue, why will adding an extra 2 null bytes make it work? 我不知道这是什么问题,为什么要添加额外的2个空字节使其起作用? I'm not facing this issue on my android device, all cards work with just one string. 我在Android设备上没有遇到此问题,所有卡都只能使用一个字符串。

Since all these instructions are of the proprietary range, I'm not too confident about meaning and cases (DECREASE?), but assume, that they are case 4 allowing command data and response. 由于所有这些指令均属于专有范围,因此我对含义和大小写(DECREASE?)不太确定,但可以假设它们是允许命令数据和响应的情况4。

All your APDUs are clearly malformed. 您所有的APDU显然格式错误。 If you have no command data, LC=0 must not be specified. 如果没有命令数据,则不得指定LC = 0。 The zeroes also can't be LE, since this is either encoded in one byte (short) or 3 bytes (extended length) in absence of LC. 零也不能为LE,因为在没有LC的情况下,零被编码为一个字节(短)或3个字节(扩展长度)。 That appending two zero bytes works, means, that you are switching to extended length somewhat successfully, 附加两个零字节的工作原理意味着您已成功切换到扩展长度,

I recommend to refer to ISO 7816-4, chapter command response pairs. 我建议参考ISO 7816-4的“命令响应对”一章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM