ISO/IEC 7816-4
Identification cards — Integrated circuit cards — Part 4: Organization, security and commands for interchange
Cartes d’identification — Cartes à circuit intégré — Partie 4: Organisation, sécurité et commandes pour les échanges

 Application-independent card services
This clause specifies application-independent card services, referred to as “card services”.
1) Card identification
2) Application identification and selection
3) Selection by path
4) Data retrieval
5) Data element retrieval
6) Card-originated byte strings
The purpose of card services is to provide interchange mechanisms between a card and an interface device knowing nothing about each other except that they both comply with this document. Card services result from any combination of historical bytes, the contents of EF.DIR and EF.ATR and sequences of commands. Unless otherwise specified, every command APDU uses CLA set to ’00′, i.e., no command chaining, no secure messaging and the basic logical channel.
There is no need for an application to comply with this clause once it has been identified and selected in the card. An application may use other mechanisms compatible with this document for achieving similar functions. Therefore such solutions may not guarantee interchange.

 Card identification

This service allows the interface device to identify the card and to deal with it. The historical bytes provide a generic support to card identification. The card provides information to the outside world on its logical content directly, e.g., through the card service data byte , and / or indirectly, e.g., through the initial access data indicating an access to a file implicitly selected immediately after the answer to reset and a possible protocol and parameters selection. Consequently, the data available at this point, i.e., the initial data string, may not be subsequently retrievable.

Historical bytes
Purpose and general structure

The historical bytes indicate operating characteristics of the card.

 When a card answers to reset, the Answer-to-Reset may contain historical bytes (see ISO/IEC 7816-3).

 When the physical interface does not allow a card to answer to reset, e.g., a universal serial bus or an access by radio frequency, a GET DATA command may retrieve historical bytes (tag ’5F52′).

The first historical byte is the “category indicator byte”. If the category indicator byte is set to ’00′, ’10′ or ’8X’, then Table 83 summarizes the format of the historical bytes. Any other value indicates a proprietary format.

Table 83 — Category indicator byte

 
Value Meaning
’00′ ’10”80′ ’81′ to ’8F’ A status indicator shall be present as the last three historical bytes. A status indicator may be present in a COMPACT-TLV data object (one, two or three bytes) Reserved for future use
 Any other value indicates a proprietary format.

 If the first historical byte is set to ’00′, then the remaining historical bytes consist of optional consecutive COMPACT-TLV data objects followed by a mandatory status indicator (the last three bytes, not in TLV).

 If the first historical byte is set to ’80′, then the remaining historical bytes consist of optional consecutive COMPACT-TLV data objects; the last data object may carry a status indicator of one, two or three bytes.

Any interindustry BER-TLV data object consisting of a tag field set to ’4X’, a length field set to ’0Y’ and a value field of Y bytes can be converted into a COMPACT-TLV data object consisting of a byte set to ‘XY’ called “compact header” and a value field of Y bytes.

Any interindustry data element defined hereafter may be present in EF.ATR. If present in EF.ATR, it shall appear in a BER-TLV data object, i.e., a tag field set to ’4X’, a length field set to ’0Y’ and a value field of Y bytes.

Optional data elements
Country or issuer indicator

Referenced by a compact header set to either ’1Y’ or ’2Y’, this interindustry data element is a country or issuer indicator (see also tags ’41′ and ’42′ in Table 9). Table 84 shows the country or issuer indicator.

Table 84 — Country or issuer indicator

Compact header Value
’1Y’ Country code (see ISO 3166-1[1]) and optional national data
’2Y’ Issuer identification number (see ISO/IEC 7812-1[3]) and optional issuer data

 A country indicator consists of a country code (three quartets with values from ’0′ to ’9′, see ISO 3166-1[1]) followed by subsequent data (at least one quartet). The relevant national standardization body shall choose those subsequent data (odd number of quartets).

 An issuer indicator consists of an issuer identification number (see ISO/IEC 7812-1[3]) possibly followed by subsequent data. The card issuer shall choose those subsequent bytes if any (for encoding, e.g., a Primary Account Number).

NOTE In ISO/IEC 7812-1:1993, an issuer identification number might consist of an odd number of quartets with a value from ’0′ to ’9′. Then it was mapped into a byte string by setting bits 4 to 1 of the last byte to 1111.

Application identifier

Referenced by a compact header set to ‘FY’, this interindustry data element is an application identifier (AID, see also tag ’4F’ in Table 9). If present in the historical bytes or in the initial data string, an AID denotes an implicitly selected application