ASN.1 OCTET STRING tag: 04

The ASN.1 OCTET STRING type contains arbitrary strings of octets. This type is very similar to BIT STRING, except that all values must be an integral number of eight bits. You can use constraints to specify a maximum length for an OCTET STRING type.

Example

TransparentType ::= OCTET STRING
BinaryFile      ::= OCTET STRING

An OCTET STRING value can be expressed as either a binary string or a hexadecimal string:

eightBitBytes1 OCTET STRING ::= 'A24F'H
eightBitBytes2 OCTET STRING ::= '1010001001001111'B
OCTET STRING encoding example
Str1 ::= OCTET STRING
eightBitBytes1 Str1 ::= 'A24F'H

In BER, the OCTET STRING type value defined in the example above is encoded as follows:

04 02 A24F

The OCTET STRING type value defined in the following example:

longString OCTET STRING ::= '00112233445566778899AABBCCDDEEFF'H

is BER-encoded as follows:

24 80
   04 08 0011223344556677
   04 08 8899AABBCCDDEEFF
00 00

Constraints

The OCTET STRING type can be constrained by a single value, by type inclusion, by size, and by contents constraints.

Related Topics