An ISO/ITU-T/CCITT standard for transmitting structured data on networks.
Used by SSL Certificates, and many protocols such as SNMP, LDAP, various IBM Protocols, Z39.50, etc.
ASN.1 is a standard for transmitting structured binary data over networks. ASN.1 also is a grammer that can be used to define PDU's to be sent over a network. It's frequently seen as SNMP MIB?s.
ASN.1 is made up of "encoding" of some chunk of data. An encoding is either:
|Identifier Octets|Length Octets|Contents (called the "Definite form")
or
|Identifier Octets|Length Octets|Contents|End of contets octets (called the "Indefinite form")
Definate form is in general used when you know the size of something before hand, indefinate form is used when the size of what you are encoding is unknown.
The Identifier Octets are built up like so: |1|2|3|4|5|6|7|8 ||Class|Constructed|||||Tag
where class is |Value|Class |00b|Universal |01b|Application |10b|Context specific |11b|Private
If constructed is 1, then it means that this is a constructed type, not a primative one.
The tag says which type it is, if the tag is under <=31, then it's value is used directly, otherwise the tag bits above are set to "11111" and then a sequence of octets that represent the number. The 8th bit of each octet is set to 1 to mean "more octets after this one". The low bits are the 7 bits of the tag, MSB first.
"Choice" values encode which choice was taken directly into the tag bits. I don't know why.
In definate encodings, if the 8th bit is 0, then it's a "short" encoding of the length, and the length is the lower 7 bits. If the 8th bit is set, and the lower 7 bits are how many octets are used to encode the length(!). This allows for lengths up to 2**1008. The lower 7 bits being set is reserved for future expansion.
End of contents is encoded as |Type|Length|Value |00|00| Absent
Boolean is encoded as an octet, 0 for false, non-zero for true. Integers are encoded as a sequence of bytes, MSB? first. Sequences are encoded as a series of encodings.
Encodings: |Number|Name |Universal 0|Reserved for encoding rules |Universal 1|Boolean |Universal 2|Integer |Universal 3|Bitstring |Universal 4|Octet String |Universal 5|Null type |Universal 6|Object identifier type |Universal 7|Object descriptor type |Universal 8|External type/Instance of type |Universal 9|Real |Universal 10|Enumerated Type |Universal 11|Embedded PDV (Presentation Data Value) Type |Universal 12-15|Reserved |Universal 16|Sequence/Sequence-of types |Universal 17|Set/Set-of types |Universal 18-22|Charactor String types |Universal 23-24|Time types |Universal 25-30|Charactor String types |Universal 31-..|Reserved