ASN.1
Previous: Built-in Types Up: Built-in Types Next: Structured Types


Simple Types

 ASN.1's built-in simple types are shown in the following Table . The universal class number (tag) and a typical use of each type are also included.   

Simple Types Tag Typical Use
BOOLEAN 1 Model logical, two-state variable values
INTEGER 2 Model integer variable values
BIT STRING 3 Model binary data of arbitrary length
OCTET STRING 4 Model binary data whose length is a multiple of eight
NULL 5 Indicate effective absence of a sequence element
OBJECT IDENTIFIER 6 Name information objects
REAL 9 Model real variable values
ENUMERATED 10 Model values of variables with at least three states
CHARACTER STRING * Models values that are strings of characters from a specified characterset

Table: Simple types in ASN.1, their universal tags, and uses. * indicates more than one tag. For a full list of Universal Tags, see the Universal Tags page.


Type BOOLEAN takes values TRUE and FALSE. Usually, the type reference for BOOLEAN describes the true state. For example: Female ::= BOOLEAN is preferable to Gender ::= BOOLEAN.

Type INTEGER takes any of the infinite set of integer values. Its syntax is similar to programming languages such as C or Pascal. It has an additional notation that names some of the possible values of the integer. For example,

   ColorType ::= INTEGER
       {
          red      (0)
          white    (1)
          blue     (2)
       }

indicates that the ``ColorType" is an INTEGER and its values 0, 1, and 2 are named ``red", ``white", and ``blue", respectively. The ColorType could also have any of the other valid integer values, such as 4 or -62.

Type BIT STRING takes values that are an ordered sequence of zero or more bits. The bit sequence is either a binary or hexadecimal string delimited by single quotes followed by B or H, respectively. For example, `11010001'B or `82DA6'H are valid values of BIT STRING. The length of the string of bits must be a multiple of four when hexadecimal is used. BIT STRING also has a form similar to INTEGER, but the numbers in parentheses indicate location in the string of bits. For example, the type notation

    Occupation  ::=  BIT STRING
          {
              clerk      (0)
              editor     (1)
              artist     (2)
              publisher  (3)
          }

names the first bit ``clerk", the second bit ``editor", and so on. Strings of bits can then be written by listing the named bits that are set to 1. For example, (editor, artist) and '0110'B are two representations for the same value of ``Occupation".

Type OCTET STRING takes values that are an ordered sequence of zero or more eight-bit octets. The sequence is written in the same form as a BIT STRING sequence. Thus, `1101000100011010'B and `82DA'H are valid values of OCTET STRING.

Type NULL takes only one value, NULL. It can be used as a place marker, but other alternatives are more common.

Type OBJECT IDENTIFIER names information objects (for example, abstract syntaxes or ASN.1 modules). The type notation requires the keywords OBJECT IDENTIFIER. The named information object is a node on an object identifier tree that is managed at the international level. ISO, CCITT, or any other organization is allowed a subtree which the organization defines. On each level j of the object identifier tree, nodes are numbered 0,1,2,.... A list of positive numbers, enclosed in braces and ordered by level starting from the root, uniquely identifies an information object at a node of the tree. This ordered list of positive numbers delimited by braces is the value notation for type OBJECT IDENTIFIER. The followingFigure illustrates the concept of an object identifier tree. For example, in the subtree with root ``RetailStores'' the information object ``payroll'' has local value 0 6 2. More formally, if

    ClothingType  ::=  OBJECT IDENTIFIER

then

    payroll  ClothingType  ::=  {0 6 2}.

If the retail stores are considered as part of an international ``MegaCorp'' then 1 2 0 0 6 2 uniquely identifies ``payroll''.

  node 10

Figure: Sample object identifier tree.

Type REAL takes values that are the machine representation of a real number, namely the triplet (m, b, e), where m is the mantissa (a signed number), b the base (2 or 10), and e the exponent (a signed number). For example, the representation of the value 3.14 for the variable Pi, declared as Pi ::= REAL, can be (314, 10, -2). Three special values, PLUS-INFINITY, 0, and MINUS-INFINITY, are also allowed.

Type ENUMERATED is similar to the INTEGER type, but names specific values only. For example,

   ColorType ::= ENUMERATED
       {
          red      (0)
          white    (1)
          blue     (2)
       }

has the same interpretation as in the type INTEGER example near the beginning of this section, except that ColorType can take only the values specifically in the list; that is, no other values than 0 for ``red", 1 for ``white", or 2 for ``blue".

Type CHARACTER STRING takes values that are strings of characters from some defined (ISO- or CCITT-registered) character set. Type references and specifications of the characters in their strings are given in the next Table . Also included are short labels, called tags, that are assigned to character string types for machine readability. The value notation for each character string type is a string of characters from the corresponding character set delimited by double quotation marks. For example, if Address is of type PrintableString, then ``Villanova, PA 19085'' is an Address value.

  

Character String Type Tag Character Set
NumericString 18 0,1,2,3,4,5,6,7,8,9, and space
PrintableString 19 Upper and lower case letters, digits, space, apostrophe, left/right parenthesis, plus sign, comma, hyphen, full stop, solidus, colon, equal sign, question mark
TeletexString (T61String) 20 The Teletex character set in CCITT's T61, space, and delete
VideotexString 21 The Videotex character set in CCITT's T.100 and T.101, space, and delete
VisibleString (ISO646String) 26 Printing character sets of international ASCII, and space
IA5String 22 International Alphabet 5 (International ASCII)
GraphicString 25 All registered G sets, and space
GraphicString 27 All registered C and G sets, space and delete

Table: Character string types.


Previous: Built-in Types Up: Built-in Types Next: Structured Types


This site was developed from:
Computer Networks and Open Systems
An Application Development Perspective

by
Lillian N. Cassel
Richard H. Austing

Jones & Bartlett Publisher
ISBN 0-7637-1122-5

This site is hosted by:


Real World ASN.1 and XML Solutions