K096 / Encoding and decoding
CBOR
CBOR (Concise Binary Object Representation) is a binary serialization format standardized in RFC 8949.
CRYPTOGRAPHY LAB / K096
Cryptography Lab · CBOR
Run real computations and inspect intermediate states step by step.
Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.
CBOR (JSON subset, small integers)
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- CBOR (Concise Binary Object Representation) is a binary serialization format standardized in RFC 8949. Source document ↗
- Classification and reversibility
- Binary serialization/encoding, not encryption or hashing; encoded data can be decoded. Source document ↗
- Key or secret requirements
- Ordinary encoding/decoding APIs require no key or secret. Source document ↗
- Operating principle and structure
- Each item has a head and optional content; the first byte's top three bits identify the major type. Source document ↗
- Key size, block size and parameters
- Not confirmed in the survey
- Security strength and recommendation
- No cryptographic strength rating; some implementations offer decoder limits against malicious input. Source document ↗
- Known attacks and vulnerabilities
- cbor2 has a known service-crash vulnerability when parsing long objects (CVE-2024-26134). Source document ↗
- Standards and certification
- IETF STD 94 (RFC 8949) Internet Standard. Source document ↗
- Typical uses
- WebAuthn, IoT and systems needing compact self-describing messages. Source document ↗
- Implementations, libraries and tools
- Libraries such as cbor2 support serialization/deserialization. Source document ↗
- Decryption or decoding
- cbor2 loads/load decodes bytes into the original object. Source document ↗
- Advantages
- Unlike JSON, supports binary data and dates directly. Source document ↗
- Limitations and cautions
- CBOR map keys may be any CBOR type, not just strings; beware interoperability. Source document ↗
- Distinguishing encryption, encoding and hashing
- Binary serialization, not encryption or hashing; do not use for confidentiality. Source document ↗
Practical examples
Example
Encode an application object into CBOR bytes and decode using the same schema at the receiver. Binary data and dates are easy to handle; convert to JSON when needed for inspection.
Procedure
Define data and encode to bytes. Decode within trust boundaries and size limits. If confidentiality/integrity is needed, apply separate encryption/signatures after encoding; distinguish decoding from decryption.
Scenario
Use CBOR for compact self-describing binary messages in WebAuthn or IoT and internal APIs; convert to JSON for readable logs, debugging and external integrations.
Pitfalls and alternatives
CBOR provides neither confidentiality nor integrity; use TLS, signatures or encryption separately. For untrusted input use length, nesting and duplicate-key limits; verify map key types, tags and noncanonical encodings when interoperating with JSON.