Initial card installation

Tomcat

Professional
Messages
2,686
Reputation
10
Reaction score
710
Points
113
The dialogue between the reader and the card occurs in several sequential stages:
  • connection and activation of card contacts (transfer of the card to an idle state);
  • initial installation (reinstallation of the card);
  • data exchange between the card and the reader;
  • shutdown (deactivation) of the card.
In the process of inserting the card into the reader, the terminal does not supply voltage to the card. This is due to the fact that the card's microcircuit can be seriously damaged if voltage is applied to an inappropriate card contact. The supply voltage is not applied until

MasterCard to A

until the card edge sensor of the reader detects that the card is fully inserted into the reader. Many chips have protection mechanisms in case the card is inserted along the energized pins of the reader.

When the reader detects that the card is inserted correctly, it first puts the card and itself into an idle state, characterized by the following parameters:

ContactState
VCCStable supply voltage
VPPStable open circuit programming voltage
RSTLower signal level
CLKStable clock signal
I / OReception mode on the side of the reader

The transfer of the card to an idle state occurs as a result of the following sequence of actions by the reader:
  • the supply voltage is applied to the contact of the VCC card, which takes its upper value;
  • a clock signal is sent to the CLK card contact at the time TO;
  • the reader and the card go into the I / O line listening mode (information reception mode) for a time not exceeding 200 clock cycles from the moment of maintenance: the voltage value at the I / O card contact takes the upper value;
  • the RST card contact is supplied with voltage corresponding to the lower level of the card insertion signal (ISO 7816-3 standard);
  • VPP card pin (not used on EMV cards) is set to idle mode (VPP pin is supplied with the voltage defined in ISO 7816-3 as “idle”, i.e. voltage not used for EEPROM programming; in accordance with ISO7816-3 this voltage is between 0.95 VCC and 1.05 VCC).
  • (The values of the parameters of the physical signals applied to the card contacts are not given here. You can get acquainted with them in section 5.3 of book 1 of the EMV 4.2 specifications.)

Thus, in the idle state, the I / O line is set on the side of the reader and the card to receive mode, the reader sends a stable clock signal to the card, the initial setting line RST is in the state of the lower signal level.

In an idle state (see Fig. 2.6), the card stays for 40,000–45,000 cycles from the moment the clock signal T o is given , until the reader starts the initial setup procedure: the voltage on the RST line will be set by the terminal to the upper value. This signals the card to start the internal procedure for the initial card installation. The content of the initial setup procedure differs from card to card, but the procedure should end with the card Answer to Reset (ATR) sent to the reader.

The ATR card response is a sequence of bits returned to the reader over the I / O line. The first byte of the ATR sequence can be received by the reader after 400-40,000 CLK cycles from the moment the RST signal starts being sent.

The above procedure for installing the card is called cold reset. For a number of reasons, the card may not respond to the reader (the reader will not receive the ATR sequence): the card is incorrectly inserted into the reader (possibly upside down) or is physically damaged. There may be another case - the ATR sequence received by the terminal has an incorrect format and / or character values that the terminal does not expect. Whatever the case, if the ATR sequence is not received by the reader within a certain time interval or does not meet the expectations of the reader, the reader starts the warm reset procedure. The procedure begins with a sequence of steps

The sequence of the initial installation of the card from the side of the reader

Rice. 2.6. The sequence of the initial installation of the card from the side of the reader

MasterCard to A

Static card shutdown: the reader sets the voltage level on the RST and I / O lines low. Note that in the case of a complete shutdown of the card (deactivation of the card), performed at the end of the dialogue between the card and the reader, the reader sets a low voltage level on the RST, CLK, I / O and VCC lines.

Thus, before starting the warm install, the supply voltage and the clock signal are already applied to the card, and the voltage corresponding to the lower level of the card install signal is applied to the RST card contact. Within a time not exceeding 200 clock cycles from the moment the voltage value at the RST contact is set equal to the low level of the setup signal, the reader and the card go into the information reception mode: the voltage value at the I / O contact takes the upper value. As a result, the card gets into an idle state, and its further installation is carried out according to the rules of cold installation described above.

