Format:CBOR
| Extensions | .cbor |
|---|---|
| Endianness | big-endian |
| Website | https://www.rfc-editor.org/rfc/rfc8949 |
| On this wiki | Facts · Code · Notes · Topics |
RFC 8949 Concise Binary Object Representation: each item starts with a byte whose top 3 bits are the major type (0-7) and low 5 bits the argument; big-endian; optional self-describe tag 0xd9d9f7.
Initial byte
Major type = byte >> 5, additional info = byte & 0x1f. Info 0-23 is the value/length itself; 24, 25, 26, 27 mean a following 1, 2, 4, 8 byte big-endian argument; 31 means indefinite length (arrays, maps, strings terminated by a 0xff break). Major types: 0 unsigned int (0x00-0x1b); 1 negative int (-1-n, 0x20-0x3b); 2 byte string (0x40-0x5b, indefinite 0x5f); 3 UTF-8 text string (0x60-0x7b, 0x7f); 4 array (0x80-0x9b, 0x9f); 5 map (0xa0-0xbb, 0xbf); 6 tag (0xc0-0xdb); 7 simple/float: 0xf4 false, 0xf5 true, 0xf6 null, 0xf7 undefined, 0xf9 float16, 0xfa float32, 0xfb float64, 0xff break.
Self-described CBOR
Tag 55799 serialized as d9 d9 f7 can start a file as a magic number; it is not a valid start of ordinary JSON or text, so it works as file identification. CBOR is used in COSE/CWT, WebAuthn and CTAP2 (attestation objects), and many IoT protocols.
Sources
RFC 8949 (rfc-editor.org/rfc/rfc8949.txt): tag 55799/0xd9d9f7 and the simple values 0xf4/0xf9 read; the major-type layout from the RFC section 3.