ISO/IEC 7816 Part 4: Interindustry command for interchange


1. Scope

2. Normative references

3. Definitions

4. Abbreviations and notation

5. Basic organizations

6 Basic interindustry commands

7 Transmission-oriented interindustry commands

8 Historical bytes

9 Application-independent card services

A Transportation of APDU messages by T=0

B Transportation of APDU messages by T=1

C Record pointer management

D Use of the basic encoding rules of ASN.1

E Examples of card profiles

F Use of secure messaging


1 Scope

This part of ISO/IEC 7816 specifies

It does not cover the internal implentation within the card and/or the outside world.
It allows further standardization of additional interindustry commands and security architectures.

2 Normative references

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.

3 Definitions

For the puposes of this part of ISO/IEC 7816, the following definitions apply :

4 Abbreviations and notation

For the purposes of this part of the ISO/IEC 7816, the following abbreviations apply :

APDUApplication protocol data unit
ATRAnswer to reset
BERBasic encoding rules of ASN.1 (see annex D)
CLAClass byte
DIRDirectory
DFDedicated file
EFElementary file
FCIFile control information
FCPFile control parameter
FMDFile management data
INSInstruction byte
MFInstruction byte
P1-P2Parameter bytes
PTSProtocol type selection
RFUReserved for future use
SMSecure messaging
SW1-SW2Status bytes
TLVTag length value
TPDUTransmission 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||B2Concatenation of bytes B1 (the most significant byte) and B2 (the least significant byte)
#Number

5 Basic organizations

5.1 Data structures

This clause contains information on the logical structure of data as seen at the interface, when processing interindustry commands for interchange. The actual storage location of data and structural information beyond what is described in this clause are outside the scope of ISO/IEC 7816.

5.1.1 File organization
This part of ISO/IEC 7816 supports the following two categories of files :

The logical organization of data in a card consists of following structural hierachy of dedicated files :

The following two types of EFs are defined :

Figure 1 illustrates an example of the logical file organization in a card.
Figure 1 - Logical file organization (example)

5.1.2 File referencing methods

When a file cannot be implicitly selected, it shall be possible to select it by at least one of the following methods :

5.1.3 Elementary file structures

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 :

Figure 2 shows those for EF structures.

F I G U R E 2

Figure 2 - EF structures
NOTE - The arrow on the figure references the most recently written record.

5.1.4 Data referencing mehods
Data may be referenced as records, as data units or as data objects. Data is considered to be stored in a single continuous sequence of records (within an EF of record structure) or of data units (within an EF of transparent structure). Reference to a record or to a data unit outside an EF is an error.
Data referencing method, record numbering method and data unit size are EF-dependent features. The card can provide indications in the ATR, in the ATR file and in any file control information. When the card provides indications in several places, the indication valid for a given EF is the closest one to that EF within the path from the MF to that EF.
5.1.4.1 Record referencing
Within each EF of record structure, each record can be referenced by a record identifier and/or by a record number. Record identifiers and record numbers are unsigned 8-bit integers with values in the range from '01' to 'FE'. The value '00' is reserved for special purposes. The value 'FF' is RFU.
Referencing by record identifier shall induce the management of a record pointer. A reset of the card, a SELECT FILE and any command carrying a valid short EF identifier can affect the record pointer. Referencing by record number shall not affect the record pointer.

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 :

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 : The following additional rules are defined for linear structures and for cyclic structures : Referencing by record number - Within each EF of record structure, the record numbers are unique and sequential :

5.1.4.2 Data unit referencing

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

  1. An EF of record structure may support data unit referencing and in case it does, data units may contain structural information along with data, e.g. record numbers in a linear structure.
  2. Within an EF of record structure, data unit referencing may not provide the intended result because the storage order of the records in the EF is not known, e.g. storage order in a cyclic structure.

5.1.4.3 Data object referencing
Each data object (as defined in 5.4.4) is headed by a tag which references it. Tags are specified in this part and other parts of ISO/IEC 7816.

5.1.5 File control information

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.

TagValues
'62'File control parameters (FCP template)
'64'File management data (FMD template)
'6F'File control information (FCI template)
Table 1 - Template relevant to FCI
The 3 templates may be retrieved according to selection options of the SELECT FILE command. If the FCP or FMD option is set, then the use of the corresponding template is mandatory. If the FCI option is set then the use of the FCI template is optional.

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 :

Table 2 - File control parameters
TagLValueApplies to
'80'2Number of data bytes in the file, excluding structural information.Transparent EFs
'81'2Number of data bytes in the file, including structural information if anyAny file
'82'1File descriptor byte (see table 3)Any file
'82'2File descriptor byte followed by data coding byte (see table 86)Any file
'82'3 or 4File descriptor byte followed by data coding byte and maximum record length.EFs with record structure
'83'2File identifierAny file
'84'1 to 16DF nameDFs
'85'var.Proprietary informationAny file
'86'var.Security attributes (coding outside the scope of this part of ISO/IEC 7816)Any file
'87'2Identifier of an EF containing an extension of the FCIAny file
'88' to '9E'RFU
'9FXY'RFU
Table 3 - File descriptor bytey
b8 b7 b6 b5 b4 b3 b2 b1Meaning
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 xEF structure
0 -- -- -- -- 0 0 0No information given
0 -- -- -- -- 0 0 1Transparent
0 -- -- -- -- 0 1 0Linear fixed, no further info
0 -- -- -- -- 0 1 1Linear fixed SIMPLE-TLV
0 -- -- -- -- 1 0 0Linear variable, no further info
0 -- -- -- -- 1 0 1Linear variable SIMPLE-TLV
0 -- -- -- -- 1 1 0Cyclic, no further info
0 -- -- -- -- 1 1 1Cyclic, SIMPLE-TLV
1 x x x x x x xRFU
Shareable means that the file supports at least concurrent access on different logical channels.

5.2 Security architecture of the card

This clause describes the following features :

Security attributes are compared with the security status to execute command and/or to access files.

5.2.1 Security status

Security status represents the current state possibly achieved after completion of

The security status may also result from the completion of a security procedure related to the identification of the involved entities, if any, e.g. Three security statuses are considerd : If the concept of logical channels is applied, the file specify security status may depend on the logical channel (see 5.5.1).

5.2.2 Security attributes

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 :

NOTE - Security attributes may also be associated to other objects (e.g. keys).

5.2.3 Security mechanisms

This part of ISO/IEC 7816 defines the following security mechanisms :

The result of an authentication may be logged in an internal EF according to the requrements of the application.

5.3 APDU message structure

A step in an application protocol consists of sending a command, processing it in the receiving entity and sending back the response. Therefore a spcecific response corresponds to a specific command, referred to as a command-response pair.
An application protocol data unit (APDU) contains either a command message or a response message, sent from the interface device to the card or conversely.
In a command-response pair, the command message and the response message may contain data, thus inducing four cases which are summarised by table 4.
Table 4 - Data within a command-response pair
CaseCommand dataExpected response data
1No dataNo data
2No dataData
3DataNo data
4DataData

5.3.1 Command APDU

Illustrated by figure 3 (see also table 6), the command APDU defined in this part of ISO/IEC 7816 consists of

HeaderBody
CLA INS P1 P2[Lc field] [Data field] [Le field]
Figure 3 - Command APDU structure
The number of bytes present in the data field of the command APDU is denoted by Lc.

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.