With the help of the I / O line, a half-duplex communication channel is realized between the card and the reader. This means that the card and the reader transmit data on the same I / O line, but they do it alternately (they cannot transmit data at the same time). Therefore, when the power is turned on, the reader and the card go into the receive state, in which they listen to the channel. After the Reset signal is given, the reader remains in the receiving state, and the card goes into the transmitting state to send the ATR response to the reader. From this moment on, the card and the reader in antiphase change their states between transmission and reception.

The card can store several ATR sequences and, depending on the value of the clock frequency of the CLK signal, respond to the terminal of one of them. In practice, a very limited number of reader clock rates are used. Therefore, the card has the ability to select such an ATR sequence that would best match its decision on the choice of the parameters of the communication protocol used to communicate with the reader.

As defined in the ISO / IEC 7816-3 standard, the ATR sequence consists of no more than 33 characters, one of the following five types:
  • TS - mandatory start character;
  • TO - mandatory format character;
  • TA (i), TB (i), TC (i), TD (i) - optional (optional) interface symbols;
  • Tl, T2, TK - optional history symbols (no more than 15 symbols);
  • TCK - check character (not used in ATR, only if the card has selected the T = 0 protocol).
Each character is represented by a one-byte binary sequence. The start character TS is used for the following purposes. The I / O line carries one bit of information using a signal that is the voltage value on the I / O line relative to the GND pin. The signal corresponding to a bit of information is transmitted over an elementary time unit (etu), the magnitude of which, as will be shown below, is determined by the clock cycle of the CLK signal.

The signal for transmitting a bit of information can take two values: H (the I / O line is in a high voltage state - 5, 3 or 1.8 volts - depending on the supply voltage value supported by the card and the terminal) or L (I / O line is in a low voltage state). The specific voltage value for the transmission of the 'G bit (H or L) must be determined before the card interacts with the terminal. Obviously, another possible signal strength value is used to transmit the '0' bit.

The decision about the signal level used to transmit the '1' bit is determined by the card using the start symbol TS. If the value of the TS symbol is' 3B'h, then the card adopts the so-called forward agreement, in which the signal level H corresponds to the transmission '1', and the signal level L corresponds to the transmission 'O'. If the TS symbol value is' 3F'h, then the card adopts the so-called inverse convention, in which the signal level H corresponds to the transmission 'O', and the signal level L corresponds to the transmission '1'.

Forward and backward conventions also control the precedence of the bits in each byte transmitted between the card and the reader. In direct convention, the first bit following the start bit is the least significant bit in the byte. It is followed by bits in ascending order of precedence. In reverse convention, the first bit following the start bit is the most significant bit in the byte. It is followed by bits in decreasing order of precedence.

Any EMV-compliant terminal must support forward and backward agreements.

The most significant 4 bits of the TO format symbol determine the presence of the TA (1), TB (1), TC (1), TD (1) interface symbols in the ATR sequence. For example, if the most significant bit (b8) is 1, the TD interface symbol (1) is present in the ATR. Similarly, the value of bit b7 = 1 means the presence of the TC (1) interface symbol in the ATR sequence, etc.

The least significant four bits of the TO format character specify the number of history characters (no more than 15).

Interface symbols TA (i), TB (i), TC (i), TD (i) are used to configure the input / output channel (definition of the protocol used by the card and the reader during sequential exchange of commands and responses, the number of additional symbols of the guard interval, working waiting time and a number of other parameters), as well as programming voltage and current.

The most significant 4 bits of the TD (i) byte determine the presence of interface symbols in the next four bytes TA (i + 1), TB (i + 1), TC (i + 1), TD (i + 1). If the symbol TD (i) was not transmitted, then the next four bytes TA (i + 1), TB (i + 1), TC (i + 1), TD (i + 1) will not be transmitted. From here it follows by induction that if TD (i) was not transmitted, then no more interface characters will be transmitted.

The least significant 4 bits of any TD (i) character indicate the type of communication protocol used for the card-to-terminal dialogue. If the ATR sequence does not contain any TD (i) characters, then the T = 0 protocol shall be used in accordance with ISO 7816-3.

The symbols TA (1), TB (1), TC (1) and TB (2) are fundamental to the functioning of the card and are called global interface symbols. These symbols encode integers FI, DI, II, PI1, N, PI2, which in turn define the parameters F, D, I, P, N, the purpose of which is described below.

