The Basic Encoding Rules (BER) is one of the encoding formats defined as part of the ASN.1 standard specified by the ITU in X.690.
The Basic Encoding Rules were the original rules laid out by the ASN.1 standard for encoding abstract information into a concrete data stream. The rules, collectively referred to as a transfer syntax in ASN.1 parlance, specify the exact octet sequences which are used to encode a given data item. The syntax defines such elements as: the representations for basic data types, the structure of length information, and the means for defining complex or compound types based on more primitive types. The BER syntax, along with two subsets of BER (the Canonical Encoding Rules and the Distinguished Encoding Rules), are defined by the ITU-T's X.690 standards document, which is part of the ASN.1 document series.
The BER format specifies a self-describing and self-delimiting format for encoding ASN.1 data structures. Each data element is encoded as a type identifier, a length description, the actual data elements, and where necessary, an end-of-content marker. These types of encodings are commonly called type-length-value or TLV encodings. This format allows a receiver to decode the ASN.1 information from an incomplete stream, without requiring any pre-knowledge of the size, content, or semantic meaning of the data.
The encoding of a PDU consists of cascaded TLV encodings, encapsulating types are SEQUENCE, SET and CHOICE.
The type field is an octet specifying the characteristics of the value field.
If Class is set to Universal, the value is of a type native to ASN.1 (e.g. INTEGER). The Application class is only valid for one specific application. Context-specific depends on the context (such as within a sequence, set or choice) and private can be defined in private specifications.
P/C is the primitive/constructed bit, it specifies if the value is primitive like an INTEGER or constructed which means, it again holds TLV values like a SET. If the bit is "on" (value = 1), it indicates a constructed value.
Number specifies the tag, i.e. of which exact kind the value is.
Additional information from http://luca.ntop.org/Teaching/Appunti/asn1.html:
The P/C (primitive/constructed) bit has value 0 for primitive and 1 for constructed. Some types (such as strings) may be encoded in either primitive or constructed form. When the encoding is primitive, the value field contains the representation of the tagged data item, whereas when the encoding is constructed, the value field contains a sequence of TLVs.
A tag number field of 1F indicates that the tag number is stored in subsequent bytes in base-128 in big-endian order where the 8th bit is 1 if more bytes follow and 0 for the last byte of the tag number.
Full article ▸