This part of ISO/IEC 7816 specifies
The following standards contain provisons which, through reference in this text, constitute provisions of this part of ISO 7816. At the time of publication, the editions indicated were valid. All standards are subject to revision, and parties to agreements based on this part of ISO/IEC 7816 are encouraged to investigate the possibility of applying the most recent editions of the standards indicated below. Members of IEC and ISO maintain registers of currently valid International Standards :
ISO 3166: 1993 Codes for the representation of names of countries.
ISO/IEC 7812-1: 1993 Identification cards - Identification of issuers - Part 1: Numbering system.
ISO/IEC 7816-3: 1989 Identification cards - Integrated circuit(s) cards with contacts - Part 3: Electronic signals and transmission protocols.
Amendment 1: 1992 to ISO/IEC 7816-3: 1989 Protocol type T=1, asynchronous half duplex block transmisson protocol.
Amendment 2: 1994 to ISO/IEC 7816-3: 1989 Revision of protocol type selection.
ISO/IEC 7816-5: 1994 Identification cards - Integrated circuit(s) cards with contacts - Part 5: Numbering system and registration procedure for application identifiers.
ISO/IEC 7816-6: Identification cards - Integrated circuit(s) cards with contacts - Part 6: Interindustry data elements.
ISO/IEC 8825: 1990 Information technology - Open Systems Interconnection - Specification of Basic Encoding Rules of Abstract Syntax Notation One (ASN.1)
ISO/IEC 9796: 1991 Information technology - Security techniques - Digital signature scheme giving message recovery.
ISO/IEC 9797: 1994 Information technology - Security techniques - Data integrity mechanism using a cryptographic check function employing a block cipher algorithm.
ISO/IEC 9979: 1991 Data cryptographic techniques - Procedures for the registration of cryptographic algorithms.
ISO/IEC 10116: 1991 Information technology - Modes of operation for an n-bit block cipher algorithm.
ISO/IEC 10118-1: 1994 Information technology - Security techniques - Hash-functions - Part 1: General
ISO/IEC 10118-2: 1994 Information technology - Security techniques - Hash-functions - Part 2: Hash-functions using an n-bit block cipher algorithm.
For the puposes of this part of ISO/IEC 7816, the following definitions apply :
For the purposes of this part of the ISO/IEC 7816, the following abbreviations apply :
| APDU | Application protocol data unit |
| ATR | Answer to reset |
| BER | Basic encoding rules of ASN.1 (see annex D) |
| CLA | Class byte |
| DIR | Directory |
| DF | Dedicated file |
| EF | Elementary file |
| FCI | File control information |
| FCP | File control parameter |
| FMD | File management data |
| INS | Instruction byte |
| MF | Instruction byte |
| P1-P2 | Parameter bytes |
| PTS | Protocol type selection |
| RFU | Reserved for future use |
| SM | Secure messaging |
| SW1-SW2 | Status bytes |
| TLV | Tag length value |
| TPDU | Transmission protocol data unit |
For the purposes of this part of ISO/IEC 7816, the following notation applies :
| '0'-'9' and 'A'-'F' | The sixteen hexadecimal digits |
| (B1) | Value of byte B1 |
| B1||B2 | Concatenation of bytes B1 (the most significant byte) and B2 (the least significant byte) |
| # | Number |
The logical organization of data in a card consists of following structural hierachy of dedicated files :
The following two types of EFs are defined :
When a file cannot be implicitly selected, it shall be possible to select it by at least one of the following methods :
The following structures of EFs are defined :
The following attributes are defined for EFs structured in records :
The card shall support at least one of the following four methods for structuring EFs :
Referencing by record identifier - Each record identifier is provided by an application. If a record is a
SIMPLE-TLV data object in the data field for a message (see 5.4.4), then the record identifier is the first byte of the
data object. Within an EF of record structure, records may have the same record identifier, in which case data contained
in the records may be used for discriminating between them.
Each time a reference is made with a record identifier, an indication shall specify the logical position of the target
record the first or last occurrence, the next or previous occurrence relative to the record pointer :
Within each EF of transparent structure, each data unit can be referenced by an offset (e.g. in READ BINARY command). It is an
unsigned integer, limited to either 8 or 15 bits according to an option in the respective command. Valued to 0 for the first data
unit of the EF, the offeset is incremented by 1 for every subsequent data unit.
By default, i.e. if the card gives no indication, the size of the date unit is one byte.
NOTES
The file control information (FCI) is the string of data bytes available in response to a SELECT FILE command. The file control information may be present for any file. Table 1 introduces 3 templates intended for conveying file control information when coded as BER-TLV data objects.
| Tag | Values |
|---|---|
| '62' | File control parameters (FCP template) |
| '64' | File management data (FMD template) |
| '6F' | File control information (FCI template) |
Part of the file control information may additionally be present in a working EF under control of an application and referenced under tag '87'. The use of the FCP or FCI template is mandatory for the coding of file control information in such an EF.
File control information not coded according to this part of ISO/IEC 7816 may be introduced as follows :
| Tag | L | Value | Applies to |
|---|---|---|---|
| '80' | 2 | Number of data bytes in the file, excluding structural information. | Transparent EFs |
| '81' | 2 | Number of data bytes in the file, including structural information if any | Any file |
| '82' | 1 | File descriptor byte (see table 3) | Any file |
| '82' | 2 | File descriptor byte followed by data coding byte (see table 86) | Any file |
| '82' | 3 or 4 | File descriptor byte followed by data coding byte and maximum record length. | EFs with record structure |
| '83' | 2 | File identifier | Any file |
| '84' | 1 to 16 | DF name | DFs |
| '85' | var. | Proprietary information | Any file |
| '86' | var. | Security attributes (coding outside the scope of this part of ISO/IEC 7816) | Any file |
| '87' | 2 | Identifier of an EF containing an extension of the FCI | Any file |
| '88' to '9E' | RFU | ||
| '9FXY' | RFU |
| b8 b7 b6 b5 b4 b3 b2 b1 | Meaning |
|---|---|
| 0 x -- -- -- -- -- -- | File accessibility |
| 0 0 -- -- -- -- -- -- | Not shareable file |
| 0 1 -- -- -- -- -- -- | Shareable file |
| 0 -- x x x -- -- -- | File type |
| 0 -- 0 0 0 -- -- -- | Working EF |
| 0 -- 0 0 1 -- -- -- | Internal EF |
| 0 -- 0 1 0 -- -- -- | Reserved |
| 0 -- 0 1 1 -- -- -- | for |
| 0 -- 1 0 0 -- -- -- | proprietary |
| 0 -- 1 0 1 -- -- -- | types |
| 0 -- 1 1 0 -- -- -- | of EFs |
| 0 -- 1 1 1 -- -- -- | DF |
| 0 -- -- -- -- x x x | EF structure |
| 0 -- -- -- -- 0 0 0 | No information given |
| 0 -- -- -- -- 0 0 1 | Transparent |
| 0 -- -- -- -- 0 1 0 | Linear fixed, no further info |
| 0 -- -- -- -- 0 1 1 | Linear fixed SIMPLE-TLV |
| 0 -- -- -- -- 1 0 0 | Linear variable, no further info |
| 0 -- -- -- -- 1 0 1 | Linear variable SIMPLE-TLV |
| 0 -- -- -- -- 1 1 0 | Cyclic, no further info |
| 0 -- -- -- -- 1 1 1 | Cyclic, SIMPLE-TLV |
| 1 x x x x x x x | RFU |
This clause describes the following features :
Security status represents the current state possibly achieved after completion of
The security attributes, when they exist, define the allowed actions and the procedures to be performed to complete such actions.
Security attibutes may be associated with each file and fix the security conditions that shall be satisfied to allow operations on the file. The security attributes of file depend on :
This part of ISO/IEC 7816 defines the following security mechanisms :
| Case | Command data | Expected response data |
|---|---|---|
| 1 | No data | No data |
| 2 | No data | Data |
| 3 | Data | No data |
| 4 | Data | Data |
Illustrated by figure 3 (see also table 6), the command APDU defined in this part of ISO/IEC 7816 consists of
| Header | Body |
|---|---|
| CLA INS P1 P2 | [Lc field] [Data field] [Le field] |
The maximum number of bytes expected in the data field of the response APDU is
denoted by Le (length of expected data). When the Le field contains only
zeros, the maximum number of available data bytes is requested.
Figure 4 shows the 4 structures of command APDUs according to the 4 cases
defined in table 4.
In case 1, the body of the command APDU is empty. Such a command APDU carries no length field.
In cases 2, 3 and 4 the body of the command APDU consists of a string of L bytes denoted by B1 to BL as illustrated by figure 5. Such a body carries 1 or 2 length fields; B1 is [part of] the first length field.
| Command body |
|---|
| B1 B2 (L bytes) |
Table 5 shows the decoding of the command APDUs according to the four cases defined in table 4 and figure 4 and according to the possible extension of Lc and Le.
| Conditions | Case |
|---|---|
| L=0 | 1 |
Decoding conventions for Le
If the value of Le is coded in 1 (or 2) byte(s) where the bits are not all
null, then the value of Le is equal to the value of the byte(s) which lies in
the range from 1 to 255 (or 65535); the null value of all the bits means the
maximum value of Le: 256 (or 65536).
The first 4 cases apply to all cards.
Case 1 - L=0 : the body is empty.
Case 2E - L=3 and (B1)=0
Illustrated by figure 6 (see also table 7), the response APDU defined in this part of ISO/IEC 7816 consists of
| Body | Trailer |
|---|---|
| [Data field] | SW1 SW2 |
The number of bytes present in the data field of the response APDU is denoted by Lr.
The trailer codes the status of the receiving entity after processing the command-response pair.
NOTE - If the command is aborted, then the response APDU is a trailer coding an error condition on 2 status bytes.
Table 6 shows the contents of the command APDU.
| Code | Name | Length | Description |
|---|---|---|---|
| CLA | Class | 1 | Class of instruction |
| INS | Instruction | 1 | Instruction code |
| P1 | Parameter 1 | 1 | Instruction parameter 1 |
| P2 | Parameter 2 | 1 | Instruction parameter 2 |
| Lc field | Length | variable 1 or 3 | Number of bytes present in the data field of the command |
| Data field | Data | variable=Lc | String of bytes sent in the data field of the command |
| Le field | Length | variable 1 or 3 | Maximum number of bytes expected in the data field of the response to the command |
Table 7 shows the contents of the response APDU.
| Code | Name | Length | Description |
|---|---|---|---|
| Data field | Data | variable=Lr | String of bytes received in the data field of the response |
| SW1 | Status byte 1 | 1 | Command processing status |
| SW2 | Status byte 2 | 1 | Command processing qualifier |
The subsequent clauses specify coding conventions for the class byte, the instruction byte, the parameter bytes, the data field bytes and the status byte. Unless otherwise specified, in those bytes, RFU bits are coded zero and RFU bytes are coded '00'.
According to table 8 used in conjunction with table 9, the class byte CLA of a command is used to indicate
| Value | Meaning |
|---|---|
| '0X' | Structure and coding of command and response according to this part of ISO/IEC 7816 (for coding of 'X' see table 9) |
| 10 to 7F | RFU |
| 8X, 9X | Structure of command and response according to this part of ISO/IEC 7816. Except for 'X' (for coding, see table 9), the coding and meaning of command and response are proprietary |
| AX | Unless otherwise specified by the application context, structure and coding of command and response according to this part of ISO/IEC 7816 (for coding of 'X', see table 9) |
| B0 to CF | Structure of command and response according to this part of ISO/IEC 7816 |
| D0 to FE | Proprietary structure and coding of command and response |
| FF | Reserved for PTS |
| b4 b3 b2 b1 | Meaning |
|---|---|
| x x -- -- | Secure messaging (SM) format |
| 0 x -- -- | No SM or SM not according to 5.6 |
| 0 0 -- -- | No SM or no SM indication |
| 0 1 -- -- | Proprietary SM format |
| 1 x -- -- | Secure messaging according to 5.6 |
| 1 0 -- -- | Command header not authenticated |
| 1 1 -- -- | Command header authenticated (see 5.6.3.1 for command header usage) |
| -- -- x x | Logical channel number (according to 5.5) (b2 b1 = 00 when logical channels are not used or when logical channel #0 is selected |
The instruction byte INS of a command shall be coded to allow transmission with any of the protocols defined in part 3 of ISO/IEC 7816. Table 10 shows the INS codes that are consequently invalid.
| b8 b7 b6 b5 b4 b3 b2 b1 | Meaning |
|---|---|
| x x x x x x x 1 | Odd values |
| 0 1 1 0 x x x x | '6X' |
| 1 0 0 1 x x x x | '9X' |
Table 11 shows the INS codes defined in this part of ISO/IEC 7816. When the value of CLA lies within the range from '00' to '7F', the other values of INS codes are to be assigned by ISO/IEC JTC 1 SC17.
| Value | Command name | Clause |
|---|---|---|
| '0E' | ERASE BINARY | 6.4 |
| '20' | VERIFY | 6.12 |
| '70' | MANAGE CHANNEL | 6.16 |
| '82' | EXTERNAL AUTHENTICATE | 6.14 |
| '84' | GET CHALLENGE | 6.15 |
| '88' | INTERNAL AUTHENTICATE | 6.13 |
| 'A4' | SELECT FILE | 6.11 |
| 'B0' | READ BINARY | 6.1 |
| 'B2' | READ RECORD(S) | 6.5 |
| 'C0' | GET RESPONSE | 7.1 |
| 'C2' | ENVELOPE | 7.2 |
| 'CA' | GET DATA | 6.9 |
| 'D0' | WRITE BINARY | 6.2 |
| 'D2' | WRITE RECORD | 6.6 |
| 'D6' | UPDATE BINARY | 6.3 |
| 'DA' | PUT DATA | 6.10 |
| 'DC' | UPDATE DATA | 6.8 |
| 'E2' | APPEND RECORD | 6.7 |
The parameter bytes P1-P2 of a command may have any value. If a parameter byte provides no further qualification, then it shall be set to '00'.
Each data field shall have one of the following three structures.
This part of ISO/IEC 7816 supports the following two types of TLV-coded data objects in the data fields :
ISO/IEC 7816 uses neither '00' nor 'FF' as tag value.
Each BER-TLV data object shall consists of 2 or 3 consecutive fields (see ISO/IEC 8825 and annex D).
Each SIMPLE-TLV data object shall consist of 2 or 3 consecutive fields.
The data fields of some commands (e.g. SELECT FILE), the value fields of the SIMPLE-TLV data object and the value field of the some primitive BER-TLV data objects are intended for encoding one or more data elements.
The data fields of some other commands (e.g. record-oriented commands) and the value fields of the other primitive BER-TLV data objects are intended for encoding one or more SIMPLE-TLV data objects.
The data fields of some other commands (e.g. object-oriented commands) and the value fields of the constructed BER-TLV data objects are intended for encoding one or more BER-TLV data objects.
NOTE - Before between or after TLV-coded data objects, '00' or 'FF' bytes without any meaning may occur (e.g. due to erase or modified TLV-coded data objects).
The status bytes SW1-SW2 of a response denote the processing state in the card. Figure 7 shows the structural scheme of the values defined in this part of ISO/IEC 7816.
NOTE - When SW1='63' or '65', the state of the non-volatile memory is changed. When SW1='6X' except '63' and '65', the state of the non-volatile memory is unchanged.
Due to specifications in part 3 of ISO/IEC 7816, this part does not define the following values of SW1-SW2 :
The following values of SW1-SW2 are defined whichever protocol is used (see examples in annex A).
NOTE - A functionality similar to that offered by '61XX' may be offered at application level by '9FXX'. However, applications may use '9FXX' for other purposes.
Table 12 completed by tables 13 to 18 shows the general meanings of the values of SW1-SW2 defined in this part of ISO/IEC 7816. For each command, an appropriate clause provides more detailed meanings.
Tables 13 to 18 specify values of SW2 when SW1 is valued to '62', '63', '65', '68', '69' and '6A'. The values of SW2 not defined in tables 13 to 18 are RFU, except the values from 'F0' to 'FF' which are not defined in this part of ISO/IEC 7816.
| SW1-SW2 | Meaning |
|---|---|
| Normal processing | |
| '9000' | No further qualification |
| '61XX' | SW2 indicates the number of response bytes still available (see text below) |
| Warning processings | |
| '62XX' | State of non-volatile memory unchanged (further qualification in SW2, see table 13) |
| '63XX' | State of non-volatile memory changed (further qualification in SW2, see table 14) |
| Execution errors | |
| '64XX' | State of non-volatile memory unchanged (SW2='00', other values are RFU) |
| '65XX' | State of non-volatile memory changed (further qualification in SW2, see table 15) |
| '66XX' | Reserved for security-related issues (not defined in this part of ISO/IEC 7816) |
| Checking errors | |
| '6700' | Wrong length |
| '68XX' | Functions in CLA not supported (further qualification in SW2, see table 16) |
| '69XX' | Command not allowed (further qualification in SW2, see table 17) |
| '6AXX' | Wrong parameter(s) P1-P2 (further qualification in SW2, see table 18) |
| '6B00' | Wrong parameter(s) P1-P2 |
| '6CXX' | Wrong length Le: SW2 indicates the exact length (see text below) |
| '6D00' | Instruction code not supported or invalid |
| '6E00' | Class not supported |
| '6F00' | No precise diagnosis |
| SW2 | Meaning |
|---|---|
| '00' | No information given |
| '81' | Part of returned data may be corrupted |
| '82' | End of file/record reached before reading Le bytes |
| '83' | Selected file invalidated |
| '84' | FCI not formatted according to 5.1.5 |
| SW2 | Meaning |
|---|---|
| '00' | No information given |
| '81' | File filled up by the last write |
| 'CX' | Counter provided by 'X' (valued from 0 to 15) (exact meaning depending on the command) |
| SW2 | Meaning |
|---|---|
| '00' | No information given |
| '81' | Memory failure |
| SW2 | Meaning |
|---|---|
| '00' | No information given |
| '81' | Logical channel not supported |
| '82' | Secure messaging not supported |
| SW2 | Meaning |
|---|---|
| '00' | No information given |
| '81' | Command incompatible with file structure |
| '82' | Security status not satisfied |
| '83' | Authentication method blocked |
| '84' | Referenced data invalidated |
| '85' | Conditions of use not satisfied |
| '86' | Command not allowed (no current EF) |
| '87' | Expected SM data objects missing |
| '88' | SM data objects incorrect |
| SW2 | Meaning |
|---|---|
| '00' | No information given |
| '80' | Incorrect parameters in the data field |
| '81' | Function not supported |
| '82' | File not found |
| '83' | Record not found |
| '84' | Not enough memory space in the file |
| '85' | Lc inconsistent with TLV structure |
| '86' | Incorrect parameters P1-P2 |
| '87' | Lc inconsistent with P1-P2 |
| '88' | Referenced data not found |
A logical channel, as seen at the interface, works as a logical link to a DF.
There shall be independence of activity on one logical channel from activity on another one. That is, command interdependencies on one logical channel shall be independent of command interdependencies on another logical channel. However, logical channels may share application-dependent security status and therefore may have security-related command interdependencies across logical channels (e.g. password verification).
Commands referring to a certain logical channel carry the respective logical channel number in the CLA byte (see tables 8 and 9). Logical channels are numbered from 0 to 3. If a card supports the logical channel mechanism, then the maximum number of available logical channels is indicated in the card capabilities (see 8.3.6).
Command-response pairs work as currently described. This part of ISO/IEC 7816 supports only command-response pairs which shall be completed before initiating a subsequent command-response pair. There shall be no interleaving of commands and their responses across logical channels; between the receipt of a command and the sending of the response to that command only channel is opened it remains open until explicity closed by a MANAGE CHANNEL command.
NOTES
The basic logical channel is permanently available. When numbered, its number is 0. When the class byte is coded according to table 8 and 9, the bits b1 and b2 code the logical channel number.
A logical channel is opened by successful completion of
The close function of the MANAGE CHANNEL command may be used to explicitly close a logical channel using the logical channel number. After closing the logical channel number will be available for re-use. The basic logical channel shall not be closed.
The goal of secure messaging (SM) is to protect [part of] the messages to and from a card by ensuring two basic security functions: data authentication and data confidentiality.
Secure messaging is achieved by applying one or more security mechanisms. Each security mechanism involves an algorithm, a key, an argument and often, initial data.
This clause defines 3 types of SM-related data objects :
In each message involving security mechanisms based on cryptography, the data field shall comply with the basic encoding rules of ASN.1 (see ISO/IEC 8825 and annex D), unless otherwise indicated by the class byte (see 5.4.1).
In the data field, the present SM format may be selected
In the context-specific class, the bit 1 of the tag fixes whether the SM-related data object shall (b1=1) or not (b1=0) be integrated in the computation of a data object for authentication. If present, the data objects of the other classes shall be integrated in such a computation.
Encapsulation is mandatory for data not coded in BER-TLV and for BER-TLV, including SM-related data objects. Encapsulation is optional for BER-TLV, not including SM-related data objects. Table 19 shows plain data objects for encapsulation.
| Tag | Value |
|---|---|
| 'B0','B1' | BER-TLV, including SM-related data objects |
| 'B2','B3' | BER-TLV, but not SM-related data objects |
| '80','81' | not BER-TLV-coded data |
| '99' | SM status information (e.g. SW1-SW2) |
The computation of cryptographic checksums (see ISO/IEC 9797) involves an initial check block, secret key and a block cipher algorithm that need not be reversible. The algorithm under control of the related key basically transforms a current input block of k bytes (typically 8 or 16) into a current output block of the same length.
The computation of a cryptographic checksum is performed in the following consecutive stages :
The cryptographic checksum shall integrate any SM-related data object having a tag where b1=1 and any data object with a tag outside the range from '80' to 'BF'. Those data objects shall integrate data block by data block in the current check block. The splitting into data blocks shall be performed in the following way.
The padding consists of one mandatory byte valued to '80' followed, if needed, by 0 to k-1 bytes set to '00', until the respective data block is filled up to k bytes. Padding for authentication has no influence on transmission as the padding bytes shall not be transmitted.
The mode of operation is "cipher block chaining" (see ISO/IEC 10116). The first input is the exclusive-or of the initial check block with the first data block. The first output results from the first data block. The first output results from the first input. The current input is the exclusive-or of the previous output with the current data block. The current output results from the current input. The final check block is the last output.
Table 20 shows the cryptographic checksum data object.
| Tag | Value |
|---|---|
| '8E' | Cryptographic checksum (at least 4 bytes) |
The digital signature computation is typically based upon asymmetric cryptographic techniques. There are two types of digital signatures :
The computation of a digital signature with appendix implies the use of a hash function (see ISO/IEC 10118). The data input either consists of the value of the digital signature input data object (see table 21), or is determined by the mechanism define in 5.6.3.1.
The computation of a digital signature related data objects.
| Tag | |
|---|---|
| '9A','BA' | Digital signature input data |
| '9E' | Digital signature |
Data objects for confidentiality are intended for carrying a cryptogram which plain value consists of one of the following 3 cases :
Padding has to be indicated when the plain value consists of not BER-TLV coded data. When padding is applied but not indicated the rules defined in 5.6.3.1 shall apply.
| Tag | Value |
|---|---|
| '82','83' | BER-TLV, including SM-related data objects |
| '84','85' | BER-TLV, but not SM-related data objects |
| '86','87' | Padding indicator byte (see table 23) followed by cryptogram (plain not coded in BER-TLV) |
Every data object for confidentiality may use any cryptographic algorithm and any mode of operation owning to an appropriate algorithm reference (see 5.6.5.1). In the absence of an algorithm reference and when no mechanism is implicitly selected for confidentiality a default mechanism shall apply.
For the computation of a cryptogram which is preceded by the padding indicator, the default mechanism is block cipher in "electronic code book" mode (see ISO/IEC 10116). The use of a block cipher may involve padding. Padding for confidentiality has an influence on transmission, the cryptogram (one or more blocks is longer than the plain text).
Table 23 shows the padding indicator byte
| Value | Meaning |
|---|---|
| '00' | No further indication |
| '01' | Padding as defined in 5.6.3.1 |
| '02' | No padding |
| '80' to '8E' | Proprietary |
| Other values are RFU |
For the computation of a cryptogram not preceded by a padding indicator byte, the default mechanism is a stream cipher with exclusive-or of the string of data bytes to be concealed with a concealing string of the same length. Concealment thus requires no padding and the data objects concealed in the value field are recovered by the same operation.
An algorithm, a key and, possibly initial data may be selected for each security mechanism
Each command message may carry a response descriptor template fixing the data objects required in response. Inside the response descriptor, the security mechanisms are not yet applied: the receiving entity shall apply them for constructing the response.
Table 24 shows the control reference templates.
| Tag | Meaning |
|---|---|
| 'B4','B5' | Template valid for cryptographic checksum |
| 'B6','B7' | Template valid for digital signature |
| 'B8','B9' | Template valid for confidentiality |
The last possible position of a control reference template is just before the first data object to which the referred mechanism applies. For example, the last possible position of a template for cryptographic checksum is just before the first data object integrated in the computation.
Each control reference remains valid until a new control reference is provided for the same mechanism. For example, a command may fix control references for the next command.
Each control reference template is intended for carrying control reference data objects (see table 25): an algorithm reference, a file reference, a key reference, an initial data reference and only in a control reference template for confidentiality a cryptogram contents reference.
The algorithm reference fixes an algorithm and its mode of operation (see ISO/IEC 9979 and 10116). Structure and coding of the algorithm reference are not defined in this part of ISO/IEC 7816.
The file reference denotes the file where the key reference is valid. If no file reference is present, then the key reference is valid in the current DF.
The key reference identifies the key to be used.
The initial data reference, when applied to cryptographic checksums, fixes the initial check block. If no initial data reference is present and no initial check block is implicitly selected, then the null block shall be used. Moreover, before transmitting the first data object for confidentiality using a stream cipher, a template for confidentiality shall provide auxiliary data for initializing the computation of the string of concealing bytes.
The cryptogram contents reference specifies the content of the cryptogram (e.g. secret key, initial password, control words). The first byte of the value field is named the type cryptogram descriptor byte and is mandatory. The range '00' to '7F' is RFU. The range '80' to 'FF' is proprietary.
| Tag | Value |
|---|---|
| '80' | Alogorithm reference |
| File reference | |
| '81' | - file identifier or path |
| '82' | - DF name |
| Key reference | |
| '83' | - for direct use |
| '84' | - for computing a session key |
| Initial data reference | |
| '85' | - L=0, null block |
| '86' | - L=0, chaining block |
| '87' | - L=0, previous initial value block plus one L=k, initial value block |
| Auxiliary data | |
| '88' | - L=0, previous exchanged challenge plus one L!=0, no further indication |
| '89'-'8D' | - L=0, index of a proprietary data element, L!=0, value of a proprietary data element |
| '8E' | Cryptogram contents reference |
The response descriptor template, if present in the data field of the command APDU, shall fix the structure of the corresponding response. Empty data objects shall list all data needed for producing the response.
The security items (algorithms, key and initial data) used for processing the data field of a command message may be different from those used for producing the data field of the subsequent response messsage.
The following rules shall apply
Table 26 shows the response descriptor template.
| Tag | Value |
|---|---|
| 'BA','BB' | Response descriptor |
In any command using secure messaging the following specific error conditions
may occur:
SW1='69' with SW2=
It shall not be mandatory for all cards complying to this part of ISO/IEC 7816 to support all the described commands or all the options of a supported command.
When international interchange is required, a set of card system services and related commands is defined in clause 9.
Table 11 provides a summary of the commands defined in this part of ISO/IEC 7816.
The impact of secure messaging (see 5.6) on the message structure is not described in this clause.
The list of error and warning conditions give in each clause 6.X.5 is not exhaustive (see 5.4.5).
The Read Binary response message gives (part of) the content of an EF with transparent structure.
The command can be performed only if the security status satisfies the security attributes defined for this EF for the read function.
The command shall be aborted if it is applied to an EF without transparent structure.
| CLA | As defined in 5.4.1 |
| INS | 'B0' |
| P1-P2 | See text below |
| Lc field | Empty |
| Data field | Empty |
| Le field | Number of bytes to be read |
If bit8=1 in P1, then bit7-6 are set to 0. bit3-1 of P1 are a short EF (Elementary File) identifier and P2 is the offset of the first byte to be read in date units from the beginning of the file.
If bit8=0 in P1, then P1||P2 is the offset of the first byte to be read in data units from the beginning of the file.
If the Le field contains only zeroes, then within the limit of 256 for short length or 65536 for extended length, all the bytes until the end of the file should be read.
| Data field | Data read (Le bytes) |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The WRITE BINARY command message initiates the writing of binary values into an EF.
Depending upon the file attributes, the command shall perform one of the following operations :
When no indication is given in the data coding byte, the logical OR behavior shall apply.
When the command contains a valid short EF identifier, it sets the file as current EF.
The command is processed on the currently selected EF. The command can be performed only if the security status satisfies the security attributes for the write functions.
Once a WRITE BINARY has been applied to a data unit of a one-time write EF, any further write operation referring to this data unit will be aborted if the content of the data unit or the logical erased state indicator (if any) attached to this data unit is different from the logical erased state.
The command shall be aborted if is is applied to an EF without transparent structure.
| CLA | As defined in 5.4.1 |
| INS | 'D0' |
| P1-P2 | See text below |
| Lc field | Length of the subsequent data field |
| Data field | String of data units to be written |
| Le field | Empty |
If b8=1 in P1, then bit7-6 are set to 0 (RFU bits). bit5-1 of P1 are a short EF identifier and P2 is the offset of the first byte to be written in data units from the beginning of the file.
If b8=0 in P1, then P1||P2 is the offset of the first byte to be written in data units from the beginning of the file.
| Data field | Empty |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The UPDATE BINARY command message initiates the update of the bits already present in an EF with the bits given in the command APDU.
When the command contains a valid short EF identifier, it sets the file as current EF.
The command is processed on the currently selected EF. The command can be performed only if the security status satisfies the security attributes for the update function.
The command shall be aborted if it is applied to an EF without transparent structure.
| CLA | As defined in 5.4.1 |
| INS | 'D6' |
| P1-P2 | See text below |
| Lc field | Length of the subsequent data field |
| Data field | String of data units to be updated |
| Le field | Empty |
If b8=1 in P1, then b6-5 are set to 0 (RFU bits). bit5-1 of P1 are a short EF identifier and P2 is the offset of the first byte to be updated in data units from the beginning of the file.
If b7=1 in P1, then P1||P2 is the offset of the first byte to be written in data units from the beginning of the file.
| Data field | Empty |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The ERASE BINARY command message sets (part of) the content of an EF to its logical erased state, sequentially starting from a given offset.
When the command contains a valid short EF identifier, it sets the file as current EF.
The command is processed on the currently selected EF. The command can be performed only if the security status satisfies the security attributes for the erase function.
The command shall be aborted if it is applied to an EF without transparent structure.
| CLA | As defined in 5.4.1 |
| INS | '0E' |
| P1-P2 | See text below |
| Lc field | Empty or '02' |
| Data field | See text below |
| Le field | Empty |
If b8=1 in P1, then b7-6 are set to 0 (RFU bits). bit5-1 are a short EF identifier and P2 is the offset of the first byte to be updated in data units from the beginning of the file.
If b8=0 in P1, then P1||P2 is the offset of the first byte to be written in data units from the beginning of the file.
| Data field | Empty |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The READ RECORD(S) response message gives the contents of the specified record(s) (or the beginning part of one record) of an EF.
The command can be performed only if the security status satisfies the security attributes for this EF for the read function.
If an EF is currently selected at the time of issuing the command, then this command may be processed without identification of this file.
When the command contains a valid short EF identifier, it sets the file as current EF and resets the current record pointer.
The command shall be aborted if applied to an EF without record structure.
| CLA | As defined in 5.4.1 |
| INS | 'B2' |
| P1 | Record number or record identifier of the first record to be read ('00' indicates the current record) |
| P2 | Reference control, according to table 36 |
| Lc field | Empty |
| Data field | Empty |
| Le field | Number of bytes to be read |
| b8 b7 b6 b5 b4 b3 b2 b1 | Meaning |
|---|---|
| 0 0 0 0 0 -- -- -- | Currently selected EF |
| x x x x x -- -- -- | Short EF identifier |
| 1 1 1 1 1 -- -- -- | RFU |
| -- -- -- -- -- 1 x x | Usage of record number in P1 |
| -- -- -- -- -- 1 0 0 | - Read record P1 |
| -- -- -- -- -- 1 0 1 | - Read all records from P1 up to the last |
| -- -- -- -- -- 1 1 0 | - Read all records from the last up to P1 |
| -- -- -- -- -- 1 1 1 | RFU |
| -- -- -- -- -- 0 x x | Usage of record identifier in P1 |
| -- -- -- -- -- 0 0 0 | - Read first occurence |
| -- -- -- -- -- 0 0 1 | - Read last occurrence |
| -- -- -- -- -- 0 1 0 | - Read next occurrence |
| -- -- -- -- -- 0 1 1 | - Read previous occurrence |
If the Le field contains only zeros, then depending on bit3-1 of P2 and within the limit of 256 for short length or 65536 for extended length, the command should read completely
| Data field | Lr (may be equal to Le) bytes, see table 38 |
| SW1-SW2 | Status bytes |
When the record are SIMPLE-TLV data objects (see 5.4.4), table 38 illustrates the format of the data field of the response message.
| Tn (1 byte) | Ln (1 or 3 byte) | First data bytes of the record |
| Tn (1 byte) | Ln (1 or 3 bytes) | Whole data bytes of the record Ln bytes |
| Record #n Tn||Ln||Vn | ... | First bytes of record #n+m Tn+m||Ln+m||Vn+m |
| Record #n Tn||Ln||Vn | ... | Record #n+m Tn+m||Ln+m||Vn+m |
The comparision of the length of the data field with its TLV structure gives the nature of the data: the unique record (read one record) or the last record (read all records) is incomplete, complete or padded.
NOTE - If TLV coding is not used, then the read-all-records function results in receiving serverl records without standard delimitation of the records.
The following specific warning conditions may occur.
The WRITE RECORD command message initiates one of the following operations :
When no indication is given in the data coding byte, the logical OR operation shall apply.
When using current record addressing the command shall set the record pointer on the successfully written record.
The command can be performed only if the security status satisfies the security attributes for this EF for the write functions.
If an EF is currently selected at the time of issuing the command, then this command may be processed without identification of this file.
When the command contains a valid short EF identifier, it sets the file as current EF and resets the current record pointer.
The command shall be aborted if applied to an EF without record structure.
The previous option of the command (P2=xxxxx011) applied to a cyclic file, has the same behavior as APPEND RECORD.
| CLA | As defined in 5.4.1 |
| INS | 'D2' |
| P1 | P1='00' designates the current record P1!='00' is the number of the specified record |
| P2 | According to table 40 |
| Lc field | Length of the subsequent data field |
| Data field | Record to be written |
| Le field | Empty |
| b8 b7 b6 b5 b4 b3 b2 b1 | Meaning |
|---|---|
| 0 0 0 0 0 -- -- -- | Currently selected EF |
| x x x x x -- -- -- | Short EF identifier |
| 1 1 1 1 1 -- -- -- | RFU |
| -- -- -- -- -- 0 0 0 | First record |
| -- -- -- -- -- 0 0 1 | Last record |
| -- -- -- -- -- 0 1 0 | Next record |
| -- -- -- -- -- 0 1 1 | Previous record |
| -- -- -- -- -- 1 0 0 | Record number given in P1 |
| Any other value | RFU |
| Tn (1 byte) | Ln (1 or 3 bytes) | Whole data bytes of the record (Ln bytes) |
| Data field | Empty |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The APPEND RECORD command message initiates either the appending of a record at the end of an EF of linear structure or the writing of record number 1 in an EF of cyclic structure.
The command shall set the record pointer on the successfully appended record.
The command can be performed only if the security status satisfies the security attributes for this EF for the append function.
If an EF is currently selected at the time of issuing the command, then this command may be processed without identification of this file.
When the command contains a valid short EF identifier, it sets the file as current EF and resets the current record pointer.
The command shall be aborted if applied to an EF without record structure.
NOTE - If this command is applied to an EF of cyclic structure full of records, then the record with the highest record number is replaced. This record becomes record number 1.
| CLA | As defined in 5.4.1 |
| INS | 'E2' |
| P1 | Only P1='00' is valid |
| P2 | According to table 44 |
| Lc field | Length of the subsequent data field |
| Data field | Record to be appended |
| Le field | Empty |
| b8 b7 b6 b5 b4 b3 b2 b1 | Meaning |
|---|---|
| 0 0 0 0 0 0 0 0 | Currently selected EF |
| x x x x x 0 0 0 | Short EF identifier |
| 1 1 1 1 1 0 0 0 | RFU |
| Any other value | RFU |
| Tn (1 byte) | Ln (1 or 3 bytes) | Whole data bytes of the record (Ln bytes) |
| Data field | Empty |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The UPDATE RECORD command message initiates the updating of a specific record with the bits given in the command APDU.
When using current record addressing, the command shall set the record pointer on the successfully updated record.
The command can be performed only if the security status satisfies the security attributes for this EF for the update function.
If an EF is currently selected at the time of issuing the command, then this command may be processed without identification of this file.
When the command contains a valid short EF identifier, it sets the file as current EF and resets the current record pointer.
The command shall be aborted if applied to an EF without record structure.
When the command applies to an EF with linear fixed or cyclic structure, the it shall be aborted if the record length is different form the length of the existing record.
When the command applies to an EF with linear variable structure, then it may be carried out when the record length is different from the length of the existing record.
The previous option of the command (P2=0x03), applied to a cyclic file, has the same behaviour as APPEND RECORD.
| CLA | As defined in 5.4.1 |
| INS | 'DC' |
| P1 | P1='00' designates the current record P1!='00' is the number of the specified record |
| P2 | According to table 48 |
| Lc field | Length of the subsequent data field |
| Data field | Record to be updated |
| Le field | Empty |
| b8 b7 b6 b5 b4 b3 b2 b1 | Meaning |
|---|---|
| 0 0 0 0 0 -- -- -- | Currently selected EF |
| x x x x x -- -- -- | Short EF identifier |
| 1 1 1 1 1 -- -- -- | RFU |
| -- -- -- -- -- 0 0 0 | First record |
| -- -- -- -- -- 0 0 1 | Last record |
| -- -- -- -- -- 0 1 0 | Next record |
| -- -- -- -- -- 0 1 1 | Previous record |
| -- -- -- -- -- 1 0 0 | Record number given in P1 |
| Any other value | RFU |
| Tn (1 byte) | Ln (1 or 3 bytes) | Whole data bytes of the record (Ln bytes) |
| Data field | Empty |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The GET DATA command is used for the retrieval of one primitive data object, or the retrieval of one or more data objects contained in a constructed data object, within the current context (e.g. application-specific environment or current DF).
The command can be performed only if the security status satisfies the security conditions defined by the application within the context for the function.
| CLA | As defined in 5.4.1 |
| INS | 'CA' |
| P1-P2 | See table 52 |
| Lc field | Empty |
| Data field | Empty |
| Le field | Number of bytes expected in response |
| Value | Meaning |
|---|---|
| '0000'-'003F' | RFU |
| '0040'-'00FF' | BER-TLV tag (1 byte) in P2 |
| '0100'-'01FF' | Application data (proprietary coding) |
| '0200'-'02FF' | SIMPLE-TLV tag in P2 |
| '0300'-'3FFF' | RFU |
| '4000'-'FFFF' | BER-TLV tag (2 bytes) in P1-P2 |
Get application data
When a primitive data object is requested, the data field of the response message shall contain the value of the corresponding primitive data object.
When a constructed data object is requested, the data field of the response message shall contain the value of the constructed data object, i.e. data objects including their tag, length and value.
| Data field | Lr (may be equal to Le) bytes |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
The PUT DATA command is used for storing one primitive data object or one or more data objects contained in a constructed data object within the current context (e.g. application-specific environment or current DF). The exact storing functions (writing once and/or updating and/or appending) are to be induced by the definition or the nature of the data objects.
NOTE - The command could be used for example to update data objects.
The command can be performed only if the security status satisfies the security conditions defined by the application within the context for the function(s).
| CLA | As defined in 5.4.1 |
| INS | 'DA' |
| P1-P2 | See table 55 |
| Lc field | Length of the subsequent data field |
| Data field | Parameters and data to be written |
| Le field | Empty |
| Value | Meaning |
|---|---|
| '0000'-'003F' | RFU |
| '0040'-'00FF' | BER-TLV tab (1 byte) in P2 |
| '0100'-'01FF' | Application data (proprietary coding) |
| '0200'-'02FF' | SIMPLE-TLV tag in P2 |
| '0300'-'3FFF' | RFU |
| '4000'-'FFFF' | BER-TLV tag (2 bytes) in P1-P2 |
Store application data
When a primitive data object is requested, the data field of the command message shall contain the value of the corresponding primitive data object.
When a constructed data object is provided, the data field of the command message shall contain the value of the constructed data object, i.e. data objects including their tag, length and value.
| Data field | Empty |
| SW1-SW2 | Status bytes |
The following specific warning conditions may occur.
A successful Select File sets a current file within a logical channel. Subsequent command may implicitly refer to the current file through that logical channel.
Selecting a DF (which may be the MF) sets it as current DF. After such a selection, an implicit current EF may be referred to through that logical channel.
Selecting an EF sets a pair of current files: the EF and its parent file.
After the answer to reset, the MF is implicitly selected through the basic logical channel, unless specified differently in the historical bytes or in the initial date string.
NOTE - A direct selection by DF name can be used for selecting applications registered according to part 5 of ISO 7816.
The following conditions shall apply to each open logical channel.
Unless otherwise specified, the correct execution of the command modifies the security status according to the following rules :
| CLA | As defined in 5.4.1 |
| INS | 'A4' |
| P1 | Selection control, see table 58 |
| P2 | Selection control, see table 59 |
| Lc field | Empty or length of the subsequent data field |
| Data field | If present according to P1-P2
|
| Le field | Empty or maximum length of data expected in response |
| b8 b7 b6 b5 b4 b3 b2 b1 | Meaning |
|---|---|
| 0 0 0 0 0 0 x x | Selection by file identifier |
| 0 0 0 0 0 0 0 0 | - Select MF, DF or EF (data field=identifier or empty) |
| 0 0 0 0 0 0 0 1 | - Select child DF (data field=DF identifier) |
| 0 0 0 0 0 0 1 0 | - Select EF under current DF (data field=EF identifier) |
| 0 0 0 0 0 0 1 1 | - Select parent DF of the current DF (empty data field) |
| 0 0 0 0 0 1 x x | Selection by DF name |
| 0 0 0 0 0 1 0 0 | - Direct selection by DF name (data field=DF name) |
| 0 0 0 0 1 x x x | Selection by path (see 5.1.2) |
| 0 0 0 0 1 0 0 0 | - Select from MF (data field=path without the identifier of the MF) |
| 0 0 0 0 1 0 0 1 | - Select from current DF (data field=path without the identifier of the current DF) |
| Any |