简体   繁体   English

TagLostException IsoDep Android Java卡

[英]TagLostException IsoDep Android Java card

I'm working with a Java card using Android IsoDep. 我正在使用Android IsoDep处理Java卡。 I have already set the timeout to 50000 milliseconds. 我已经将超时设置为50000毫秒。 I also calculated the duration the NFC connection was opened and it was just over 6 seconds. 我还计算了NFC连接打开的持续时间,刚好超过6秒。
I put the card on my table and put my phone on top of it and I didn't touch either through the process so there is no chance the card could be removed physically. 我将卡放在桌子上,然后将手机放在其上面,在此过程中我也没有触摸任何一个,因此没有机会将卡物理移除。

Any idea why this is happening? 知道为什么会这样吗?

My code: 我的代码:

try {
    if (nfc.isConnected()) {
        DLog.w(TAG, "exchange() - connected");

        byte[] resp = nfc.transceive(apdu);

        // ...
    } else {
        // ...
        close();
    }
} catch (TagLostException e) {
    DLog.e(TAG, "card was removed", e);
    close();
    // ...
}
catch (IOException e) {
    close();
    // ...
}  

The exception: 例外:

01-08 09:54:54.721: E/IsoDepSecureHandler(11221): android.nfc.TagLostException: Tag was lost.
01-08 09:54:54.721: E/IsoDepSecureHandler(11221):   at android.nfc.TransceiveResult.getResponseOrThrow(TransceiveResult.java:48)
01-08 09:54:54.721: E/IsoDepSecureHandler(11221):   at android.nfc.tech.BasicTagTechnology.transceive(BasicTagTechnology.java:151)
01-08 09:54:54.721: E/IsoDepSecureHandler(11221):   at android.nfc.tech.IsoDep.transceive(IsoDep.java:172)

The particular command that it failed to execute is 80460000400000271020363630303030303030353138323133303134333666383639383063022b100141000100000000000000000036364ed930284231adbc6c525e9f0abd 它执行失败的特定命令是80460000400000271020363630303030303030353138323133303134333666383639383063022b100141000100000000000000000036364ed930284231adbc6c525e9f0abd

However, the same command was executed just fine when I use a contactless reader that connect to my phone. 但是,当我使用连接到手机的非接触式阅读器时,可以很好地执行相同的命令。 Note that the command can only executed as long as I don't repeat the process and generate new security parameters (some other APDU commands were sent to the card prior to this one). 请注意,只有在我不重复该过程并生成新的安全参数的情况下,该命令才能执行(在此之前,其他一些APDU命令已发送到该卡)。 Once new the security parameters are generated, the above command does not work anymore; 一旦生成了新的安全性参数,以上命令将不再起作用。 therefore, 6982 will be returned. 因此,将退回6982

tbellenger suggested adding 00 to the end of the command but that doesn't work, even with the smartcard reader as 6985 is returned. tbellenger建议在命令末尾添加00 ,但这不起作用,即使使用智能卡读卡器也要返回6985

Try adding '00' to the end of your APDU. 尝试在APDU的末尾添加“ 00”。 This is sometimes required. 有时这是必需的。 Don't modify 'LC' from '40' - just add the zero byte. 不要修改“ 40”中的“ LC”,只需添加零字节即可。 I think this is required in T=CL or T=1. 我认为这在T = CL或T = 1中是必需的。

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

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