Home › Playgrounds › ASN.1 tree

ASN.1 tree

Any DER value, not only a certificate. Paste PEM, hexadecimal or base64; every node shows its tag, its content length and its absolute offset in your input.

The switch is the point

DER is a canonical subset of BER: for any value there is exactly one encoding. Accept BER turns that off, and the difference is worth seeing on real bytes. Try 30 80 02 01 00 00 00 — a SEQUENCE with an indefinite length, terminated by an end-of-contents marker. Strict DER refuses it with PKI_ASN1_INDEFINITE_LENGTH_FORBIDDEN; tick the box and BER reads it, reporting what it tolerated as a diagnostic. Same input, two policies, and the caller chooses which.

Two more the switch changes: a non-minimal length — 30 81 03 02 01 00, where 81 03 spends two octets saying what one could say, refused as PKI_ASN1_LENGTH_NON_MINIMAL — and a constructed OCTET STRING, 24 06 04 01 41 04 01 42, refused as PKI_ASN1_CONSTRUCTED_STRING_FORBIDDEN. Each names its clause of X.690.

What this page will not refuse is as instructive. Paste 01 01 01 — a BOOLEAN whose content octet is neither 0x00 nor 0xFF — and the tree accepts it under both policies. That is not a gap: decodeAsn1 decides structure, and the rule that DER's TRUE is exactly 0xFF belongs to readBoolean, which fires when something reads the value as a boolean. The layering is the point — a decoder that enforced every type's value rules would have to know every schema, and pkinative's does not. The certificate inspector is where those rules run.

Object identifiers, resolved

Every OBJECT IDENTIFIER node is decoded to dotted notation and, when the registry knows it, given its name. That resolution is a deliberate composition rather than a feature of the parser: the certificate layer never imports the name registry, so a caller that only parses never pays for its bytes, and a caller that wants names asks for them. This page asks.

Offsets are real

The offset on every node is its position in the bytes you pasted, and the length is the content length excluding the header. That is what makes the tree usable next to a hex editor, and it is the same arithmetic conformance level L2 uses to prove that tbsCertificate and signatureValue start and end where an independently written walker says they do.