Documentation
¶
Overview ¶
Package cbor encodes and decodes the CBOR subset used by Managed Device Attestation objects.
Design ¶
The decoder accepts definite-length values with text map keys and bounds size and nesting. Tags, floating-point values, indefinite lengths, duplicate keys and trailing data are rejected. Attestation parsing selects the required format and certificate-chain members from the decoded map.
Marshal emits the same subset with deterministic map ordering from RFC 8949. This bounded format supports the attestation parser, simulator and tests; it is not a general CBOR implementation or a WebAuthn ceremony implementation.
References ¶
- Decision record 0032: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0032-managed-device-attestation.md
- RFC 8949 (Concise Binary Object Representation): https://www.rfc-editor.org/rfc/rfc8949
- W3C WebAuthn attestation objects: https://www.w3.org/TR/webauthn-2/#sctn-attestation
- Apple: https://developer.apple.com/documentation/devicemanagement/acmecertificate
- Schema: third_party/device-management/mdm/profiles/com.apple.security.acme.yaml
Index ¶
Constants ¶
const ( // MaxBytes is the largest input Unmarshal and Wellformed accept. MaxBytes = 1 << 20 // MaxDepth is the deepest nesting of arrays and maps accepted. MaxDepth = 16 )
Limits applied to every decode.
Variables ¶
var ( ErrTooLarge = errors.New("cbor: input too large") ErrSyntax = errors.New("cbor: malformed input") ErrUnsupported = errors.New("cbor: item outside the supported subset") ErrTrailing = errors.New("cbor: trailing data") ErrType = errors.New("cbor: cannot decode into target") ErrDuplicate = errors.New("cbor: duplicate map key") ErrDepth = errors.New("cbor: nesting too deep") ErrTarget = errors.New("cbor: target must be a non-nil pointer") )
Decoding and encoding errors.
Functions ¶
func Marshal ¶
Marshal encodes v into the supported subset. Map and struct keys are written in the deterministic order of RFC 8949 section 4.2.1: by the bytes of the encoded key, which for text keys sorts shorter before longer and then bytewise. A RawMessage is copied verbatim after a well-formedness check, so a value that came from Unmarshal round-trips unchanged.
func Unmarshal ¶
Unmarshal decodes exactly one item from data into v, which must be a non-nil pointer. Input larger than MaxBytes, anything outside the subset described on the package, and any bytes after the item are errors.
func Wellformed ¶
Wellformed reports whether data is exactly one item of the supported subset with nothing after it. It walks the whole input without decoding into a target, so a caller can reject a hostile body before spending anything on it.
Types ¶
type RawMessage ¶
type RawMessage []byte
RawMessage is an encoded item kept verbatim. Decoding into one copies the bytes of exactly one item, which lets a caller defer interpretation (an attestation statement is read only once its format name is known) and lets a server persist what it received byte for byte.