ASN.1 SEQUENCE tag: 16

In ASN.1, an ordered list of elements (or components) comprises a SEQUENCE. Using SEQUENCE, you can create a new type built from an arbitrary series of elements. Each element must identify its type, either by specifying a type name or by actually defining the element's type inline. Each element in the sequence must be assigned an identifier. Note that while all type names begin with upper case letters, any identifiers assigned to the elements must begin with a lower case letter. Identifiers have no effect on an encoded value of the type.


In the following example, a type called PersonnelRecord is defined as a sequence of three elements: name (an OCTET STRING), location (an INTEGER with a named number list), and age (an INTEGER). The third element in the sequence, age, is marked OPTIONAL. The presence of this element in a particular value of this type is not mandatory.

PersonnelRecord ::= SEQUENCE {
         name     OCTET STRING,
         location INTEGER { home(0), field(1), roving(2)}
         age      INTEGER   OPTIONAL

Note the use of AUTOMATIC TAGS. You can use automatic tagging to omit the tags and avoid ambiguous type definitions. The presence of a tag on one or more elements of a SEQUENCE disables automatic tagging of all of the elements of a given SEQUENCE; other SEQUENCEs, possibly nested ones, are unaffected.

The syntax above is equivalent with the following one:

PersonnelRecord ::= SEQUENCE {
         name     [0] IMPLICIT OCTET STRING,
         location [1] IMPLICIT INTEGER {home(0), field(1), roving(2)}                                        OPTIONAL,
         age      [2] IMPLICIT INTEGER OPTIONAL}
SEQUENCE encoding example
PersonnelRecord ::= SEQUENCE {
         name     OCTET STRING,
         location INTEGER { homeOffice(0),
         age      INTEGER OPTIONAL

rockStar1 PersonnelRecord ::= {
      name      '6269672068656164'H,
      location  roving,
      age       26

In BER, the SEQUENCE type values defined in the example above are encoded as follows:

30 10
   80 08 6269672068656164
   81 01 02
   82 01 1A


The SEQUENCE type can be constrained by a single value, by type inclusion, and by constraints on its components (inner subtyping).

Related Topics