read records failed on real smart card

妖精的绣舞 提交于 2019-12-06 14:45:55

The problem is that your JCIDE simulator behaves as a T=1 card, but your real card is a T=0 card. T=0 and T=1 are transmission protocols defined by the ISO/IEC 7816-3 standard. T=0 is the older and simpler one.

T=1 returns all the data together with the status word independently on your Le byte in APDU.

T=0 checks if the length of your output data is equal to Le byte from the input (T=0 card expects your device has limited memory, so it responds with as many output bytes as asked to only). If not, it sends a status word 6CXX, where the XX is the correct Le byte. You have to resend the command with Le=XX:

<- 00 A4 04 00 06 11 22 33 44 55 66 00
-> 90 00

<- 00 B3 00 FF
-> 6C 06

<- 00 B3 00 FF 06
-> 11 11 11 11 11 22 90 00

You don't have to worry about performance - the command is not processed again. Your output is ready from the first call, you just have to ask for it.

Use setIncomingAndReceive at the very beginning of the ReadRecors() method. Like:

 private void ReadRecord(APDU apdu) {
    // ReadRecord
     apdu.setIncomingAndReceive();
     rest of your codes....

Calling this method indicates that this APDU has incoming data.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!