TLV (Tag Length Value) Encoding

Source: Internet
Author: User
Tag fields are information about tags and encoding formats;
The length field defines the length of a value;
The content (value) field indicates the actual value.
Therefore, an encoding value is also called a TLV (TAG, length, value) triple. Encoding can be basic or structural. If it represents a simple type and a complete explicit value, encoding is primitive. If the value it represents has a nested structure, the encoding is a constructed ).

TLV encoding is the encoding of tag, length, and value. The encoding method for determining the length of the BER encoding is as follows.
There are two methods for BER encoding:
One is the encoding method with a fixed length. This consists of three parts: identifier octets, length octets, and contents octets (which can correspond to TLV ). Another encoding method is uncertain length. This consists of four parts: identifier ETS, length octets, contents octets, and end-of-contents octets. Length octets is 0x80, and end-of-contents octets is 0x00. Each type can be encoded as a fixed-length encoding method, but some types cannot be encoded as uncertain-length encoding methods. DER encoding can only be determined by length.
Identifier octets consists of three parts: Class, P/C, and tag number. The height of the first byte of identifier octets is class, the next byte is P/C, and other bits represent the tag number. Class has four types: Universal (00), application (01), context-specific (10), and private (11 ). If the P/C bit is 1, it indicates constructed, and 0 indicates primitive. If 0 <= tag number <= 30, the entire identifier octets has only one byte. Otherwise, the last five digits of the first byte are 1, and the first byte with the highest digit is 0, this is the last byte of identifier ETS ets. Remove the maximum value from the second byte to the last byte and combine it with the value of tag number.
Length ETS has two encoding methods: one is to use only one byte to indicate the length, the highest bit is 0, and the last 7 digits represent the length value, obviously, this only indicates 0-127. The other is that the highest bit of the first byte is 1, and the other bit indicates the number of bytes after which it belongs to length octets. The following bytes constitute the length value. The length value indicates the number of bytes occupied by contents octets. Der requires that the first method be used if the length is 0-127, and the latter method be used if the length is greater.
The tag field (t) consists of one or more consecutive bytes. It indicates a class,
A type, and a number. The tag field of the Data Objects
Described in this specification is coded on one or two bytes.

* The length field (l) consists of one or more consecutive bytes. It indicates
Length of the following field. The length field of the Data Objects described in
This specification is coded on one or two bytes.

* The Value Field (v) indicates the value of the data object. If l = '00', the value
Field is not present.

A BER-TLV Data Object belongs to one of the following two categories:

* A primitive data object where the value field contains a Data Element
Financial Transaction interchange.

* A constructed data object where the value field contains one or more primitive
Or constructed data objects. The Value Field of a constructed data object is
Called a template.

 

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.