Skip to content
ecdsa.com

ASN.1 (Abstract Syntax Notation One)

The ITU-T X.680 language for describing data structures independently of their encoding, used to define X.509 certificates, CMS, PKCS #8 keys, OCSP, LDAP and telecom protocols.
Also written asASN.1Abstract Syntax Notation OneX.680

An ASN.1 module declares types; RFC 5280, for example, defines Certificate as a SEQUENCE of tbsCertificate, signatureAlgorithm (an AlgorithmIdentifier) and signatureValue (a BIT STRING). Building blocks are SEQUENCE, SET, CHOICE, OPTIONAL and DEFAULT fields, context-specific tags ([0], [1]) with IMPLICIT or EXPLICIT tagging, and primitive types such as INTEGER, BIT STRING, OCTET STRING, OBJECT IDENTIFIER and the string and time types.

Encoding rules turn a value into bytes: BER and its canonical subset DER (X.690) for PKI, PER for compact telecom messages, XER and JER for XML and JSON. Most security-relevant ASN.1 is DER.

ASN.1 parsing has a long bug history (length overflows, BER/DER confusion, tag-handling mismatches), so use a maintained parser and never hand-roll one for untrusted input. Reading a dump is a practical debugging skill: openssl asn1parse -i or the ASN.1 explorer show the tree with offsets.

Standards and references

All terms