Why APDU Response in READ BINARY COMMAND return 233 bytes and not 256

Viewed 28

I am working with smart cards in java, trying to get a file. For this I am using APDU commands.

The "SELECT FILE" command is executed correctly, it answers me 90 00, but when obtaining the file through a cycle, each iteration is returning 233 bytes and not 256, and when assembling the file it does not work.

ResponseAPDU answer = channel.transmit(new CommandAPDU(new byte[]{(byte) 0x00, (byte) 0xB0, (byte) 0X00, (byte) 0x00, (byte) 0x00}));
System.out.println(answer.toString());

Prints: ResponseAPDU: 233 bytes, SW=9000

Thanks in advance for the help

1 Answers

Several possible reasons:

  • the file might just have 233 bytes
  • there is a trusted channel or some other kind of secure messaging involved and TLV format overhead as well as MAC consume the missing bytes
  • toString might be confused by non-printable characters
  • reader or card might be configured to a lower i/o buffer size

If by "assembling" you mean concatenating the results, try to adjust the start offset to the number of bytes you actually got.

Related