ATR command when programming PC/SC reader

18,244

Solution 1

Short answer:

  • You are correct about ATR being generated by PCSC reader
  • I think the ATR will remain the same irrespective of the reader for contactless cards

Long answer:

ATR is for contact cards and is specified in ISO 7816. For contacless cards, it is the PC/SC reader (IFD) that generates the ATR.

The ATR is constructed based on:

  • ATS (Answer to Select) for ISO 14443 Type A cards
  • ATQB and ATTRIB bytes for ISO 14443 Type B cards

The ATR will be of the form 3B 8X 80 01 HB_ATS Parity_Byte where X is the number of bytes of Historical Bytes of ATS (HB_ATS).

The exact construction of ATR for contactless cards is given in section 3.1.3.2.3 of the PC/SC spec.

Given that the only variable is ATS, it should be the same regardless of the reader.

--Sid

Solution 2

ATR contains fixed fields as well as optional fields(conditional). So depending on some values of a field, subsequent fields may be omitted hence ATR might be different for different readers but they all conform to the standards.

Check out the smart card tutorial here.
In short, ATR frame is as below:
enter image description here

Share:
18,244
STeN
Author by

STeN

Smartphones/SmartTVs/HbbTV and NFC technology is my experience and background as developer and application architect for more then 10 years. @PetrMazanec

Updated on June 25, 2022

Comments

  • STeN
    STeN about 2 years

    I have checked the programming interface for the MIFARE Ultralight and TOPAZ/Jewel IC tags. The API quite nicely describes how the bytes are saved on the card, how to address the memory blocks, how to make all operations like read, read-all, use of the OTP (One Time Programmable) function, how to read ROM bytes, how to switch from idle to ready state (REQA, WUPA commands), it says if commands are CRC protected, how to access the tag UID, etc.

    When stared to program the NFC reader (ACR122U or SCL010) I found that all communication between PCD (reader) an PICC (tag) starts with the ATR (Answer-To-Reset) command, which is as described on Internet a command that the PCD sends to PICC for identification purposes.

    But none of the tags documentation mentions the ATR command – all communication with tags when they become powered (PQR) starts with REQA, WUPA commands in order to switch the card to the Ready mode.

    My understanding is that ATR is built by PC/SC based on the NFC card the reader communicated with. Once the reader detect what type of technology is the tag based on it creates the ATR. Also according to documentation ATR for different NFC readers are different for the same NFC tags.

    Am I right? Does the PC/SC build the ATR?

    BR STeN

  • Roy Lee
    Roy Lee over 11 years
    +1 So can you tell me what is the exact ATR command? In hex format, been goggling around but no deal :(
  • Chand51
    Chand51 over 11 years
    ATR is generated by the card(PICC) in response to RESET command issued by the reader(PCD or IFD).
  • neo
    neo almost 7 years
    I have same concern ? could you help