CardWerk smarter card solutions

ISO 7816-4: Interindustry Commands for Interchange

SmartCard API for .NET

Easy smart card integration with our smart card framework for .NET with C# and VB.NET sample code.

smart card API for C#

Sample code available for Mifare, DESFire, JavaCard, KVK, eGK, SIM, PIV, CAC, HID Prox/iCLASS and many more

Get SmartCard API NOW
download smart card API for C#, VB.NET and Visual Studio

ISO 7816 [part 1] [part 2] [part 3] [part4] [section..1 2 3 4 5 6 7 8 9 annex.. A B C D E F]

8 Historical bytes

8.1 Purpose and general structure
8.2 Category indicator (mandatory)
8.3 Optional COMPACT-TLV data objects
8.4 Status information
8.5 DIR data reference

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 :

  • a mandatory category indicator (1 byte)
  • optional COMPACT-TLV data objects
  • a conditional status indicator (3 bytes)

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
Value Meaning
'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 values Proprietary

8.3 Optional COMPACT-TLV data objects

8.3.1 Country/issuer indicator
8.3.2 Card service data
8.3.3 Initial access data
8.3.3.1 Length='1'
8.3.3.2 Length='2'
8.3.3.3 Length='5'
8.3.4 Card issuer's data
8.3.5 Pre-issuing data
8.3.6 Card capabilities

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
Tag Length Value
'1' variable Country code and national date
'2' variable Issuer 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 b1 Meaning
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 field Empty
Data field Empty
Le field First 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-1 Short 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'
P2 Short EF identifier (from the first byte of initial access data) followed by b3-1='110'
Lc field Empty
Data field Empty
Le field Second 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'
P1 Value of the first byte on initial access data
P2 '00'
Lc field Empty
Data field Empty
Le field Second 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

  • card manufacturer
  • integrated circuit type
  • integrated circuit manufacturer
  • ROM mask version
  • operation system version
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 b1 Meaning
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 b1 Meaning
-- x x -- -- -- -- -- Behavior of write functions
-- 0 0 -- -- -- -- -- - one-time write
-- 0 1 -- -- -- -- -- - proprietary
-- 1 0 -- -- -- -- -- - write OR
-- 1 1 -- -- -- -- -- - write AND
-- -- -- -- -- x x x Data 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 b1 Meaning
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 y Maximum 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.

[Home] | [Services] | [Solutions] | [Knowledge Base] | [Search] | [Contact]

Copyright 1999-2017 Jacquinot Consulting, Inc.
All rights reserved. Legal disclaimer Last modified August 10, 2017