Overview#Abstract Syntax Notation One (ASN.1) is defined in X.208 is a mechanism for encoding data in a binary form.
Abstract Syntax Notation One uses a TLV structure, in which each element has a type, length, and value. The type component is a data type that indicates what kind of information is stored in the element and indicates how the value should be encoded. The length component specifies the number of bytes in the value, and the value is the actual data held by the element.
Examples of ASN.1 elements include:
- null -- null elements do not hold any value. They are generally used as placeholders when an element is required but no value is needed.
- Octet String -- Octet string elements hold a set of zero or more octets (bytes) of data. It can be used for holding string or binary data.
- Boolean -- Boolean elements hold values that represent either "true" or "false".
- Integer -- Integer elements hold values that represent integer values.
- Enumerated -- Enumerated elements hold values that represent integer values where each value has a specific meaning.
- Sequence -- Sequence elements are containers that zero or more other ASN.1 elements in a manner where the order of the elements is significant.
- Set -- Set elements are containers that hold zero or more other ASN.1 elements in a manner where the order of the elements is not significant.
Note that ASN.1 is a general framework for binary encoding, but doesn't actually define how the data should be encoded. There are a number of different kinds of ASN.1 encoding rules:
- Basic Encoding Rules (BER)
- Distinguished Encoding Rules (DER)
- Canonical Encoding Rules (CER)
- Packed Encoding Rules (PER)
The book ASN.1 Complete (PDF) by Professor John Larmouth, which is an excellent reference on the Abstract Syntax Notation One.