Aditya_Anand
Aditya_Anand

Reputation: 565

getting extra bytes 82 00 in pc/sc response

I am trying to read data from sony felica card using pc/sc transparent session and transceive data object.

The response I am getting is for a read without encryption command is

c0 03 00 90 00 92 01 00 96 02 00 00 97 82 00 + Data

But according to the protocol, the response should be

c0 03 00 90 00 92 01 00 96 02 00 00 97 + Data

I am unable to figure out the last 82 00 appended in the response from the card.

Now when I try to authenticate with the card I get

c0 03 01 6F 01 90 00

which is a error in pc/sc. I want to resolve these extra bytes 82 00 which I believe will solve the issue with all the commands which require authentication and encryption.

Upvotes: 0

Views: 272

Answers (1)

vlp
vlp

Reputation: 8116

The response data is BER-TLV encoded (see PC/SC 2.02, Part 3).

In BER-TLV encoding there are several possibilities to encode tag 0x97 with two octets of data 0xD0D1, e.g.:

  • 97|02|D0D1 -- short form (see parsed)

  • 97|8102|D0D1 -- long form with one octet with length (see parsed)

  • 97|820002|D0D1 -- long form with two octets with length (see parsed)

  • 97|83000002|D0D1 -- long form with three octets with length (see parsed)

  • ...

Your reader is using two octets for sending the length of ICC Response data object (which is perfectly valid).

You should parse the response properly...Good luck!

PS: The above means, that the Data part of your truncated responses still contains one extra byte with the response length (i.e. Len|Data)

Upvotes: 1

Related Questions