Determine card type from ATR

偶尔善良 提交于 2020-01-01 03:48:04

问题


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


回答1:


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).




回答2:


ATR exists for contact smartcards only. For contactless cards, its equivalent is called ATQ, and it comes in two variations: ATQ-A and ATQ-B, for each of the two ISO14443 types.

So the way I'd recommend to go is:

  • The reader sends both REQ-A and REQ-B, polling to see if there are contactless cards in range.
  • If a card responds with REQ-A, it is Type A; or if it's REQ-B, it is Type B.

The contactless reader's drivers should pass on this information to your software. I recommend you get hold of a copy of ISO 14443-3 standard, it explain the initial steps of the card discovery and anticollision protocol, so you can see the differences between types A and B.



来源:https://stackoverflow.com/questions/23404314/determine-card-type-from-atr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!