blank.gif (43 bytes)

Church Of The
Swimming Elephant

ASN.1 Connected: An Internet Encyclopedia

Up: Connected: An Internet Encyclopedia
Up: Topics
Up: Concepts
Up: Protocol
Prev: ASCII Request/Reply Protocols
Next: Protocol Layering


ASN.1 Abstract Syntax Notation 1 (ASN.1), heavily used by OSI and OSI-inspired protocols, including X.500, H.323, SNMP and LDAP, defines a standard grammer used to write textual descriptions of messages. One of several encoding rules are then used to construct the actual binary messages. ISO Standard X.680 defines the ASN.1 grammer. Basic Encoding Rules (BER), Canonical Encoding Rules (CER), and Distinguished Encoding Rules (DER), are specified in ISO Standard X.690. Packed Encoding Rules (PER) are specified in ISO Standard X.691. These documents, like other ITU standards, can be purchased online at

For example, here's a sample ASN.1 definition from the LDAP protocol, using the ASN.1 primitive OCTET STRING, and the constructor SEQUENCE. The placement of ::= symbols, comments, and braces are all defined by the ASN.1 grammer.

        LDAPString ::= OCTET STRING

        AttributeDescription ::= LDAPString

        AttributeValueAssertion ::= SEQUENCE {
                attributeDesc   AttributeDescription,
                assertionValue  AssertionValue }

        AssertionValue ::= OCTET STRING

RFC 2251, the LDAP standard, specifies that BER should be used to encode the ASN.1 structures used in LDAP. So, let's encode this AttributeValueAssertion:

{attributeDesc "cn", assertationValue ""}

We follow the BER rules. A SEQUENCE is encoded with a tag byte of 30H, followed by the length of the SEQUENCE, followed by each of the component parts. An OCTET STRING is encoded with a tag byte of 05H, followed by the length of the string, followed by its value. Lengths less than 128 bytes can be encoded directly in one byte, so the final BER encoding is:

One of the advantages of ASN.1 is that, due to its well-defined syntax, automated tools can be constructed to compile ASN.1 definitions into subroutines that can encode and decode ASN.1 messages, simplifying the design of programs implementing ASN.1-based protocols. One of ASN.1's perceived disadvantages is the relative inefficiency of its encodings, and the additional computational overhead required to convert back and forth from them.

Next: Protocol Layering

Connected: An Internet Encyclopedia


Protect yourself from cyberstalkers, identity thieves, and those who would snoop on you.
Stop spam from invading your inbox without losing the mail you want. We give you more control over your e-mail than any other service.
Block popups, ads, and malicious scripts while you surf the net through our anonymous proxies.
Participate in Usenet, host your web files, easily send anonymous messages, and more, much more.
All private, all encrypted, all secure, all in an easy to use service, and all for only $5.95 a month!

Service Details

Have you gone to church today?
All pages ©1999, 2000, 2001, 2002, 2003 Church of the Swimming Elephant unless otherwise stated
Church of the Swimming Elephant©1999, 2000, 2001, 2002, 2003 is a wholly owned subsidiary of Packetderm, LLC.

Packetderm, LLC
210 Park Ave #308
Worcester, MA 01609