I M A G E 4

Figure 4 - The 4 structures of command APDUs
In case 1, the length Lc is null; therefore the Lc field and the data field are empty. The length Le is also null; therefore the Le field is empty. Consequently, the body is empty.
In case 2, the length Lc is null; therefore the Lc field and the data field are empty. The length of Le is not null; therefore the Le field is present. Consequently, the body consists of the Le field.
In case 3, the length Lc is not null; therefore the Lc field is present and the data field consists of the Lc subsequent bytes. The length Le is null; therefore the Le field is empty. Consequently, the body consists of the Lc field followed by the data field.
In case 4, the length Lc is not null; therefore the Lc field is present and the data field consists of the Lc subsequent bytes. The length Le is also not null; therefore the Le field is also present. Consequently, the body consists of the Lc field followed by the data field and the Le field.

5.3.2 Decoding conventions for command bodies

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)

Figure 5 - Not empty body
In the card capabilities (see 8.3.6), the card states that, within the command APDU, the Lc field and Le field Consequently, the cases 2, 3 and 4 are either short (one byte for each length field) or extended (B1 is valued to '00' and the value of each length is coded on 2 other 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.

Table 5 - Decoding of the command APDUs
ConditionsCase
L=01

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 2S - L=1 Case 3S - L=1 + (B1) and (B1) != 0 Case 4S - L=2 + (B1) and (B1) != 0 For cards indicating the extension of Lc and Le (see 8.3.8 card capabilities), the next 3 cases also apply.

Case 2E - L=3 and (B1)=0

Case 3E - L=3 + (B2||B3). (B1)=0 and (B2||B3)=0 Case 4E - L= 5 + (B2||B3),(B1)=0 and (B2||B3)=0 For each transmission protocol defined in part 3 of ISO/IEC 7816 an annex attached to this part (one per protocol) specifies the transport of the APDUs of a command-response pair for each of the previous 4 cases.

5.3.3 Response APDU

Illustrated by figure 6 (see also table 7), the response APDU defined in this part of ISO/IEC 7816 consists of

BodyTrailer
[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.

5.4 Coding conventions for command headers, data fields and response trailers

Table 6 shows the contents of the command APDU.

Table 6 - command APDU contents
CodeNameLengthDescription
CLAClass1Class of instruction
INSInstruction1Instruction code
P1Parameter 11Instruction parameter 1
P2Parameter 21Instruction parameter 2
Lc fieldLengthvariable 1 or 3Number of bytes present in the data field of the command
Data fieldDatavariable=LcString of bytes sent in the data field of the command
Le fieldLengthvariable 1 or 3Maximum number of bytes expected in the data field of the response to the command

Table 7 shows the contents of the response APDU.

CodeNameLengthDescription
Data fieldDatavariable=LrString of bytes received in the data field of the response
SW1Status byte 11Command processing status
SW2Status byte 21Command 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'.

5.4.1 Class byte

According to table 8 used in conjunction with table 9, the class byte CLA of a command is used to indicate

Table 8 - Coding and meaning of CLA
ValueMeaning
'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 7FRFU
8X, 9XStructure 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
AXUnless 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 CFStructure of command and response according to this part of ISO/IEC 7816
D0 to FEProprietary structure and coding of command and response
FFReserved for PTS
Table 9 - Coding and meaning of nibble 'X' when CLA='0X','8X','9X' or 'AX'
b4 b3 b2 b1Meaning
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 xLogical channel number (according to 5.5) (b2 b1 = 00 when logical channels are not used or when logical channel #0 is selected

5.4.2 Instruction byte

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.

Table 10 - Invalid INS codes
b8 b7 b6 b5 b4 b3 b2 b1Meaning
x x x x x x x 1Odd 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.

Table 11 - INS codes defined in this part of ISO/IEC 7816
ValueCommand nameClause
'0E'ERASE BINARY6.4
'20'VERIFY6.12
'70'MANAGE CHANNEL6.16
'82'EXTERNAL AUTHENTICATE6.14
'84'GET CHALLENGE6.15
'88'INTERNAL AUTHENTICATE6.13
'A4'SELECT FILE6.11
'B0'READ BINARY6.1
'B2'READ RECORD(S)6.5
'C0'GET RESPONSE7.1
'C2'ENVELOPE7.2
'CA'GET DATA6.9
'D0'WRITE BINARY6.2
'D2'WRITE RECORD6.6
'D6'UPDATE BINARY6.3
'DA'PUT DATA6.10
'DC'UPDATE DATA6.8
'E2'APPEND RECORD6.7

5.4.3 Parameter bytes

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'.

5.4.4 Data field bytes

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).

5.4.5 Status bytes

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.

F I G U R E 7

Figure 7 - Structural scheme of status bytes

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.

Table 12 - Coding of SW1-SW2
SW1-SW2Meaning
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

Table 13 - Coding of SW2 when SW1='62'
SW2Meaning
'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

Table 14 - Coding of SW2 when SW1='63'
SW2Meaning
'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)

Table 15 - Coding of SW2 when SW1='65'
SW2Meaning
'00'No information given
'81'Memory failure

Table 16 - Coding of SW2 when SW1='68'
SW2Meaning
'00'No information given
'81'Logical channel not supported
'82'Secure messaging not supported

Table 17 - Coding of SW2 when SW1='69'
SW2Meaning
'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

Table 18 - Coding of SW2 when SW1='6A'
SW2Meaning
'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

5.5 Logical channels

5.5.1 General concept

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

  1. More than one logical channel may be opened to the same DF, if not excluded (see file accessibility in 5.1.5)
  2. More than one logical channel may select the same EF if not excluded (see file accessibility in 5.1.5)
  3. A SELECT FILE command on any logical channel will open a current DF and possibly a current EF. Therefore, there is one current DF and possibly one current EF per logical channel as a result of the behavior of the SELECT FILE command and file accessing commands using a short EF identifier.

5.5.2 Basic logical channel

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.

5.5.3 Opening a logical channel

A logical channel is opened by successful completion of

5.5.4 Closing a logical channel

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.

5.6 Secure messaging

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.

5.6.1 SM format concept

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

The SM format defined in this part of ISO/IEC 7816 is BER-TLV coded.

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.

5.6.2 Plain value data objects

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.

Table 19 - Plain value data objects
TagValue
'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)

5.6.3 Data objects for authentication

5.6.3.1 Cryptographic checksum data object

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 :

Table 20 shows the cryptographic checksum data object.

Table 20 - Cryptographic checksum data object
TagValue
'8E'Cryptographic checksum (at least 4 bytes)

6.5.3.2 Digital signature data object

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.

Table 21 - Digital signature related data objects
Value
Tag
'9A','BA'Digital signature input data
'9E'Digital signature

5.6.4 Data objects for confidentiality

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.

Table 22 - Data objects for confidentiality
TagValue
'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

Table 23 - Padding indicator byte
ValueMeaning
'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.

5.6.5 Auxiliary security data objects

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.

5.6.5.1 Control references

Table 24 shows the control reference templates.

Table 24 - Control reference templates
TagMeaning
'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.

Table 25 - Control reference data objects
TagValue
'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

5.6.5.2 Response descriptor

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.

Table 26 - Response descriptor template
TagValue
'BA','BB'Response descriptor

5.6.6 SM status conditions

In any command using secure messaging the following specific error conditions may occur:

SW1='69' with SW2=

6 Basic interindustry commands

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).

6.1 READ BINARY

6.1.1 Definition and scope

The Read Binary response message gives (part of) the content of an EF with transparent structure.

6.1.2 Conditional usage and security
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 defined for this EF for the read function.

The command shall be aborted if it is applied to an EF without transparent structure.

6.1.3 Command message

Table 27 - READ BINARY command APDU
CLAAs defined in 5.4.1
INS'B0'
P1-P2See text below
Lc fieldEmpty
Data fieldEmpty
Le fieldNumber 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.

6.1.4 Response message (nominal size)

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.

Table 28 - READ BINARY response APDU
Data fieldData read (Le bytes)
SW1-SW2Status bytes

6.1.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.2 WRITE BINARY command

6.2.1 Definition and scope

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.

6.2.2 Conditional usage and security

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.

6.2.3 Command message

Table 29 - WRITE BINARY command APDU
CLAAs defined in 5.4.1
INS'D0'
P1-P2See text below
Lc fieldLength of the subsequent data field
Data fieldString of data units to be written
Le fieldEmpty

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.

6.2.4 Response message (nominal case)

Table 30 - WRITE BINARY response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.2.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.3 UPDATE BINARY command

6.3.1 Definition and scope

The UPDATE BINARY command message initiates the update of the bits already present in an EF with the bits given in the command APDU.

6.3.2 Conditional usage and security

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.

6.3.3 Command message

Table 31 - UPDATE BINARY command APDU
CLAAs defined in 5.4.1
INS'D6'
P1-P2See text below
Lc fieldLength of the subsequent data field
Data fieldString of data units to be updated
Le fieldEmpty

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.

6.3.4 Response message (nominal case)

Table 32 - UPDATE BINARY response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.3.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.4 ERASE BINARY command

6.4.1 Definition and scope

The ERASE BINARY command message sets (part of) the content of an EF to its logical erased state, sequentially starting from a given offset.

6.4.2 Conditional usage and security

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.

6.4.3 Command message

Table 33 - ERASE BINARY command APDU
CLAAs defined in 5.4.1
INS'0E'
P1-P2See text below
Lc fieldEmpty or '02'
Data fieldSee text below
Le fieldEmpty

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.

6.4.4 Response message (nominal case)

Table 34 - ERASE BINARY response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.4.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.5 READ RECORD(S) command

6.5.1 Definition and scope

The READ RECORD(S) response message gives the contents of the specified record(s) (or the beginning part of one record) of an EF.

6.5.2 Conditional usage and security

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.

6.5.3 Command message

Table 35 - READ RECORD(S) command APDU
CLAAs defined in 5.4.1
INS'B2'
P1Record number or record identifier of the first record to be read ('00' indicates the current record)
P2Reference control, according to table 36
Lc fieldEmpty
Data fieldEmpty
Le fieldNumber of bytes to be read

Table 36 - Coding of the reference control P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 -- -- --Currently selected EF
x x x x x -- -- --Short EF identifier
1 1 1 1 1 -- -- --RFU
-- -- -- -- -- 1 x xUsage 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 1RFU
-- -- -- -- -- 0 x xUsage 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

6.5.4 Response message (nominal case)

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

Table 37 - READ RECORD(S) response APDU
Data fieldLr (may be equal to Le) bytes, see table 38
SW1-SW2Status 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.

Table 38-1 - Data field of the response when reading for one record
Case A - Partial read of one record
Tn (1 byte)Ln (1 or 3 byte)First data bytes of the record
This case applies when the Le field does not contain only zeroes.

Case B - Complete read of one record
Tn (1 byte)Ln (1 or 3 bytes)Whole data bytes of the record Ln bytes
This case applies when the Le field contains only zeroes.

Table 38-2 - Data field of the response when reading for several records
Case C - Partial read of a record sequence
Record #n Tn||Ln||Vn...First bytes of record #n+m Tn+m||Ln+m||Vn+m
This case applies when the Le field does not contain only zeroes.

Case D - Read multiple records up to the file end
Record #n Tn||Ln||Vn...Record #n+m Tn+m||Ln+m||Vn+m
This case applies when the Le field contains only zeroes.

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.

6.5.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.6 WRITE RECORD command

6.5.1 Definition and scope

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.

6.6.2 Conditional usage and security

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.

6.6.3 Command message

Table 39 - WRITE RECORD command APDU
CLAAs defined in 5.4.1
INS'D2'
P1P1='00' designates the current record
P1!='00' is the number of the specified record
P2According to table 40
Lc fieldLength of the subsequent data field
Data fieldRecord to be written
Le fieldEmpty

Table 40 - Coding of the reference control P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 -- -- --Currently selected EF
x x x x x -- -- --Short EF identifier
1 1 1 1 1 -- -- --RFU
-- -- -- -- -- 0 0 0First record
-- -- -- -- -- 0 0 1Last record
-- -- -- -- -- 0 1 0Next record
-- -- -- -- -- 0 1 1Previous record
-- -- -- -- -- 1 0 0Record number given in P1
Any other valueRFU
When the records are SIMPLE-TLV data objects (see 5.4.4), table 41 illustrates the format of the data field of the command message.

Table 41 - Data field of the command
Complete write of one record
Tn (1 byte)Ln (1 or 3 bytes)Whole data bytes of the record (Ln bytes)

6.6.4 Response message (nominal case)

Table 42 - WRITE RECORD response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.6.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.7 APPEND RECORD

6.7.1 Definition and scope

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.

6.7.2 Conditional usage and security

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.

6.7.3 Command message

Table 43 - APPEND RECORD command APDU
CLAAs defined in 5.4.1
INS'E2'
P1Only P1='00' is valid
P2According to table 44
Lc fieldLength of the subsequent data field
Data fieldRecord to be appended
Le fieldEmpty

Table 44 - Coding of the reference control P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 0 0 0Currently selected EF
x x x x x 0 0 0Short EF identifier
1 1 1 1 1 0 0 0RFU
Any other valueRFU
When the records are SIMPLE-TLV data objects (see 5.4.4), table 45 illustrates the format of the data field of the command message.

Table 45 - Data field of the command
Complete append of one record
Tn (1 byte)Ln (1 or 3 bytes)Whole data bytes of the record (Ln bytes)

6.7.4 Response message (nominal case)

Table 46 - APPEND RECORD response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.7.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.8 UPDATE RECORD command

6.8.1 Definition and scope

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.

6.8.2 Conditional usage and security

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.

6.8.3 Command message

Table 47 - UPDATE RECORD command APDU
CLAAs defined in 5.4.1
INS'DC'
P1P1='00' designates the current record
P1!='00' is the number of the specified record
P2According to table 48
Lc fieldLength of the subsequent data field
Data fieldRecord to be updated
Le fieldEmpty

Table 48 - Coding of the reference control P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 -- -- --Currently selected EF
x x x x x -- -- --Short EF identifier
1 1 1 1 1 -- -- --RFU
-- -- -- -- -- 0 0 0First record
-- -- -- -- -- 0 0 1Last record
-- -- -- -- -- 0 1 0Next record
-- -- -- -- -- 0 1 1Previous record
-- -- -- -- -- 1 0 0Record number given in P1
Any other valueRFU
When the records are SIMPLE-TLV data objects (see 5.4.4), table 49 illustrates the format of the data field of the command message.

Table 49 - Data field of the command
Complete update of one record
Tn (1 byte)Ln (1 or 3 bytes)Whole data bytes of the record (Ln bytes)

6.8.4 Response message (nominal case)

Table 50 - UPDATE RECORD response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.8.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.9 GET DATA command

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).

