wire / wire-format / asn1-ber
BER encodes each ASN.1 value as a Tag-Length-Value triple: an identifier octet (class + primitive/constructed bit + tag number), a length (definite short/long form, or indefinite with an end-of-contents marker), then the content. BER is the original, flexible TLV scheme; DER is its canonical, deterministic subset.
aka: BER · Basic Encoding Rules · ASN.1 TLV · X.690 BER
spec: ITU-T X.690
BER is the archetypal Tag-Length-Value encoding. Every element is: identifier octet(s) giving tag class (universal/application/context/private) and a primitive-vs-constructed bit and the tag number; length octet(s) in definite (short < 128, or long form: 0x8N then N length bytes) or indefinite form (0x80, terminated by two 0x00 end-of-contents octets); then the content octets.
| field | size | meaning |
|---|---|---|
| Identifier (Tag) | 1+ bytes | Bits 8-7 = class (00 universal, 01 application, 10 context-specific, 11 private); bit 6 = constructed (1) vs primitive (0); bits 5-1 = tag number (0x1F escape => multi-byte tag in base-128). |
| Length | 1+ bytes | Short form: one octet 0x00-0x7F = length. Long form: 0x8N where N (1-126) is the count of following length octets (big-endian). Indefinite form: 0x80, content runs until an end-of-contents (00 00). |
| Contents (Value) | = Length | The value octets; for constructed types these are themselves nested TLV elements. |
example:
02 01 05
INTEGER 5: tag 0x02 (universal, primitive, INTEGER) | length 0x01 (one content byte) | value 0x05.
see: wire-format/asn1-der
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/asn1-ber
or /wire-format/asn1-ber.json