ASN.1 is an international standard[1] which was originally developed as part of the OSI research, and has been adopted for use in various areas of the Internet architecture, particularly network management.
[1] ISO/IEC 8824:1987 - ASN.1 is an example of a
Data Description
Language in database terminology
[2] ISO/IEC 8825:1987
BOOLEAN
(1)INTEGER
(2)REAL
(9)BITSTRING
(3), OCTETSTRING
(4)NULL
(5)ENUMERATED
(10)NB: The numbers given in parentheses, eg (1), are called TAGS, see later this lecture.brainDamaged ::= BOOLEAN numberOfEmployees ::= INTEGER avogadrosNumber ::= REAL(602,10,23) sevenDeadlySins ::= ENUMERATED { pride(1), envy(2), gluttony(3), avarice(4), lust(5), sloth(6), wrath(7) } -- corresponding to OSI 7 layers :-)
SET
(17)SET OF
(17)SEQUENCE
(16), SEQUENCE OF
(16)CHOICE
(11)ANY
CHOICE
, except containing a list
of anything that can be defined in ASN.1
Some examples are:
messageBodyPart ::= CHOICE { [0] IMPLICIT asciiText, -- note TAG* [1] IMPLICIT telex ...etc... }
There are four classes of tags:
CHOICE
and ENUMERATED
examples in slides 2 & 3 are an example.
Gauge.
OCTET STRING
Note that in these notes, an attempt will also be made to present
all ASN.1 (and other) syntactic elements in the fixed-width
courier
typeface. Occasional lapses from this convention
may have to be forgiven by the reader...
Example:
Note also that, where appropriate, we adopt the OSI convention of referring to "octets", instead of "bytes", even though the terms have almost universally identical meaning.MyType ::= TYPE nameOfValue MyType ::= VALUE
An ASN.1 object is encoded as a TAG, a LENGTH and a VALUE, (TLV encoding) thus:
The TAG is (usually) encoded in a single octet, containing its value (see earlier) in binary in the low-order 5 bits and maybe some other information[3].![]()
The LENGTH can be encoded in two possible ways, definite (which usually only requires a single octet) and indefinite (which requires, at least, several more octets). Both are equally complicated!
The VALUE field is encoded using a specified method which is
appropriate to its type - for example, an INTEGER
is sent
as its
binary 2's complement equivalent; an OCTET STRING
is
simply the
appropriate octets.
[3]The CLASS (see slide 4) of the object (most significant 2 bits), and whether it is a simple or constructed (structured) data type (1 bit: 0 for simple, 1 for constructed).
A small-valued integer might be encoded as:![]()
A an octet-string encodes just the bytes of the string, thus:
- Note that the value field is encoded using 2's complement notation
- If the value is greater than 127 or less than -128, more octets are required, hence the length is greater.
OBJECT
IDENTIFIER
[4] data type. An OBJECT
IDENTIFIER
is a simple ASN.1 data
type with special properties.
An OBJECT IDENTIFIER
is a data type denoting an
authoritatively
named object, regardless of the type of the
object which it
names.
It is written as a sequence of non-negative integer values which describe a traversal of a tree. The tree consists of a root connected to a number of labelled nodes via edges.
Each label consists of a non-negative integer value and an
optional brief textual description (or Object
Descriptor
).
The most common format for writing down the value of an OBJECT
IDENTIFIER
is as a dotted sequence, thus:
This identifies the object found by starting at the root, moving to the node with label 1, then moving to the node with label 0, and so on. The node found after traversing this list is the one being identified.1.0.8571.5.1
[4] and the related Object
Descriptor
type.
ccitt(0)
iso(1)
joint-iso-ccitt(2)
standard(0)
registration-authority(1)
member-body(2)
identified-organisation(3)
In ASN.1, an![]()
OBJECT IDENTIFIER
is specified using the
following
syntax, eg:
The textual values (Document-Type-Name ::= OBJECT IDENTIFIER fTAM-1 Document-Type-Name ::= { 1 0 8571 5 1 }
Object Descriptors
) may also be used,
and
mixed, where no confusion can arise, eg:
or even just:internet OBJECT IDENTIFIER ::= { iso org(3) dod(6) 1 }
{ internet }
The OSI Name-Registration Hierarchy:
Note that CCITT no longer exists, having been subsumed into its parent body, the ITU - how this affects the diagram is unclear to your lecturer.![]()