ASN.1 INTEGER tag: 02

The INTEGER type value can be a positive or negative number. There are no limits imposed on the magnitude of INTEGER values in the ASN.1 standard.

INTEGER types can also be used like enumerated types in C. In a type definition, the word "INTEGER" can be followed by a bracketed list of identifiers, each assigned to a particular INTEGER value. Each identifier must begin with a lowercase letter and may contain letters, digits, or hyphens. The named number list allows INTEGER values to convey a variety of meanings. Note that not all possible values must be defined in the list. You can assign names only to the first and last legal values, or to some other significant subset of the possibilities.

Example

Size ::= INTEGER
INTEGER encoding example
Temperature ::= INTEGER
temperatureToday Temperature ::= -20

In BER, the negative INTEGER type value defined in the example above is encoded as follows:

02 01 EC

The INTEGER value defined in the following example:

Color ::= INTEGER {red(0), 
                   blue(1),
                   yellow(2)}
defaultColor Color ::= blue

is BER-encoded as:

02 01 01

Constraints

The INTEGER type can be constrained by a single value, by type inclusion, and by value range contraints.

Related Topics