The TA (1) symbol encodes two parameters: FI (bits b8-b5) and DI (bits b4-b1). The FI parameter defines the F value, which is the clock frequency conversion factor (Table 2.3). The DI parameter defines the D value, which is the bit rate setting factor (Table 2.4).

Tab. 2.3. Calculation of F and Fmax from the FI value

FI01234567eight
FInternal clock372558744111614881860RFURFU
Fmax. MGC-56eight1216twenty--

FInineAVCDEF
F512768102415362048RFURFU
Fmax. MGC57.5ten15twenty--

Tab. 2.4. Calculating D from DI

DI01234567
DRFU124eight16RFURFU
DIeightnineAVWITHDEF
DRFURFU1/21/41/81/161/321/64

In the tables, FI and DI values are presented in hexadecimal notation. With the help defined in the table. 2.3 and 2.4 of parameters F and D, the value of the elementary value of the time etu, expressed in seconds, is calculated, during which one bit of information is transmitted:

, 1 F

when using an external clock signal etu = -;

D f

.eleven

when using your own clock of the etu microcircuit —--,

D 9600

where / is the clock frequency of the CLK signal, varying in the range from 1 MHz to F max .

Thus, using the TA (1) symbol, the data transfer rate between the reader and the card is determined. It is assumed that the terminal reader supports any baud rate from 9600 to 115200 bps and is ready to support card selection. By default FI = 1 and DI = 1, from which, using the above tables, it follows that F - 372, D - 1 and, therefore, the initial value etu 0 , expressed in seconds, is:

372

when using an external clock signal etu 0 -

when using the etu chip's own clock 0 -.

The initial etu value of 0 is used to transmit the ATR sequence.

From table. 2.3 it follows that, taking into account the default values of FI and DI, the initial value of the clock signal SEC is in the range from 1 to 5 MHz. It is almost always chosen so that the initial baud rate is 9600 bps.

The TV symbol (1) is used to set two parameters II and RP. Bits b7 and b6 encode value II, and bits b5-b1 encode value RP. Bit b8 of the TB (1) symbol is always 0.

Using the value II according to the table. 2.5 defines the maximum value of the strength of the programming current, expressed in milliamperes. The initial value for the maximum programming current is 50 mA.

Tab. 2.5. The maximum value of the strength of the programming current

II0001teneleven
I, mA2550100RFU

PI1 value takes on the values 0 and any integer value from 5 to 25. If PH = 0, then the external programming voltage is not used, but is obtained from the supply voltage of the VCC card.

If PI1 = X, where 5 <X <25 and X is an integer, then RP is the programming voltage value expressed in volts, unless the ATR symbol is TB (2). If the symbol TB (2) is present in the ATR, then it encodes the PI2 value, which also determines the value of the programming voltage, but with an accuracy of tenths of a volt. In this case, in units of 0.1 volt, the PI2 value takes on one of the values in the range of integers from 50 to 250. In this case, the PH value is ignored.

The initial value of the programming voltage is 5 volts.

The TC symbol (1) defines the number N, which is equal to the number of additional bits of the guard interval (in the T = 0 protocol, the nominal size of the guard interval is equal to two bits, in the T = 1 protocol - one bit) used in communication protocols to separate two successfully transmitted symbols ... The number N can range from 0 to 255. By default, N is 0.

