opyeb asn1lab

asn1lab · Reference

OIDs and tag numbers, decoded

OID hierarchy, base-128 encoding, common OIDs, Universal tags

An OID (Object Identifier) is a numeric path that names something without collisions. 1.2.840.113549.1.1.11 reads iso (1) → org (2) → US (840) → RSA (113549) → pkcs-1 (1) → 1 → sha256WithRSAEncryption. Each number is a child index under the previous node.

How an OID becomes bytes

  1. The first two numbers X and Y share one byte, 40 × X + Y. 1.2 becomes 42 and 2.5 becomes 85.
  2. Every later number is written base-128: seven bits per byte, with the top bit set while more bytes follow.
  3. Wrap the resulting bytes in tag 0x06 and a length.

So 1.2.840.113549.1.1.11 is 06 09 2A 86 48 86 F7 0D 01 01 0B. 840 is 0x86 0x48, and 113549 is 0x86 0xF7 0x0D.

OIDs you meet in certificates

OIDNameUse
1.2.840.113549.1.1.11sha256WithRSAEncryptionRSA signature algorithm
1.2.840.10045.4.3.2ecdsa-with-SHA256ECDSA signature algorithm
1.2.840.10045.2.1id-ecPublicKeyEC public key
1.2.840.113549.1.1.1rsaEncryptionRSA key
2.5.4.3CNname attribute
2.5.4.10Oname attribute
2.5.29.17subjectAltNamedomain and IP list
2.5.29.19basicConstraintsCA or not
2.5.29.15keyUsagekey purpose bits
2.5.29.37extKeyUsagepurpose OID list
1.3.6.1.5.5.7.3.1serverAuthTLS server purpose
1.3.101.112id-Ed25519Ed25519 key and signature

Universal tag numbers

TagNameNote
0x01BOOLEANtrue is 0xFF in DER
0x02INTEGERtwo's complement, minimal length
0x03BIT STRINGfirst byte counts unused bits
0x04OCTET STRINGarbitrary bytes, may contain DER
0x05NULLzero length
0x06OBJECT IDENTIFIERnumeric hierarchy
0x0CUTF8StringUTF-8 text
0x13PrintableStringrestricted ASCII
0x16IA5StringASCII, used for e-mail and DNS
0x17UTCTimeYYMMDDHHMMSSZ
0x18GeneralizedTimeYYYYMMDDHHMMSSZ
0x30SEQUENCEordered children
0x31SETunordered children

Class and constructed bits

High tag numbers

When the tag number is 31 or more, the low five bits are 11111 and the number follows in base-128. Tag 32 is 1F 20. Certificates rarely use it, but CMS and LDAP structures do.

The dictionary holds only common values. An unknown OID still appears as a dotted number in the tree, and you can match it against the tables above.

Questions

Why are OIDs numbers?

Names vary by language and can collide. A numeric path is administered by registration authorities, so it stays unique worldwide.

Can the first number be greater than 2?

No. The first arc is 0, 1 or 2. An arc of 2 requires the second to be 40 or more, and the first byte is then 80 or above.

How do I trace an OID not in the dictionary?

Search the number in an OID repository (OIDref, oird) or look at the prefix to see which authority defined it. For certificate extensions, read RFC 5280 and the extension's own document.

Press an OID node and watch how the number and name connect.

Open the tool

This guide follows ITU-T X.690 (DER/BER), RFC 5280 (X.509), RFC 5208 (PKCS#8), RFC 5480 (EC public keys), RFC 5915 (EC private keys) and RFC 3279 (ECDSA signatures). Every example is synthetic.