For the latest version of ISO7816 part 4, please contact ISO in Switzerland.
Each 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).
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.
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).
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.