Identifier

The identifier is the very first part of every encoding and occupies an integral number of octets, at least one. Its purpose is to convey

Because of carrying tag number, which can be very big, it has no fixed length. Nonetheless, major number of tags are small numbers, that's why it was possible to define the smallest single-octet variant of identifier as follows:

8

7

6

5

4

3

2

1

C C F T T T T T

The CC field alows representing any of four classes and F to flag primitive/constructed contents:

C C Tag class
0 0 universal
0 1 application-wide
1 0 context-specific
1 1 private-use
F Form
0 primitive
1 constructed

In this case only tag numbers in range for 0 to 30 inclusive can be coded. The last possible coding - 31 (TTTTT = 11111) indicates that given tag number is too big to fit into five bits and therefore is extended to next octet(s) coded as follows:

C C F 1 1 1 1 1
1 T T T T T T T
...
0 T T T T T T T

octet #1

octet #2

octet #n

Easy to understand - the very first bit (MSB) act as a flag, which indicates, whether this octet is the last one, or not. This way a tag field can be expanded to 7*(n-1) bits. Actual tag number is then concatenation of all T-bits, i.e. MSB first or Big Endian (no Intel-like LSB first/Small Endian).