Provided features¶
The library implements COSE (CBOR Object Signing and Encryption) as defined in RFC 9052 and RFC 9053: the COSE key types, the signature, MAC, content encryption and key management algorithms, the cryptographic structures a signature, a MAC or an encryption is computed over, and the header rules that decide what a message says.
The six COSE message types themselves come from
spomky-labs/cbor-php 3.4.0 or later, as CBOR\Tag\CoseSign1Tag
and its siblings; this library owns what RFC 9052 reads into them.
What it implements¶
| Specification | What the library does with it |
|---|---|
| RFC 9052 | Structures and process: the Sig_structure, MAC_structure and Enc_structure, the header rules, external_aad, detached content |
| RFC 9053 | Initial algorithms: signatures, HMAC, AES-CBC-MAC, the AEAD content encryption algorithms, the key management algorithms (direct, HKDF, AES Key Wrap, ECDH) and the key types |
| RFC 8230 | RSASSA-PSS (PS256, PS384, PS512) and the RSA key type |
| RFC 8812 | RSASSA-PKCS1-v1_5 (RS256, RS384, RS512, RS1) and ECDSA with secp256k1 (ES256K) |
| RFC 9864 | Fully-specified algorithm identifiers |
| RFC 9596 | The typ (type) header parameter |
| RFC 9597 | CWT Claims in COSE headers |
| RFC 9054 | The hash algorithms, as a registry of their own |
| RFC 9679 | The COSE Key Thumbprint |
| RFC 9360 | The header parameters carrying and referencing X.509 certificates |
| RFC 9995 | The hash envelope |
| RFC 9338 | Countersignatures, version 2, labels 11 and 12 |
| RFC 9964 | ML-DSA for JOSE and COSE: ML-DSA-44/65/87 and the AKP key type |
| RFC 9942 | Receipts: the receipts, vds and vdp header parameters and the RFC9162_SHA256 verifiable data structure |
| RFC 9921 | RFC 3161 timestamp tokens, carried and bound to the message, not validated |
Where to start¶
- Producing or checking a signed message —
Signing and verifying, then
What the application must check before you rely on a
verification that returned
true. - Reading a message someone handed you — Messages, structures and headers, and Reading headers for the rules RFC 9052 puts on a header map.
- Encrypting — Encryption for the message, and Key management for how a recipient gets the content encryption key.
- Handling keys — Keys, and
Key restrictions for the
algandkey_opsrules the library enforces. - Choosing an identifier — Algorithms lists every one the library ships with its RFC reference.
- Verifying a CBOR Web Token — CBOR Web Tokens.
What it leaves to the application¶
The library computes and checks cryptography over the structures the RFCs define. Several decisions are not cryptographic, and it does not make them for you:
- Which algorithm is acceptable for a given message. A verification confirms the signature made by the algorithm the message names; deciding that the algorithm was allowed to sign it is a separate step. See What the application must check.
- Whether a certificate is trusted. The X.509 header parameters are read and the certificate they carry can be turned into a key, but no chain is built or validated and no network call is made. See X.509 header parameters.
- Whether a claim is acceptable. A CWT is verified as a COSE message; the claims inside it are yours to check. See CBOR Web Tokens.
- Whether a timestamp token or a receipt comes from an authority you trust. The binding between the token and the message is checked; the trust in the issuer is not. See Timestamp tokens and Receipts.
Each of those pages ends with a section saying where the library stops.
References¶
- RFC 9052 — CBOR Object Signing and Encryption (COSE): Structures and Process
- RFC 9053 — CBOR Object Signing and Encryption (COSE): Initial Algorithms
- RFC 8230 — Using RSA Algorithms with COSE Messages
- RFC 8812 — COSE and JOSE Registrations for WebAuthn Algorithms
- RFC 9864 — Fully-Specified Algorithms for JOSE and COSE
- RFC 9596 — COSE "typ" (type) Header Parameter
- RFC 9597 — CBOR Web Token (CWT) Claims in COSE Headers
- RFC 9054 — COSE: Hash Algorithms
- RFC 9679 — COSE Key Thumbprint
- RFC 9360 — COSE: Header Parameters for Carrying and Referencing X.509 Certificates
- RFC 9995 — COSE Hash Envelope
- RFC 9338 — COSE: Countersignatures
- RFC 9964 — ML-DSA for JOSE and COSE
- RFC 9881 — Algorithm Identifiers for ML-DSA
- FIPS 204 — Module-Lattice-Based Digital Signature Standard
- RFC 9942 — COSE Receipts
- RFC 9162 — Certificate Transparency Version 2.0
- RFC 9921 — COSE Header Parameter for Timestamp Tokens as Defined in RFC 3161
- RFC 3161 — Internet X.509 PKI Time-Stamp Protocol (TSP)
- RFC 8392 — CBOR Web Token (CWT)
- RFC 3394 — Advanced Encryption Standard (AES) Key Wrap Algorithm
- RFC 5869 — HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
- RFC 7748 — Elliptic Curves for Security
- IANA COSE registry: the algorithm, key type and curve registries every identifier of this library is checked against