Search code examples
smartcardisoapdu

Card does not return Status Word when data to retrieve exceeds 256 bytes


I'm working with a card in T=0 protocol:

  • I send a command to the Card that request a response with data.
  • The applet I use is expected to answer with data, potentially more than 256 bytes, so in the command Le is set to '00'
  • Card first answers with 61 XX where 'XX' is the count of bytes to read (from 1 to 256).
  • Then I retrieve the data by sending a GET RESPONSE command:

    00 C0 00 00 XX

Expectation:

Regarding ISO7816-3, I expected the Card to respond with:

Procedure byte | Data | SW1 SW2

And if SW1 == 0x61, I would send:

00 C0 00 00 SW2

And so on, until eventually I get 90 00.

Reality:

However, this is what I actually have (TPDU level):

> Command
< 61 00

> 00 C0 00 00 00
< C0 (procedure byte)
< Data (256)
No Status Word, no procedure byte (timeout)

> 00 C0 00 00 00
< C0 (procedure byte)
< Data (256)
No Status Word, no procedure byte (timeout)

[...]

> 00 C0 00 00 00
< 61 39 (status word)

I have to repeatedly send GET RESPONSE with P3=00 (256), read the 256 bytes and got no Status Word until the Card warns me that there is actually less than 256 bytes to read.

I can't found the part of the specification that allows the card to "skip" the status word, or how to deal with answers longer than 256 bytes. Any pointer ?


Solution

  • I figured it out: it was a timing issue.

    The card do have a Status Word to send, however my process between the read operations was too long so by the time I requested it, it was no longer available in the card.

    I should have highlighted that I was developing the reader part myself.