The TD symbol (1) defines the type of communication protocol used by the card and the reader. Thus, the type of protocol is determined by the card (as will be shown below, the terminal has the ability to try to change the card's decision). For contact cards, the ISO 7816-3 standard defines the protocols T - 0 (asynchronous half-duplex byte protocol) and T = 1 (asynchronous half-duplex block protocol). The terminal reader must support both of the mentioned protocols and be ready to implement any card decision on the choice of the communication protocol.

In addition, other types of communication protocols are reserved:
  • Т - 2 and Т - 3 - for duplex data transmission protocols;
  • Т = 4 - for extended half-duplex data transmission protocols;
  • T = 5 ... 13 - for future use;
  • T - 14 - protocol not regulated by ISO;
  • T = 15 - for future expansion.
As a national standard in Japan, the block asynchronous protocol T = 14 is used.

The TD (1) interface symbol is also used to determine the presence (Bit-mapping) of the TA (2), TB (2), TC (2) and TD (2) symbols.

The TA symbol (2) is used in the mechanism for the terminal to change the decision on the choice of the protocol type (see below about the PTS mechanism). In accordance with EMV 4.2 Book 1 Section 4.3.3.5, the TA (2) symbol must not be present in the ATR. At the same time, if the TA (2) symbol is still present in the ATR, then the terminal will not reject such an ATR sequence only if the b5 bit of the TA (2) symbol is 0 and the terminal can fulfill all the conditions specified by the interface symbols of the ATR sequence.

The TC symbol (2) can be set only when the card selects the T - 0 protocol. It defines the WI parameter, which is used to calculate the limitation on the waiting time for the start bit of any character transmitted by the card, from the moment the start bit of the previous character is transmitted either by the card, either by the terminal. This limit is calculated using the formula 960 • D • WI • etu. In accordance with the EMV standard, the TC symbol (2) must not be present in the ATR. If there is no TS (2) in ATR, then by default WI = 10. The WI parameter is usually called work waiting time.

Interface symbols TA (3), TB (3), TC (3) are used only when the card has selected the T = 1 protocol (see clause 2.4.2).

History symbols are defined by the card manufacturer. There should be no more than 15 of them in the ATR sequence. These symbols are usually used to convey information about the type and model of the chip, the manufacturer of the card, and the possible use of this card. Often history symbols determine the number and version of the card mask.

The TCK check character provides error detection when transmitting the ATR sequence and is not used when TD (1) is absent or indicates that the T - 0 protocol is selected. TCK is calculated as a bitwise modulo 2 addition of all bytes of the ATR sequence except for TCK.

To illustrate this, consider an example of an ATR sequence returned by a card in response to a Reset signal. When representing each nibble of the ATR sequence in hexadecimal notation in our example, it looks like this:

ZV 95 94 40 FF 63 01 01 02 01.

Thus, the ATR sequence is 10 bytes long. The first byte is the mandatory TS byte. It is equal to 'ЗВ', which means that a direct agreement will be used between the card and the terminal.

The second mandatory byte TO is 95 (hex). This means that ATR only contains the interface characters TA (1) and TD (1) (as indicated by the first nibble '1001') and that ATR contains five historical characters.

As follows from the ATR value, the TA (1) interface symbol is' 94'h. This means that FI = 9, and DI = 4. Using the table. 2.3 and 2.4, we get that F = 512, D = 8, and with the clock frequency of the external generator 4.9152 MHz, we determine the data transfer rate V:

W = D - = 8 • 2,222,222 bps = 76,800 bps. F 512

The TD (1) interface symbol value is' 40'h. This means that the card selects the communication protocol T = 0 and the ATR contains the TC symbol (2), which determines the maximum delay before the card starts transmitting the next character. Since TC (2) = 'FF'h, WI = 255. Therefore, the value of the working waiting time (maximum delay) is 960 • D • WI • etu = 25.5 s.

The last 5 bytes of the ATR sequence are the historical characters encoding the IC ID and the version numbers of the IC and software masks used.

As an example, consider another ATR sequence of the following form:

3F 67 2F 00 11 14 00 03 68 90 00.

In this case, the TS symbol is' 3F'h, which means that the opposite (inverse) convention will be used between the card and the terminal. The TO byte is equal to '67'h, which means that ATR contains only the symbols of the TV (1) and TC (1) interface. Since the symbol TA (1) is not transmitted, then by default FI = 1 and DI = 1, whence using Table. 2.3 and 2.4 we obtain that F = 372, D = 1 and, therefore, the initial value etu 0 , expressed in t 372 seconds, is equal to etu 0 = -

Further, it follows from ATR that TB (1) = '2F'h, whence II = 2, RP = 15. Hence, the maximum value of the programming current is I = 100 mA (see Table 2.5), and the programming voltage is VPP = 15 volts.

Since TC (1) = '00'h, an additional increase in the number of bits in the guard interval is not required.

Since there is no TD (1) symbol in the ATR sequence, the card selects the T = 0 protocol and no other interface symbols are transmitted.

The absence of the TA interface symbol (2) in the ATR sequence means that the card is ready to negotiate with the terminal about changing the protocol and communication parameters. From the absence of the TC symbol (2) in ATR, it follows that the default working waiting time is WI = 10.

The EMV standard (see Section 4.2 of Book 1) defines the ATR sequence values for the T = 0 and T = 1 protocols, shown in the tables below.

The ATR sequence determines the channel characteristics and channel control protocol selected by the card. The ISO / IEC 7816-3 standard allows the reader in some cases to change the decision of the card, fixed in the ATR, using the mechanism laid down in the PTS (Protocol Type Selection) protocol. Today this mechanism is poorly supported, so the optimal channel performance is almost always determined from the ATR sequence without the use of PTS. In particular, the mechanism for

t = o

SymbolsThe valuesComments (1)
TS'ЗВ'Ь or' 3F'hDefines a direct or reverse agreement
THEN'6x'hSymbols TB (1) and TS (1) are present; x indicates the number of characters in the history
TV (1)'00'hVPP not required
TS (1)from '00'h to' FF'hDetermines the number of additional guard interval characters. If TC (l) = 'FF'h, then the minimum time between two transmitted characters is 12 • etu

r 1

MasterCard to A

T = 1

SymbolsThe valuesComments (1)
TS'3B'h or' 3F'hDefines a direct or reverse agreement
THEN'Ex'hSymbols TB (1), TC (1) and TD (1) are present; x indicates the number of characters in the history
TV (1)'00'hVPP not required
TS (1)From '00'h to' FF'hDetermines the number of additional guard interval characters.
If TCI = 'FF'h, then the minimum time between two transmitted characters is 11? etu
TD (1)'81'hThe symbols TA (2), TB (2) and TS (2) are present; selected protocol T = 1
TD (2)'31'hThe symbols TA (3) and TB (3) are present; selected protocol T = 1
TA (3)From '10'h to' FE'hDetermines the maximum size of the information field of the data block that can be received by the card; expressed in bytes
TV (3)The high nibble takes integer values 0-4; the least significant nibble takes integer values 0-5Defines the CWI and BWI parameters (see clause 2.4.2)
TSCBitwise addition modulo two values of all the above charactersCheck symbol

Boron protocol is not used in the EMV standard. However, with the development of the smart card market, it is possible to expand the use of PTS during card initialization. Therefore, below we will briefly describe this mechanism for correcting the communication parameters selected by the card by the reader.

In accordance with ISO 7816-3, a smart card can be in two modes of operation: negotiable mode and in a mode with already defined parameters of the ROP card (specific mode). A card in RP mode can change the communication protocol and parameters for communication with the reader after receiving a PTS command from the reader with new communication parameters. A card in the PTS mode cannot receive and process the PTS command, but under certain conditions it can switch to the PTS mode.

The ability to switch the card to RP mode is demonstrated to the reader as follows. If there is no TA (2) interface character in the ATR sequence, this means that the card is already in RP mode. If the TA symbol (2) is present, it means that the card is in the EPR mode. If at the same time bit 8 of the TA (2) symbol is equal to 1, then this means that the card can be switched to RP mode. Transferring the card to RP mode is carried out using the warm reset procedure.

The PTS command must be sent to the card operating in RP mode immediately after the reader receives the ATR sequence, in case the reader wishes to improve the communication parameters selected by the card.

The PTS command data field contains:
  • initial PTSS character (encoded by 'FF'h value);
  • PTSO format character;
  • three optional symbols PTS1, PTS2, PTS3;
  • check symbol RSK.
Bits 5, 6, and 7 of the PTSO format symbol determine whether the command contains PTS1, PTS2, PTS3, respectively. Bits 1-4 of the PTSO symbol determine the type of communication protocol (from T = 0 to T = 15) offered by the reader for use in dialogue with the card. The PTS1 symbol, if present, specifies the reader's suggested values for the FI and DI parameters, which determine the value of the elementary time unit, or, in other words, the data transfer rate. PTS2 and PTS3 are reserved for future use.

The check character PCK provides error detection during the transmission of the PTS command. The PCK value is calculated as a bitwise modulo 2 addition of all symbols from PTSS to PTS3.

If the card accepts the reader's offer to choose a communication protocol and / or communication parameters, it responds to the PTS command by placing an exact copy of the command data in the response.
 
Top