6.9.3 Command message

The command can be performed only if the security status satisfies the security conditions defined by the application within the context for the function.

Table 51 - GET DATA command APDU
CLAAs defined in 5.4.1
INS'CA'
P1-P2See table 52
Lc fieldEmpty
Data fieldEmpty
Le fieldNumber of bytes expected in response

Table 52 - Coding of the reference control P1-P2
ValueMeaning
'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

Get data objects

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.

6.9.4 Response message (nominal case)

Table 53 - GET DATA response APDU
Data fieldLr (may be equal to Le) bytes
SW1-SW2Status bytes

6.9.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.10 PUT DATA command

6.10.1 Definition and scope

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.

6.10.2 Conditional usage and security

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).

6.10.3 Command message

Table 54 - PUT DATA command APDU
CLAAs defined in 5.4.1
INS'DA'
P1-P2See table 55
Lc fieldLength of the subsequent data field
Data fieldParameters and data to be written
Le fieldEmpty

Table 55 - Coding of the reference control P1-P2
ValueMeaning
'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

Store data objects

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.

6.10.4 Response message (nominal case)

Table 56 - PUT DATA response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.10.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.11 SELECT FILE command

6.11.1 Definition and scope

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.

6.11.2 Conditional usage and security

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 :

6.11.3 Command message

