Answer to reset
An Answer To Reset (ATR) is a message output by a contact Smart Card conforming to ISO/IEC 7816 standards, following electrical reset of the card's chip by a card reader. The ATR conveys information about the communication parameters proposed by the card, and the card's nature and state.
By extension, ATR often refers to a message obtained from a Smart Card in an early communication stage; or from the card reader used to access that card, which may transform the card's message into an ATR-like format (this occurs e.g. for some PC/SC card readers when accessing an ISO/IEC 14443 Smart Card).
The presence of an ATR is often used as a first indication that a Smart Card appears operative, and its content examined as a first test that it is of the appropriate kind for a given usage.
Contact Smart Cards communicate over a signal named Input/Output (I/O) either synchronously (data bits are sent and received at the rhythm of one per period of the clock supplied to the card on its CLK signal) or asynchronously (data bits are exchanged over I/O with another mechanism for bit delimitation, similar to traditional asynchronous serial communication). The two modes are exclusive in a given communication session, and most cards are built with support for a single mode. Microprocessor-based contact Smart Cards are mostly of the asynchronous variety, used for all Subscriber Identity Modules (SIM) for mobile phones, all bank cards[disambiguation needed] with contacts conforming to EMV specifications, all contact Java Cards, and Smart Cards for pay television. Memory-only cards are generally of the synchronous variety.
ATR under asynchronous and synchronous transmission have entirely different form and content. The ATR in asynchronous transmission is extensively normalized, and relatively complex to parse.
Some Smart Cards (mostly of the asynchronous variety) have different ATR depending on if the reset is the first since power-up (Cold ATR) or not (Warm ATR).
Note: Answer To Reset should not be confused with ATtRibute REQuest (ATR_REQ) and ATtRibute RESponse (ATR_RES) of NFC, also abbreviated ATR. ATR_RES conveys information about the communication parameters supported, as does Answer To Reset, but its structure is different.
- 1 ATR in asynchronous transmission
- 2 ATR in synchronous transmission
- 3 References
ATR in asynchronous transmission
The ATR proceeds in five steps: initial character TS; format byte T0; interface bytes TAi, TBi, TCi, TDi (optionals, variable number); historical bytes Ti (optionals, up to 15), and the check byte TCK (optional). There are a total of 2 to 33 characters including TS.
The initial character TS is always physically present, but is not part of the Answer-to-Reset in ISO/IEC 7816-3:2006, defined as: the value of the byte string (at most 32 bytes) encoded in the sequence of characters following the initial character TS. ISO/IEC 7816-4:2005 states that TS is a character or synchronization pattern, not a byte]. However practice (in PC/SC, EMV, ETSI, and Calypso at least) is still to consider that TS is part of the ATR, as it was in ISO/IEC 7816-3:1997 and former. In particular, the ATR returned by PC/SC card readers and software stacks includes TS as the first byte, with the value explicitly given in every edition of ISO/IEC 7816-3, see below.
Initial character TS
The initial character TS encodes the convention used for encoding of the ATR (and further communications until the next reset). In direct [resp. inverse] convention, bits with logic value ‘1’ are transferred as a High voltage (H) [resp. a Low voltage (L)]; bits with logic value ‘0’ are transferred as L [resp. H]; and least-significant bit of each data byte is first (resp. last) in the physical transmission by the card.
For direct convention, TS is (H) L H H L H H H L L H (H) and encodes the byte ‘3B’.
For inverse convention, TS is (H) L H H L L L L L L H (H) and encodes the byte ‘3F’.
[ (H) represents the idle (High, Mark) state of the I/O line. The 8 data bits are shown in italic.]
In the following bytes of the ATR, bits are numbered 1st to 8th from low-order to high-order, and their value noted 0 or 1, regardless of the chronological order and electrical representation, defined by TS.
TS also allows the card reader to confirm or determine the duration of bits, denoted Elementary Time Unit (ETU), as one third of the delay between the first and second H-to-L transition in TS. This is optional, and the principal definition of ETU in the ATR of standard-compliant asynchronous Smart Cards is 372 periods of the clock received by the card.
Historical note: provision for cards that use an internal clock source and a fixed ETU of 1/9600 second during ATR existed in ISO/IEC 7816-3:1989, and was removed from the 1997 edition onwards.
Format byte T0
The Format byte T0 encodes in its 4 low-order bits the number K of historical bytes, in range [0..15].
It also encodes in its 4 high-order bits the presence of at most 4 other interface bytes: TA1 (resp. TB1, TC1, TD1) follow, in that order, if the 5th (resp. 6th, 7th, 8th) bit of T0 is 1.
Interface bytes TAi, TBi, TCi, TDi
Interface bytes TA1, TB1, TC1, TD1, TA2, TB2, TC2, TD2, TA3, TB3, .. are all optional, and encode communication parameters and protocols that the card propose to use.
Interface bytes come in three kinds: global interface bytes apply to all protocols; specific interface bytes apply to a specific protocol; and structural interface bytes introduce further interface bytes, and protocols.
Interface byte TA1
Interface byte TA1, if present, is global. It encodes the maximum clock frequency fmax supported by the card, and the number of clock periods per ETU that it suggests to use after the ATR, expressed as the ratio Fi/Di of two integers.
The 4 low-order bits of TA1 encode Di as:
|4th to 1st bits||0000||0001||0010||0011||0100||0101||0110||0111||1000||1001||1010||1011||1100||1101||1110||1111|
(#) This was RFU in ISO/IEC 7816-3:1997 and former. Some card readers or drivers may erroneously reject cards using this value (or other RFU).
The 4 high-order bits of TA1 encode fmax and Fi as:
|8th to 5th bits||0000||0001||0010||0011||0100||0101||0110||0111||1000||1001||1010||1011||1100||1101||1110||1111|
(#) Historical note: in ISO/IEC 7816-3:1989, this was assigned to cards with internal clock, and thus no assigned Fi or f(max).
For example, TA1 = 'B5' = 10110101 encodes fmax = 10 MHz, Fi/Di = 1024/16 = 64; this is inviting the card reader to take (after the ATR) the necessary steps to reduce the ETU to 64 clock cycles per ETU (from 372 during ATR) and increase the clock frequency up to 10 MHz (from perhaps 4 MHz during ATR).
||This article's remainder may require cleanup to meet Wikipedia's quality standards. (August 2011)|
Interface byte TB1
TB1, if present, is global. It is used to indicate the programming voltage VPP and maximum programming current required by some cards on the dedicated contact C6 during programming of their EPROM memory. Modern Smart Cards internally generate the programming voltage for their EEPROM or Flash memory, and the usage of TB1 is deprecated since the 2006 edition of the standard. Nowadays, cards should not include it in the ATR, and readers shall ignore TB1 if present. Including TB1='00' (indicating that the card does not use VPP) remains common.
In the 1997 and earlier editions of the standard:
- The low 5 bits of TB1 (5th to 1st) encode PI1; if TB2 is absent, PI1=0 indicates that the C6 contact (assigned to VPP) is not connected in the card; PI1 in range [5..25] encodes the value of VPP in Volt (the reader shall apply that voltage only on specific demand by the card, with a tolerance of 2.5%, up to the maximum programming current; and otherwise leave the C6 contact used for VPP within 5% of the VCC voltage, up to 20 mA); if TB2 is present, it supersedes the indication given by TB1 in the PI1 field, regarding VPP connection or voltage.
- The high bit of TB1 (8th bits) is reserved, shall be 0, and can be ignored by the reader.
- The 6th and 5th bits of TB1 encode the maximum programming current (assuming neither TB1 nor TB2 indicate that VPP is not connected in the card)
|7th and 6th bits||00||01||10||11|
|Maximum programming current||25 mA||50 mA||RFU(#)||RFU|
(#) This was 100 mA in ISO/IEC 7816-3:1989.
Interface byte TC1
TC1 encodes the extra guard time integer (N) from 0 to 255 over the eight bits. The default value is N = 0.
Guard Time = 12etu + R * (N/f)
Interface bytes TDi
Interface byte TDi for i>0, if present, is structural.
TDi encodes in its 4 high-order bits the presence of at most 4 other interface bytes: TAi+1 (resp. TBi+1, TCi+1, TDi+1) follow, in that order, if the 5th (resp. 6th, 7th, 8th) bit of TDi is 1.
TDi encodes in its 4 low-order bits an integer T, which is in range [0..15]. T=15 qualifies the following TAi+1 TBi+1, TCi+1, TDi+1 (if present) as global interface bytes. Otherwise, T indicates a protocol that the card is willing to use, and that TAi+1 TBi+1, TCi+1, TDi+1 (if present) are specific interface bytes applying only to that protocol. T=0 is a character-oriented protocol. T=1 is a block-oriented protocol. T in the range [3..14] is RFU.
Historical note: provision for dynamically qualifying interface bytes as global using T=15 did not exist in ISO/IEC 7816-3:1989.
Interface byte TA2
Interface byte TA2, if present, is global, and is named the specific mode byte.
Presence of TA2 globally (hence the kind) commands that the reader use specific mode (hence the name) as defined by TA2 and earlier global bytes, rather than negotiable mode when TA2 is absent.
Historical note: Provision for specific mode did not exist in ISO/IEC 7816-3:1989. Back then, the interface character TA2 had no particular name or function, and was specific (to the protocol introduced by TD1). ISO/IEC 7816-3:1997 introduced the specific mode and the specific mode byte, with interim note helping cards with specific mode byte TA2 in their ATR dealing with a reader that did not implement specific mode.
Historical bytes Ti
Historical Characters typically hold Information about the Card Builder, Type of Card (Size etc.), Version number and the State of the Card.
Check byte TCK
The Check byte adds redundancy to the ATR. If present, it is the Exclusive OR of the bytes in the ATR from T0 to the byte before TCK, included.
Presence of TCK is determined by the values of T which may be encoded in some Interface bytes.
ATR in synchronous transmission
The ATR starts with a header of 32 bits organized into 4 bytes, denoted H1 thru H4. H1 codes the protocol (with '00' and 'FF' being invalid), H2 codes parameters of the protocol. Little more is standardized.
- Section 184.108.40.206 in SCM Microsystems SDI011 Reference Manual — version 1.05
- Section 3.2 in OMNIKEY Contactless Smart Card Readers Developer Guide
- ISO/IEC 18092:2004 — Information technology — Telecommunications and information exchange between systems — Near Field Communication — Interface and Protocol (NFCIP-1)
- ISO/IEC 7816-3:2006 — Identification cards — Integrated circuit cards — Part 3: Cards with contacts — Electrical interface and transmission protocols (partial preview)
- EMV Integrated Circuit Card Specifications for Payment Systems — Book 1 — Application Independent ICC to Terminal Interface Requirements
- Note in section 7.4.2 of ISO/IEC 7816-4:2005 — Identification cards — Integrated circuit cards — Part 3: Cards with contacts — Organization, security and commands for interchange (preview)
- ISO/IEC 7816-10:1999 — Identification cards — Integrated circuit cards — Part 3: Cards with contacts — Electronic signals and answer to reset for synchronous cards (partial preview)