FILE STRUCTURE, COMMANDS AND DATA PROTECTION MECHANISMS IN EMV MICROPROCESSOR CARDS

Tomcat

Professional
Messages
2,689
Reaction score
963
Points
113

Data objects and their encoding​

Any application of a microprocessor card uses a certain set of data elements (Data Element) - the minimum units of information identified by their name, content and format (digital, binary, symbolic, mixed formats are allowed).

Data items are logical structures. For storage in card memory, they are cardped (encoded) into physical data objects. There are various forms of cardping data items to data objects. In the IPC, BER-TLV coding, formalized in the ISO / IEC 8825 standard, is widely used.

In accordance with the ISO / IEC 8825, each data object is defined by three fields: the tag (Tag), a length (Length) and value (Value). Below, the Value field of the data object will also be referred to as the data field of the data object.

The Tag field is one or more bytes. It encodes the class, type, and identifier of the data object (the Tag Number binary sequence that identifies the data object). In the EMV specifications, the Tag field is 1 or 2 bytes long. The structure of the Tag field is shown in table. 3.1 and 3.2.

As you can see from the table. 3.1, bit b6 of the first byte of the Tag field defines the type of data object. A data object can be one of two types: Primitive Data Object or Constructed Data Object. The Value field of the primitive data object contains the value of the data item. The Value field of a composite data object contains one or more primitive and / or composite data objects.

Tab. 3.1. Structure of the first byte of the Tag field

B8B7B6B5B4bsB2NSMeaning
00Universal class
01Application Class
10Context-specific Class
11Private class
0Primitive Data Object
1Constructed Data Object
11111There are other tag bytes
Any other meaningTag Number

Tab. 3.2. The structure of the subsequent bytes of the Tag field

B8B7 b6 b5 b4 b3 b2 bMeaning
1There are other tag bytes
0The last byte of the tag field
Any value> 0Tag Number

In the EMV specification, to group some data objects according to a certain common feature (for example, to group data according to their belonging to one record of a linear file, group data that are directory descriptors, etc.), composite data objects called templates are used. ... Below we will talk about FCI Template (Tag '6F'), Application Template (Tag '61') and other templates.

Bits b8 and b7 of the first (leftmost) byte of the Tag field (see Table 3.1) define the class of the data object. Depending on the meaning of these bits, the following data object classes are available:
  • 00 - a universal class (in the EMV standard, data objects of this class are not used). The high nibble (high four bits) of the first byte of the Tag field of the generic data object ranges from 'O'h to' 3'h. As before, here and below the character h denotes the representation of a number in hexadecimal notation;
  • 01 - an application class contains data objects and templates related to a specific industry (for example, the industry of financial settlements on cards). The value of the most significant nibble of the first byte of the Tag field of the data object
MasterCard

^? 9

the application class varies from '4'h to' 7'h. Data objects of this class in the EMV specifications include the card number, card expiration date, contents of the second track of the magnetic stripe of the card, service code, cardholder name, issuer country code, Application ID, etc. as well as templates FCI Template, Application Template, etc .;

10 - the context-specific class contains

data objects defined for applications of some generally accepted standard (for example, applications of the EMV standard). Data objects of this class are common to all applications of this standard. The value of the high nibble of the first byte of the Tag field of the context-defined class data object ranges from '8'h to' B'h. All data objects that first appeared in the EMV standard belong to this class (of course, the EMV standard uses objects and an application class, but defines only objects of a context-specific class);

11 - private class contains primitive and composite

data objects, defined primarily by the application specifications of a particular payment system (eg VIS 1.4 or M / Chip 4 specifications) and possibly by the issuer of the application. Obviously, the high nibble value of the first byte of the Tag field of the private class data object changes from 'C'h to' F'h. Examples of objects of this class are M / Chip 4 application data objects such as Application Control, Additional Check Table, Card Issuer Action Code, etc.

If all bits L, ..., b5 of the first byte of the Tag field are equal to 1, then the Tag field contains the second byte, the structure of which is reflected in Table. 3.2. In the second byte, only the most significant bit (b8) is not used to encode the tag identifier. This bit determines if the Tag field contains other bytes. If it is 1, then the Tag field contains at least one more byte. Otherwise, the second byte of the Tag field is also the last byte of this field. In the EMV standard, bit b8 of the second byte of the Tag field (if this byte exists) is always 0, since the maximum size of the Tag field is two bytes.

It follows from the above that if the size of the Tag field is equal to two bytes, then the value of the second nibble of the senior byte of such a tag is necessarily equal to 'F'h. The converse is not true. For example, the tag '4F' corresponding to the Application ID primitive data object is obviously one byte in size.

The BER-TLV Length field of the data object specifies the number of data bytes in the Value field. In EMV specifications, the Length field is specified by one, two or three bytes. If bit b8 of the most significant (left-most) byte of the field is 0, the Length field consists of one byte. In this case, bits b7, ..., b determine the number of bytes in the Value field. Obviously, one byte of the Length field is sufficient to encode data in the Value field of no more than 127 bytes.

If the Value field is greater than 127 bytes, bit b8 of the most significant byte of the Length field is set to 1, and bits b7-b1 of this byte specify the number of additional bytes used to represent the Length field. In the case of the EMV standard, the number of additional bytes can take only two values - 1 or 2. Note that two bytes of the Length field are enough to encode data in the Value field, the size of which does not exceed 255 bytes, and three bytes are required to encode data from 256 to 65,535 bytes.

Note that the BER-TLV data encoding method described above allows for a specific data object to unambiguously determine its identifier (Tag field), size (Length field) and value (Value field), i.e., perform the inverse transformation - get the identifier and data value ... Thus, BER-TLV encoding is a universal means of data representation. It is enough just to agree on the semantic load of the tags (identifiers) and the formats of the encoded data.

At the same time, you have to pay for the versatility of the way data is presented. In this case, the cost is to increase the size of the data due to the need to use the Tag and Length fields.

As an example, here are the details of the BER-TLV encoding of the Application Interchange Profile primitive data object:

TagLengthValue
* 9F43'h'02'h'5800' h

All data elements used in the EMV 4.2 specifications are contained in table. B1 applications B book 1 (data items that can be used in the procedure for selecting a card application) and in table. A1

MasterCard

^? 9

Appendix A of Book 3 (the rest of the data used to process the transaction). Both tables have a common structure and for each data item define:
  • the name (name) of the data item as defined in the EMV specifications;
  • description of the item (short purpose of item in EMV applications);
  • data item format: nbr (numeric item format with nbr digits), and 6 YYMMDD (numeric date format), ap nbr (alphanumeric item format with nbr characters), b (binary format);
  • tags of templates, in which the data element can be located;
  • source of the data item (the source can be the card, terminal and host of the issuer);
  • data item tag;
  • the length of the Value field of the data item.
 
Top