Table 57 - SELECT FILE command APDU
CLAAs defined in 5.4.1
INS'A4'
P1Selection control, see table 58
P2Selection control, see table 59
Lc fieldEmpty or length of the subsequent data field
Data fieldIf present according to P1-P2
  • file identifier
  • path from the MF
  • path from the current DF
  • DF name
Le fieldEmpty or maximum length of data expected in response

Table 58 - Coding of the reference control P1
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 0 x xSelection 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 xSelection 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 xSelection 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 other valueRFU

When P1='00', the card knows either because of a specific coding of the file identifier or because of the context of execution of the command if the file to select is the MF, a DF or an EF.

When P1-P2='0000', if a file identifier is provided, then it shall be unique in the following environments :

If P1-P2='0000' and if the data field is empty or equal to '3F00', then select the MF.

When P1='04', the data field is a DF name, possibly right trunctated. When supported, successive such commands with the same data field shall select DFs whose names match with the data field, i.e. start with the command data field. If the card accepts the SELECT FILE command with an empty data field, then all or a subset of the DFs can be successively selected.

NOTE - See 8.3.6 for the selection methods supported by the card.

Table 59 - Coding of the selection options P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 -- -- 0 0First record
0 0 0 0 -- -- 0 1Last record
0 0 0 0 -- -- 1 0Next record
0 0 0 0 -- -- 1 1Previous record
0 0 0 0 x x -- --File control information option (see 5.1.5)
0 0 0 0 0 0 -- --- Return FCI, optional template
0 0 0 0 0 1 -- --- Return FCP template
0 0 0 0 1 0 -- --- Return FMD template
Any other valueRFU

6.11.4 Response message (nominal case)

If the Le field contains only zeroes, then within the limit of 256 for short length or 65536 for extended length, all the bytes corresponding to the selection option should be returned.

Table 60 - SELECT FILE response APDU
Data fieldInformation according to P2 (at most Le bytes)
SW1-SW2Status bytes

6.11.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.12 VERIFY command

6.12.1 Definition and scope

The VERIFY command initiates the comparison in the card of the verification data sent from the interface device with the reference data stored in the card (e.g. password).

6.12.2 Conditional usage and security

The security status may be modified as a result of a comparison. Unsuccessful comparisons may be recorded in the card (e.g. to limit the number of further attempts of the use of the reference data).

6.12.3 Command message

Table 61 - VERIFY command APDU
CLAAs defined in 5.4.1
INS'20'
P1Only P1='00' is valid (other values are RFU)
P2Qualifier of the reference data, see table 62
Lc fieldEmpty or length of the subsequent data field
Data fieldEmpty or verification data
Le fieldEmpty

Table 62 - Coding of the reference control P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 0 0 0No information is given
0 -- -- -- -- -- -- --Global reference data (e.g. card password)
1 -- -- -- -- -- -- --Specific reference data (e.g. DF specific password)
-- -- -- x x x x xReference data number
Any other valueRFU

NOTES

  1. P2='00' is reserved to indicate that no particular qualifier is used, in those cards where the VERIFY command references the secret data unambiguously.
  2. The reference data number may be for example a password number or a short EF identifier
  3. When the body is empty, the command may be used either to retrieve the number 'X' of further allowed retries (SW1-SW2='63CX') or to check whether the verification is not required (SW1-SW2='9000').

6.12.4 Response message (nominal case)

Table 63 - VERIFY response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.12.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.13 INTERNAL AUTHENTICATE command

6.13.1 Definition and scope

The INTERNAL AUTHENTICATE command initiates the computation of the authentication data by the card using the challenge data sent from the interface device and a relevant secret (e.g. a key) stored in the card.

When the relevant secret is attached to the MF, the command may be used to authenticate the card as a whole.

When the relevant secret is attached to another DF, the comand may be used to authenticate that DF.

6.13.2 Conditional usage and security

The successful execution of the command may be subject to successful completion of prior commands (e.g. Verify, Select File) or selections (e.g. the relevant secret).

If a key and an algorithm are currently selected when issuing the command then the command may implicitly use the key and the algorithm.

The number of times the command is issued may be recorded in the card to limit the number of further attempts of using the relevant secret or the algorithm.

6.13.3 Command message

Table 64 - INTERNAL AUTHENTICATE command APDU
CLAAs defined in 5.4.1
INS'88'
P1Reference of the algorithm in the card
P2Reference of the secret, see table 65
Lc fieldLength of the subsequent data field
Data fieldAuthentication related data (e.g. challenge)
Le fieldMaximum number of bytes expected in response

P1='00' indicates that no information is given. The reference of the algorithm is known either before issuing the command or is provided in the data field.

P2='00' indicates that no information is given. The reference of the secret is known either before issuing the command or is provided in the data field.

Table 65 - Coding of the reference control P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 0 0 0No information is given
0 -- -- -- -- -- -- --Global reference data (e.g. an MF secific key)
1 -- -- -- -- -- -- --Specific reference data (e.g. DF specific key)
-- -- -- x x x x xNumber of the secret
Any other valueRFU

NOTE - The number of the secret may be for example a key number or a short EF identifier.

6.13.4 Response message (nominal case)

Table 66 - INTERNAL AUTHENTICATE response APDU
Data fieldAuthentication related data (e.g. response to the callenge)
SW1-SW2Status bytes

6.13.5 Status conditions

The following specific error conditions may occur.

6.14 EXTERNAL AUTHENTICATE command

6.14.1 Definition and scope

The EXTERNAL AUTHENTICATE command conditionally updates the security status using the result (yes or no) of the computation by the card based on a challenge previously issued by the card (e.g. by a GET CHALLENGE command) a key possibly secret stored in the card and authentication data transmitted by the interface device.

