0

Good day all, i am tasked to develop an application in android that basically functions by reading data from the chip of a smart caard. That is "easy enough" i initially thought. My workplace purchased some android devices with integrated card readers, got the SDK and handed it over to me. On reading the SDK and further research i discovered that all the SDK does is get the card ATR...which i understand contains historical data which contains personal card information.

The issue here is that a member number is to be encoded onto the cards...(the reason for their purchase) but if the ATR being returned looks like this (actual letters have been rejigged):

3D 6Z 00 00 80 34 80 62 B0 89 35 01 F1 83 00 90 00

How can i parse this to get required information.The employee number is to be encoded into the chip and i am meant to read the card and extract the data. I was thinking i will see a "name/value" pair with values that i can now extract and use at will. So pardon my inexperience. How can i parse smartcard ATR's ?..Thanks

ewom2468
  • 821
  • 3
  • 14
  • 44
  • The ATR you provided is not valid. What do you like to achieve, sorry I did not understand. Do you want to write data to cards which match a certain ATR pattern? – arminb May 02 '17 at 12:16
  • I changed the ATR (obviously i cant post the CORRECT one)...what i want to achieve is READ data that is saved to card...but seeing that an ATR looks like that...how can i make the ATR to be readable – ewom2468 May 02 '17 at 12:25
  • 2
    are you sure the member data is encoded in the ATR? – Paul Bastian May 03 '17 at 06:47
  • I have been doing further research...which has led me to see that i will need APDU commands ...the key data i need is the card number....(PAN) – ewom2468 May 03 '17 at 06:54

1 Answers1

0

You can extract historical bytes by parsing the ATR.

A Java implementation can be found here. All you would have to do is:

// your ATR as byte array
byte[] rawAtr = new byte[] {(byte)3B, (byte)0F, (byte)00, (byte)65, (byte)46, (byte)53, (byte)05, (byte)16, (byte)05, (byte)71, (byte)DF, (byte)00, (byte)00, (byte)00, (byte)80, (byte)6A, (byte)82}
ATR atr = new ATR(rawAtr);

byte[] historicalBytes = atr.getHistoricalBytes();

For Perl implementation see here.

Since historical data can be in proprietary format you will have to look inside the datasheet of the smartcard in order to know how to parse the content of the historical bytes.

arminb
  • 2,036
  • 3
  • 24
  • 43