BER-TLV Data structure

Source: Internet
Author: User

This article is in the study process of their own problems encountered, organized.

To facilitate the subsequent reference, the data for a section of the TLV structure is listed first:

[6F] 4d│├─[ -] -A0000003330101│├─[a5] the││├─[ -] 0B 50424f4320437265646974││├─[ the] on  on││├─[9f38] .9f33039f4e14││├─[5f2d] ,7a68656e66726465││├─[9f11] on  on││├─[9f12] 0F 4341524420494d4147452030303031││├─[bf0c] to│││└─[9F4D] Geneva0b0a
    • BER-TLV data Object Structure
    • Tag (tag)

According to ISO/IEC 8825-1 (DOC88 can see earlier version) specification definition, BER-TLV structure consists of tag, Length, value three parts;

The tag can consist of a number of bytes, as shown in:

The most important is the first byte, consisting of three parts, high two-bit representation category, low five-bit representation of tagnumber, 6th digit representation type;

    • Tag category

The first byte of the analysis of the EMV specification of a diagram illustrated in detail, domestic can also refer to the PBOC norms.

As can be seen, the high two-bit representation of four categories, respectively:

00: General Class

01: Application Class

02: Context-Sensitive classes

03: Special Class

In the smart card is more than the application class and context-related classes, the general class is not related to the industry, as if there is only one (0x06:object Identifier), the application class is many, such as the 0x6f in the previous article,

There are also frequently encountered 0x4f that indicate aid (application identifier), defined in 7816, followed in many other applications, such as EMV,PBOC,GP.

0x6F: ' 0110 1111 '

0x4f: ' 0100 1111 '

Context classes do not have the same meaning in a particular usage environment, but you can refer to the corresponding specification definitions. Specialized classes typically appear in private definitions, for example, some cards are used in pre-personalization commands for cards.

For the scope of the categories shown in the table above, the form is from the book "Smart Card Technology".

    • Tag type

The type of tag is represented by the 6th bit,

0: Represents a simple Type

1: Represents the structure type

You can use a metaphor to understand the differences between the two types, the simple type is equivalent to the leaf node in the tree structure, the structure type is equivalent to the branches. For example, in the following data,

84, 50, 87 and so on the leaf node of the tag on the expression of simple type, and 6F, A5 and other representations of the structure type. The binary representation is more intuitive to understand.

0x6F: ' 0110 1111 '

0x50: ' 0101 0000 '

    • Tag number

Tag number to determine according to the length of the tag, for a byte of the tag, can be represented by the number 2^5 is 32, but all 1 of the time indicates that there are subsequent bytes,

Therefore, a byte tag can only represent 31 numbers, greater than 31 can only be represented by the number of bytes;

Rarely encountered in normal use, only used in a demo of Javacard (here, incidentally, in the API provided by Javacard,

There is a package specifically for TLV to provide data packaging and parsing. But in the use of the process encountered a problem, similar to the example in the previous 9F One of the tag can not parse.

As shown, the TAG9F11 tag number is 0x11 according to the resolution, and the individual understands that the 0x10 here should represent the number (0X11+31).

    • Length (Long)

The length in BER-TLV represents the length of data in the Value field, consisting of 1 to multiple bytes, and if the highest bit of the first byte is 0, the lower 7 bits represent the length,

The maximum value is 0x7f,value the length of the data is greater than 128 bytes, and length is represented by 3 bytes. For more than 256 bytes less seen,

The tag used when downloading files in Javacard is often used, and extension apdus may be used.

    • Value (values)

The value is made up of one or more bytes, depending on the type in the tag, there are two representations of the simple type and the struct type, as in the data provided at the beginning of this article,

The data length of the tag6f is 0x4d, and the range is all the data behind it.

    • Data references
    • ISO/IEC 8825-1 specification: http://www.doc88.com/p-864119027073.html
    • EMV Specification: EMV:BOOK3
    • "Smart card Technology" version fourth

BER-TLV Data structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.