6.14.2 Conditional usage and security

The successful execution of the command requires that the last challenge obtained from the card is valid.

Unsuccessful comparisons may be recorded in the card (e.g. to limit the number of further attempts of the use of the reference data).

6.14.3 Command message

Table 67 - EXTERNAL AUTHENTICATE command APDU
CLAAs defined in 5.4.1
INS'B2'
P1Reference of the algorithm in the card
P2Reference of the secret, see table 68
Lc fieldEmpty or length of the subsequent data field
Data fieldEmpty or authentication related data (e.g. response to the challenge)
Le fieldEmpty

P1='00' indicates that no information is given. The reference of the algorithm is known either before issuing the command or is provided in the data field.

P2='00' indicates that no information is given. The reference of the secret is known either before issuing the command or is provided in the data field.

Table 68 - Coding of the reference control P2
b8 b7 b6 b5 b4 b3 b2 b1Meaning
0 0 0 0 0 0 0 0No information is given
0 -- -- -- -- -- -- --Global reference data (e.g. an MF secific key)
1 -- -- -- -- -- -- --Specific reference data (e.g. DF specific key)
-- -- -- x x x x xNumber of the secret
Any other valueRFU

NOTES

  1. The number of the secret may be for example a key number or a short EF identifier.
  2. When the body is empty, the command may be used either to retrieve the number 'X' of further allowed retries (SW1-SW2='63CX') or to check whether the verification is not required (SW1-SW2='9000').

6.14.4 Response message (nominal case)

Table 69 - EXTERNAL AUTHENTICATE response APDU
Data fieldEmpty
SW1-SW2Status bytes

6.14.5 Status conditions

The following specific warning conditions may occur.

The following specific error conditions may occur.

6.15 GET CHALLENGE command

6.15.1 Definition and scope

The GET CHALLENGE command requires the issuing of a challenge (e.g. random number) for use in a security related procedure (e.g. EXTERNAL AUTHENTICATE command).

6.15.2 Conditional usage and security

The challenge is valid at least for the next command. No further condition is specified in this part of ISO/IEC 7816.

6.15.3 Command message

Table 70 - GET CHALLENGE command APDU
CLAAs defined in 5.4.1
INS'B4'
P1-P2'0000' (other values are RFU)
Lc fieldEmpty
Data fieldEmpty
Le fieldMaximum length of the expected response

6.15.4 Response message (nominal case)

Table 71 - EXTERNAL AUTHENTICATE response APDU
Data fieldChallenge
SW1-SW2Status bytes

6.15.5 Status conditions

The following specific error conditions may occur :

6.16 MANAGE CHANNEL command

6.16.1 Definition and scope

The MANAGE CHANNEL command opens and closes logical channels.

The open function opens a new logical channel other than the basic one. Options are provided for the card to assign a logical channel number or for the logical channel number to be supplied to the card.

The close function explicitly closes a logical channel other than the basic one. After the successful closing the logical channel shall be available for re-use.

6.16.2 Conditional usage and security

When the open function is performed from the basic logical channel then after a successful open the MF shall be implicitly selected as the current DF and the security status for the new logical channel should be the same as for the basic logical channel after ATR. The security status of the new logical channel should be separate from that of any other logical channel.

When the open function is performed from a logical channel which is not the basic one then after a successful open the current DF of the logical channel from which the command was issued shall be selected as the current DF and the security status for the new logical channel should be the same as for the logical channel from which the open function was performed.

After a successful close function the security status related to this logical channel is lost.

6.14.3 Command message

Table 72 - MANAGE CHANNEL command APDU
CLAAs defined in 5.4.1
INS'70'
P1P1='00' to open a logical channel
P1='80' to close a logical channel (other values are RFU)
P2'00'-'03' (other values are RFU)
Lc fieldEmpty
Data fieldEmpty
Le field'01' if P1-P2='0000'
Empty if P1-P2!='0000'

b8 of P1 is used to indicate the open function or the close function. If b8 is 0 then MANAGE CHANNEL shall open a logical channel and if b8 is 1 then MANAGE CHANNEL shall close a logical channel.

For the open function (P1='00'), the b1 and b2 of P2 are used to code the logical channel number in the same manner as in the class byte (see 5.4.1), the other bits of P2 are RFU.

6.14.4 Response message (nominal case)

Table 73 - MANAGE CHANNEL response APDU
Data fieldLogical channel number if P1-P2='0000'
Empty if P1-P2!='0000'
SW1-SW2Status bytes

6.14.5 Status conditions

The following specific warning conditions may occur.

7 Transmission-oriented interindustry commands

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 and options shall be used as 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 given in each clause 7.X.5 is not exhaustive (see 5.4.5).

7.1 GET RESPONSE command

7.1.1 Definition and scope

The GET RESPONSE command is used to transmit from the card to the interface device APDU(s) (or part of the APDUs) which otherwise could not be transmitted by the available protocols.

7.1.2 Conditional usage and security

No condition.

7.1.3 Command message

Table 74 - GET RESPONSE command APDU
CLAAs defined in 5.4.1
INS'C0'
P1-P2'0000' (other values are RFU)
Lc fieldEmpty
Data fieldEmpty
Le fieldMaximum length of data expected in response

7.1.4 Response message (nominal case)

Table 75 - GET RESPONSE response APDU
Data field(Part of) APDU according to Le
SW1-SW2Status bytes

7.1.5 Status conditions

The following specific normal processing may occur :

The following specific warning condition may occur : The following specific error conditions may occur.

7.2 ENVELOPE command

7.2.1 Definition and scope

The ENVELOPE command is used to transmit APDU(s) or part of APDUs or any data string which otherwise could not be transmitted by the available protocols.

NOTE - The usage of ENVELOPE for SM is shown in annex F.

7.2.2 Conditional usage and security

No condition.

7.2.3 Command message

Table 76 - ENVELOPE command APDU
CLAAs defined in 5.4.1
INS'C2'
P1-P2'0000' (other values are RFU)
Lc fieldLength of the subsequent data field
Data field(Part of) APDU
Le fieldEmpty of length of expected data

When the ENVELOPE command is used under T=0 for transmitting data strings, an empty data field in an ENVELOPE command APDU means end of data string.

7.1.4 Response message (nominal case)

Table 77 - ENVELOPE response APDU
Data fieldEmpty or (part of) APDU according to Le
SW1-SW2Status bytes

NOTE - The status bytes belong to the ENVELOPE command. Status bytes of a command transmitted in the data field of the ENVELOPE command may be found in the data field of the ENVELOPE response.

7.2.5 Status conditions

The following specific error conditions may occur.

8 Historical bytes

8.1 Pupose and general strucutre

The historical bytes tell the outside world how to use the card when the transport protocol is ascertained according to part 3 of ISO/IEC 7816.

The number of historical bytes (at most 15 bytes) is specified and coded as defined in part 3 of ISO/IEC 7816.

The information carried by the historical bytes may also be found in an ATR file (default EF identifier='2F01').

If parent, the historical bytes are made up of three fields :

8.2 Category indicator (mandatory)

The category indicator is the first historical byte. If the category indicator is equal to '00', '10' or '8X', then the format of the historical bytes shall be according to this part of ISO/IEC 7816.

