ASN.1: Abstract Syntax Notation 1

Articles and Documentation

Compilers, Syntax Checkers and Other Tools

  • Christian Huitema (June 6, 2006):
    There is indeed a lot of complexity in ASN.1. At the root, ASN.1 is a
    basic T-L-V encoding format, similar to what we see in multiple IETF
    protocols. However, for various reasons, ASN.1 includes a number of
    encoding choices that are as many occasions for programming errors:
    
    * In most TLV applications, the type field is a simple number varying
    from 0 to 254, with the number 255 reserved for extension. In ASN.1, the
    type field is structured as a combination of scope and number, and the
    number itself can be encoded on a variable number of bytes.
    * In most TLV applications, the length field is a simple number. In
    ASN.1, the length field is variable length.
    * In most TLV applications, structures are delineated by the length
    field. In ASN.1, structures can be delineated either by the length field
    or by an "end of structure" mark.
    
    * In most TLV applications, a string is encoded as just a string of
    bytes. In ASN.1, it can be encoded either that way, or as a sequence of
    chunks, which conceivably could themselves be encoded as chunks.
    
    * Most applications tolerate some variations in component ordering and
    deal with optional components, but ASN.1 pushes that to an art form.
    
    * I don't remember exactly how many alphabet sets ASN.1 does support,
    but it is way more than your average application.
    
    * Most applications encode integer values by reference to classic
    computer encodings, e.g. signed/unsigned char, short, long, long-long.
    ASN.1 introduces its own encoding, which is variable length.
    
    * One can argue that SNMP makes a creative use of the "Object
    Identifier" data type of ASN.1, but one also has to wonder why this data
    type is specified in the language in the first place.
    
    

    Then there are MACRO definitions, VALUE specifications, and an even more complex definition of extension capabilities. In short, ASN.1 is vastly more complex that the average TLV encoding. The higher rate of errors is thus not entirely surprising.

    Links


    Internet Technical Notes and Resources

    Last updated by Henning Schulzrinne