Skip to content
ecdsa.com

DER (Distinguished Encoding Rules)

The canonical binary encoding of ASN.1 from ITU-T X.690 that gives every value exactly one byte representation, which is why certificates, CSRs, CRLs, keys and many signatures are DER-encoded.
Also written asDistinguished Encoding RulesDER encodingBERX.690

Every value is tag–length–value: a tag byte (0x30 SEQUENCE, 0x02 INTEGER, 0x03 BIT STRING, 0x04 OCTET STRING, 0x05 NULL, 0x06 OBJECT IDENTIFIER, 0x0C UTF8String, 0x17 UTCTime), a length (one byte below 128, otherwise 0x81/0x82… followed by the length bytes) and the contents. DER is a restricted form of BER: definite lengths only, minimal length and integer encodings, 0xFF for TRUE, sorted SET OF elements.

Canonical encoding matters because signatures cover exact bytes: a certificate's tbsCertificate must re-encode identically for the signature to verify. Lenient parsers that accept BER where DER is required have caused signature malleability (Bitcoin's BIP 66) and verification bypasses in several libraries.

DER integers are signed, so a positive value whose top bit is set gets a leading 0x00; that is why ECDSA DER signatures vary between 70 and 72 bytes for P-256. PEM is simply base64 of DER with header lines. The ASN.1 explorer decodes any DER structure locally.

Standards and references

All terms