Table 78 - Coding of the category indicator
ValueMeaning
'00'Status information shall be present at the end of the historical bytes (not in TLV).
'10'Specified in 8.5
'80'Status information if present is contained in an optional COMPACT-TLV data object.
'81'-'8F'RFU
Other valuesProprietary

8.3 Optional COMPACT-TLV data objects

The coding of the COMPACT-TLV data objects is deduced from the basic encoding rules af ASN.1 (see ISO/IEC 8825 and annex D) for BER-TLV data objects with tag='4X' and length='0Y'. The coding of such data objects is replaced by 'XY' followed by 'Y' bytes of data. In this clause, 'X' is referred to as the tag number and 'Y' as the length.

Besides the data objects defined in this clause, the historical bytes may contain data objects defined in part 4 of ISO/IEC 7816. In this case the coding of the tags and length fields defined in part 5 shall be modified as above.

When COMPACT-TLV data objects defined in this clause appear in the ATR file, they shall be encoded according to the basic encoding rules of ASN.1 (i.e tag='4X', length='0Y').

All application-class tags not defined in ISO/IEC 7816 are reserved for ISO.

8.3.1 Country/issuer indicator

When present this data object denotes a country or an issuer.

This data object is introduced by either '1Y' or '2Y'.

Table 79 - Coding of the country/issuer indicator
TagLengthValue
'1'variableCountry code and national date
'2'variableIssuer identification number

The tag '1' is followed by the appropriate length (1 nibble) and by three digits denoting the country as defined in ISO 3166. Data which follows (odd number of nibbles) is chosen by the relevant national standardization body.

The tag '2' is followed by the appropriate length (1 nibble) and by the issuer identification number as defined in part 1 of ISO/IEC 7812. If the issuer identification number contains an odd number of digits, then it shall be right padded with a nibble valued 'F'.

Card service data

This data object denotes the methods available in the card for supporting the services described in clause 9.

This data object is introduced by '31'.

When this data object is not present, the card supports only the implicit application selection.

Table 80 - Card-profile for application-independent card services
b8 b7 b6 b5 b4 b3 b2 b1Meaning
1 -- -- -- -- -- -- --Direct application selection by full DF name
-- 1 -- -- -- -- -- --Selection by partial DF name (see 9.3.2)
-- -- x x -- -- -- --Data objects available
-- -- 1 -- -- -- -- --- in DIR file
-- -- -- 1 -- -- -- --- in ATR file
-- -- -- -- x -- -- --File I/O services by
-- -- -- -- 1 -- -- --- READ BINARY command
-- -- -- -- 0 -- -- --- READ RECORD(S) command
-- -- -- -- -- x x x'000' (other value are RFU)

NOTE - The contents of the DIR and ATR files may give information on selection methods.

8.3.3 Initial access data

This optional data object allows the retrieval of a string of data objects defined in ISO/IEC 7816. The string retrieved by this data object is called the "initial data string".

This data object is introduced by '41','42' or '45'.

Any command APDU described in this clause is assumed to be the first command sent after the answer to reset. Consequently, the data available at this point may not be subsequently retrievable.

8.3.3.1 Length='1'

When only one byte of information is provided, it indicates the length of the command to perform for retrieving the initial data string. The command to perform is a READ BINARY command structured as follows :

Table 81 - Coding of the command when length='1'
CLA'00' (see 5.4.1)
INS'B0'
P1-P2'0000'
Lc fieldEmpty
Data fieldEmpty
Le fieldFirst and only byte of value field of initial access data (indicating the number of bytes to be read)

8.3.3.2 Length='2'

When two bytes of information are provided, the first byte indicates the file structure (transparent or record) and the short identifier of the EF to be read. The second byte indicates the length of the READ command to perform for retrieving data string.

Table 82 - Structure of the file byte
b8= 0 Record oriented file
= 1 Transparent file
b7-6'00' (other values are RFU)
b5-1Short EF identifier

When b8=0, the command to perform is a READ RECORD(S) command structured as follows :

Table 83 - Coding of the command when b8=0
CLA'00' (see 5.4.1)
INS'B2'
P1'01'
P2Short EF identifier (from the first byte of initial access data) followed by b3-1='110'
Lc fieldEmpty
Data fieldEmpty
Le fieldSecond and last byte of bvalue field of initial access data (indicating the number of bytes to be read)

When b8=1, the command to perform is a READ BINARY command structured as follows :

Table 84 - Coding of the command when b8=1
CLA'00' (see 5.4.1)
INS'B0'
P1Value of the first byte on initial access data
P2'00'
Lc fieldEmpty
Data fieldEmpty
Le fieldSecond and last byte of bvalue field of initial access data (indicating the number of bytes to be read)

8.3.3.3 Length='5'

The value found in the initial access data object consists of the APDU of a command to perform. When executed this command provides the initial data string in its response data field.

8.3.4 Card issuer's data

Thsi data object is optional and of variable length. Structure and coding are defined by the card issuer.

This data object is introduced by '5Y'.

8.3.5 Pre-issuing data

This data object is optional and of variable length. Structure and coding are not defined in this part of ISO/IEC 7816. It may be used for indicating

This data object is introduced by '6Y'.

8.3.6 Card capabilities

This data object is optional and of variable length. Its value field consists of either the first software function table, or the first two software tables, or the three software function tables.

This data object is introduced by '71','72' or '73'.

Table 85 shows the first software function table.

Table 85 - First software function table
b8 b7 b6 b5 b4 b3 b2 b1Meaning
DF selection
1 -- -- -- -- -- -- --- by full DF name
-- 1 -- -- -- -- -- --- by partial DF name
-- -- 1 -- -- -- -- --- by path
-- -- -- 1 -- -- -- --- by file identifier
-- -- -- -- 1 -- -- --- implicit
EF management
-- -- -- -- -- 1 -- --- Short EF identifier supported
-- -- -- -- -- -- 1 --- Record number supported
-- -- -- -- -- -- -- 1- Record identifier supported

Table 86 shows the second software function table which is the data coding byte. The data coding byte may also be present as the second data element in the file control parameter with tag '82' (see table 2).

Table 86 - Second software function table (data coding byte)
b8 b7 b6 b5 b4 b3 b2 b1Meaning
-- x x -- -- -- -- --Behavior of write functions
-- 0 0 -- -- -- -- --- one-time write
-- 0 1 -- -- -- -- --- proprietary
-- 1 0 -- -- -- -- --- write OR
-- 1 1 -- -- -- -- --- write AND
-- -- -- -- -- x x xData unit size in nibbles (power of 2, e.g. '001'=2 nibbles) (default value=one byte)
x -- -- x x -- -- --0..00 (other values are RFU)

Table 87 shows the third software functions table.

Table 87 - Third software function table
b8 b7 b6 b5 b4 b3 b2 b1Meaning
x -- -- -- -- -- -- --0 (1 is RFU)
-- 1 -- -- -- -- -- --- Extended Lc and Le fields
-- -- x -- -- -- -- --0 (1 is RFU)
-- -- -- x x -- -- --Logical channel assignment
-- -- -- 0 1 -- -- --- by the card
-- -- -- 1 0 -- -- --- by the interface device
-- -- -- 0 0 -- -- --No logical channel
-- -- -- -- -- x -- --0 (1 is RFU)
-- -- -- -- -- -- x yMaximum number of logical channels (=2*x+y+1)

8.4 Status information

The status information consists of 3 bytes: the card life status (1 byte) and the two status bytes SW1-SW2.

