Determine card type from ATR

user2793162 picture user2793162 · May 1, 2014 · Viewed 7.8k times · Source

Is it possible using ATR to determine whether I have ISO14443A or ISO14443B type card? If yes, how?

Answer

Michael Roland picture Michael Roland · May 2, 2014

As mictter correctly explained, a real ATR only exists for ISO 7816 contact cards. I can follow the argumentation that the ISO 14443 equivalent could be the ATQA/ATQB as this is the first answer you get from tags after activation, though I would rather say that the equvalent of the ATR is a combination of ATQA + SAK + ATS (for Type A) and a combination of ATQB + Answer to ATTRIB (for Type B).

Regarding the ATR you see, I assume that this is a PC/SC-emulated ATR according to the PC/SC specification.

For smartcards (ISO 14443-4 transport protocol) this ATR would have the form

3B 8n 80 01 T[1]..T[n] xx

with T[1] to T[n] being

  1. the ATS historical bytes for ISO 14443 Type A, or
  2. a concatenation of the ATQB application data (T[1] T[2] T[3] T[4]), the ATQB protocol information field (T[5] T[6] T[7]) and the ATTRIB MBLI field (T[8]).

So you might be able to do some form of matching to guess if it is a Type A or B smartcard. I.e. if n == 8 and the parameters in T[1] to T[n] match something that you expect for those fields of a Type B card. Still I doubt that you will get reliable results for arbitrary cards.

For contactless memory cards, the situation is certainly better. For these cards, the emulated ATR looks like this:

3B 8n 80 01 T[1]..T[n] xx

with T[1] to T[n] containing an application identifier presence indicator (tag 4F). So T[1] to T[n] typically look something like this:

80 4F yy A000000306 ss nnnn 00000000

with ss identifying the card's protocol:

0x01: ISO 14443-1 Type A
0x02: ISO 14443-2 Type A
0x03: ISO 14443-3 Type A
0x05: ISO 14443-1 Type B
0x06: ISO 14443-2 Type B
0x07: ISO 14443-3 Type B

and nnnn identifying the card name (see the PC/SC specifications for a full list).