The value '00' of the card life status indicates that no card life status is provided. The values '80' to 'FE' are proprietary. All other values are RFU.

The value '9000' of SW1-SW2 indicates normal processing as defined in 5.4.5.

The value '0000' of SW1-SW2 indicates that the status is not indicated.

If the category indicator is valued to '80', then the status information may be present in a COMPACT-TLV data object. In this case, the tag number is '8'. When the length is '1', then the value is the card life status. When the length is '2', then the value is SW1-SW2. When the length is '3', then the value is the card life status followed by SW1-SW2. Other values of the length are reserved for ISO.

8.5 DIR data reference

If the category indicator is '10', then the following byte is the DIR data reference. The coding and meaning of this byte are outside the scope of this part of the ISO/IEC 7816.

9 Application-independent card services

9.1 Definitions and scope

This clause describes the application-independent card services, referred to as "card services" in the following text. Their purpose is to provide interchange mechanisms between a card and an interface device knowing nothing about each other except that both comply with this part of ISO/IEC 7816.

Card services are supported by any combination of

The commands use CLS='00' (see 5.4.1), i.e. 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. It is possible for an application to use other mechanisms compatible with this part of ISO/IEC 7816 for achieving similar functions. Therefore such solutions may not guarantee interchange.

The following card services are defined

9.2 Card identification service

This function consists of the card providing information to the outside world on its logical content as well as some general data objects all applications might be interested in (e.g. interindustry data objects). The information, called "card identification data", is given by the card in the historical bytes and possibly in a file implicitly selected immediately after the answer to reset.

Access to this file is indicated in the initial access data information (see 8.3.3).

If the initial access data of the historical bytes does not denote a READ command, then the response to the command to perform contains card identification data.

9.3 Application selection service

An application is either implicitly selected in a card or can be explicitly selected by its name.

9.3.1 Implicit application selection

When an application is implicitly selected in a card, the application identifier as defined in part 5 of ISO/IEC 7816 should be indicated in the card identification data. If not present in the card identification data, then it shall be present in the ATR file.

9.3.2 Direct application selection

A card in a multi-application environment shall be able to respond positively to a direct application selection performed by a SELECT FILE command specifying the application identifier as DF name.

The application identifier should be provided completely in the command APDU. In case of an application selection by partial DF name, the next application matching with the name proposed may be selected and the full DF name will be made available in the response message of the SELECT FILE command as the file control parameter with tag '84' (see table 2).

The APDU of the command to perform is the following.

Table 88 - Coding of the command for direct application selection
CLA'00' (see 5.4.1)
INS'A4'
P1-P1'0400'
Lc fieldLength in bytes of the data field
Data fieldFull or partial DF name
Le fieldPresent, contains only zeroes

9.4 Data object retrieval service

Data objects used for application-independent international interchange are defined in this part and other parts of ISO/IEC 7816.

The retrieval of those data objects relies on one or both of the following menthods :

The information necessary to retrieve data objects by an indirect method is defined in part 6 of ISO/IEC 7816.

9.5 File selection service

When the path to an EF is known, the number of SELECT FILE commands to be issued equals the length of the path divided by two, minus one (the path always starts with the current DF).

If the path length is more than four bytes, then until all available DF identifiers of the path have been used, one or more SELECT FILE commands shall be performed with the following command APDU.

Table 89 - Coding of the command to select a DF using a file identifier
CLA'00' (see 5.4.1)
INS'A4'
P1-P2'0100'
Lc field'02'
Data fieldDF identifier (from bytes 3 and 4 of the path)
Le fieldEmpty

The last and possibly only selection is an EF selection with the following command APDU.

Table 90 - Coding of the command to select an EF
CLA'00' (see 5.4.1)
INS'A4'
P1-P2'0200'
Lc field'02'
Data fieldDF identifier (last two bytes of the path)
Le fieldEmpty

9.6 File I/O service

Once a file used for interindustry interchange has been selected, the contents relevant to interchange shall be returned by one of the following command APDUs.

Annex A Transportation of APDU message by T=0

A.1 Case 1

The command APDU is mapped onto the T=0 command TPDU by assigning the value '00' to P3.

Command APDU
CLA INS P1 P2
Command TPDU
CLA INS P1 P2P3='00'

The response TPDU is mapped onto the response APDU without any change.

Response APDU
SW1 SW2
Response TPDU
SW1 SW2

A.2 Case 2 Short

It this case, Le is valued from 1 to 256 and coded on byte B1 (B1='00' means maximum, i.e. Le=256).

The command APDU is mapped onto the T=0 command TPDU without any change.

C-APDU
CLA INS P1 P2Le=B1
C-TPDU
CLA INS P1 P2P3=B1

The response TPDU is mapped onto the response APDU according to the acceptance of Le and according to the processing of the command.

A.3 Case 3 Short

In this case, Lc is valued from 1 to 255 and coded on byte B1 (='00').

The command APDU is mapped onto the T=0 command TPDU without any change.

C-APDU
CLA INS P1 P2Lc=B1Lc bytes
C-TPDU
CLA INS P1 P2P3=B1Lc bytes

The response TPDU is mapped onto the response APDU without any change.

R-APDU
SW1 SW2
R-TPDU
SW1 SW2

A.4 Case 4 Short

In this case, Lc is valued from 1 to 255 and coded on byte B1. Le is valued from 1 to 256 and coded on byte Bl (Bl='00' means maximum i.e. Le=256).

The command APDU is mapped onto the T=0 command TPDU by cutting the last byte of the body.

C-APDU
CLA INS P1 P2Lc=B1Lc bytesBl
C-TPDU
CLA INS P1 P2P3=B1Lc bytes

A.5 Case 2 Extended

In this case, Le is valued from 1 to 65536 and coded in 3 bytes (B1)='00', (B2||B3)=any value (B2 and B3 valued to '0000' means maximum, i.e. Le=65536).

C-APDU
CLA INS P1 P2B1='00' B2B3=Le

A.6 Case 3 Extended

In this case Lc is valued from 1 to 65535 and coded on 3 bytes: (B1)='00', (B2||B3)!='0000'.

C-APDU
CLA INS P1 P2B1='00' B2B3=LcLc bytes

A.7 Case 4 Extended

In this case Lc is valued from 1 to 65535 and coded on 3 bytes: (B1)='00', (B2||B3)!='0000', and Le is valued from 1 to 65536 and coded on 2 bytes (Bl-1||Bl)=any value (Bl-1 and Bl valued to '0000' means maximum, i.e. Le=65536).

C-APDU
CLA INS P1 P2B1='00' B2B3=LcLc bytesBl-1Bl=Le

Annex B Transportation of APDU message by T=1

B.1 Case 1

The command APDU is mapped onto the information field of an I-block without any change.

Command APDU
CLA INS P1 P2
Information field
CLA INS P1 P2

The information field of the I-block received in response is mapped onto the response APDU without any change.

Information field
SW1 SW2
Response field
SW1 SW2

B.2 Case 2 (short and extended)

The command is mapped into the information field of an I-block without any change.

C-APDU
CLA INS P1 P2Le field
Information field
CLA INS P1 P2Le field

The response APDU consists of

Either information field
Data fieldSW1-SW2
or concatenation of information fields
Data
...
...SW1-SW2
R-APDU
DataSW1-SW2

B.3 Case 3 (short and extended)

The command APDU is mapped without any change onto

C-APDU
CLA INS P1 P2Lc fieldData field
Either information field
CLA INS P1 P2Lc fieldData field
or concatenation of information fields
CLA INS P1 P2Lc fieldData ...
...
... field

The information field of the I-block received in response is mapped onto the response APDU without any change.

R-APDU
SW1 SW2
Information field
SW1 SW2

B.4 Case 4 (short and extended)

The command APDU is mapped without any change onto

C-APDU
CLA INS P1 P2Lc fieldData fieldLe field
Either information field
CLA INS P1 P2Lc fieldData fieldLe field
or concatenation of information fields
CLA INS P1 P2Lc fieldData fieldLe field
...
...Le field

The response APDU consists of

Data fieldSW1-SW2
or concatenation of information fields
Data
...
...SW1-SW2
R-APDU
DataSW1-SW2

Annex C Record pointer management

C.1 Case 1

Case 1 deals with the first command issued after a select function (either explicit or implicit). The current record pointer (CP) is undefined.

Command READ RECORDSRecord in responsePosition of CP after command
Next (id=aa)First with id=aa
If not found, then error
Record read
Undefined
Previous (id=bb)Last with id=bb
If not found, then error
Record read
Undefined
First (id=cc)First with id=cc
If not found, then error
Record read
Undefined
Last (id=dd)Last with id=dd
If not found, then error
Record read
Undefined
Next (id=00)FirstRecord read
Previous (id=00)LastRecord read
First (id=00)FirstRecord read
Last (id=00)LastRecord read
Record #00ErrorUndefined
Record #EE#EE
If not found, then error
Undefined
P1='00', P2='xxxx x101'ErrorUndefined
P1='00', P2='xxxx x110'ErrorUndefined
#jj, P2='xxxx x101'#jj to last
If #jj not found, then error
Undefined
#kk, P2='xxxx x110'Last to #kk
If #kk not found, then error
Undefined

C.2 Case 2

Command READ RECORDSRecord in responsePosition of CP after command
Next (id=aa)Next with id=aa
If no next, then error
Record read
Unchanged
Previous (id=bb)Previous with id=bb
If not found, then error
Record read
Unchanged
First (id=cc)First with id=cc
If not found, then error
Record read
Unchanged
Last (id=dd)Last with id=dd
If not found, then error
Record read
Unchanged
Next (id=00)CP+1
If CP=last, then error
Previous CP+1
Unchanged
Previous (id=00)CP-1
If CP=first, then error
Previous CP-1
Unachanged
First (id=00)FirstFirst record
Last (id=00)LastLast record
Record #00CPUnchanged
Record #EE#EE
If not found, then error
Unchanged
P1='00', P2='xxxx x101'CP to lastUnchanged
P1='00', P2='xxxx x110'Last to CPUnchanged
#jj, P2='xxxx x101'#jj to last
If #jj not found, then error
Unchanged
#kk, P2='xxxx x110'Last to #kk
If #kk not found, then error
Unchanged

Annex D Use of the basic encoding rules of ASN.1

D.1 BER-TLV data object

Eatch BER-TLV data object (see ISO/IEC 8825) shall consist of 2 or 3 consecutive fields :

ISO/IEC 7816 uses neither '00' nor 'FF' as tag value.

NOTE - Before, between or after BER-TLV data objects, '00' or 'FF' bytes without any meaning may occur (e.g. due to erased or modified TLV-coded data objects).

D.2 Tag field

The bits B8 and B7 of the leading byte of tag field shall encode the tag class, i.e. the class of the data object.

The bit B6 of the leading byte of the tag field shall encode the tag type, i.e. the type of the data object.

If the bits B5-B1 of the leading byte are not all set to 1, then may they shall encode an integer equal to the tag number which therefore lies in the range from 0 to 30. Then the tag field consists of a single byte.

Otherwise (B5-B1 set to 1 in the leading byte), the tag field shall continue on one or more subsequent bytes.

D.3 Length field

In short form, the length field consists of a single byte where the bit B8 shall be set to 0 and the bits B7-B1 shall encode an integer equal to the number of bytes in the value field. Any length from 0-127 can thus be encoded by 1 byte.

In long form, the length field consists of a leading byte where the bit B8 shall be set to 1 and the B7-B1 shall not be all equal, thus encoding a positive integer equal to the number of subsequent bytes in the length field. Those subsequent bytes shall encode an integer equal to the number of bytes in the value field. Any length within the APDU limit (up to 65535) can thus be encoded by 3 bytes.

NOTE - ISO/IEC 7816 does not use the indefinite lengths specified by the basic encoding rules of ASN.1 (see ISO/IEC 8825).

D.4 Value field

In this part of ISO/IEC 7816, the value field of some primitive BER-TLV data objects consists of zero, one or more SIMPLE-TLV data objects.

The value field of any other primitive BER-TLV data object consists of zero, one or more data elements fixed by the specifications of the data objects.

The value field of each constructed BER-TLV data object consists of zero, one or more BER-TLV data objects.

Annex E Examples of card profiles

E.1 Introduction

This annex defines a number of card profiles to guide application designers in selecting commands to use in their applications. The profiles may also be used to help specify the features desired in a card. Card profiles may be combined.

E.2 Profile M

Cards of this profile have as a minimum the following features and commands.

E.3 Profile N

This profile is the same as M, plus the additional option P1='04' in the SELECT FILE command.

E.4 Profile O

Cards of this profile have as minimum the following features and commands

E.5 Profile P

Cards of this profile have as a minimum the following features and commands :

E.6 Profile Q

Cards of this profile have a minimum the following features and commands

Annex F Use of secure messaging

F.1 Abbreviations

For the purpose of this annex, the following abbreviations apply

CCCryptographic checksum
CGCryptogram
CHCommand header (CLA INS P1 P2)
CRControl reference
FRFile reference
KRKey reference
LLength
PBPadding bytes ('80' followed by 0 to k-1 times '00' where k is the block length)
PIPadding indicator byte
PVPlain value
RDResponse descriptor
TTag
||Concatenation

For all the examples, CLA indicates the use of secure messaging by an appropriate value ('0X', '8X', '9X' or 'AX') where bit b4 of CLA is set to 1 (see table 9).

F.2 Use of cryptographic checksums

The use of cryptographic checksums (see 5.6.3.1) is shown for the four cases defined in table 4 and figure 4.

F.3 Use of cryptograms

The use of cryptograms (see 5.6.4) is shown with and without padding.

F.4 Use of control references

The use of control references (see 5.6.5.1) is shown.

Command data field = Tcr||Lcr||CR
Where CR = Tfr||Lfr||Tkr||Lkr||KR

F.5 Use of response descriptor

The use of response descriptor (see 5.6.5.1) is shown.

Command data field = Trd||Lrd||RD
Where RD = Tpv||'0C'||Tcc||'00'

Response data field = Tpv||Lpv||PV||Tcc||Lcc||CC

F.6 Use of the ENVELOPE command

The use of the ENVELOPE command is shown.

Commad data field = Tcg||Lcg||PI||CG

Data carried by CG = Command APDU starting by CH and padding bytes according to PI

Response data field = Tcg||Lcg||PI||CG

Data carried by CG = Response APDU and padding bytes according to PI


Last update : 1998-11-26