Expand description
COSE key parsing and signature verification (ES256 / ES384 / RS256 /
EdDSA) via ring, plus base64url helpers and CSPRNG challenge
generation.
§Security
- All cryptographic primitives come from
ring(constant-time ECDSA/RSA/Ed25519 verification). This crate contains no hand-rolled cryptography; the only custom encoding is RFC 5280 DER wrapping of already-validated RSA modulus/exponent byte strings, which never touches secret material. - Signature verification is constant-result: on failure the payload and signature are discarded and only an error variant is returned.
Enums§
- Cose
Public Key - Parsed COSE public key (EC2, RSA, or OKP).
Constants§
- COSE_
ALG_ EDDSA - COSE algorithm: EdDSA (Ed25519).
- COSE_
ALG_ ES256 - COSE algorithm: ECDSA w/ SHA-256 on P-256.
- COSE_
ALG_ ES384 - COSE algorithm: ECDSA w/ SHA-384 on P-384.
- COSE_
ALG_ RS256 - COSE algorithm: RSASSA-PKCS1-v1_5 w/ SHA-256.
- COSE_
CRV_ ED25519 - COSE curve identifier: Ed25519 (RFC 8032 / RFC 9053).
- COSE_
CRV_ P384 - COSE curve identifier: NIST P-384 (secp384r1).
- COSE_
KTY_ EC2 - COSE key type: Elliptic-Curve key pair with x/y coordinates.
- COSE_
KTY_ OKP - COSE key type: Octet Key Pair (Ed25519).
- COSE_
KTY_ RSA - COSE key type: RSA key.
Functions§
- alg_
to_ name - Convert a COSE algorithm ID to a human-readable name.
- base64_
decode_ urlsafe - Base64url decode (RFC 4648 §5, no padding required; standard alphabet with padding is also accepted by the engine’s forgiving handling).
- base64_
encode_ urlsafe - Base64url encode (RFC 4648 §5, no padding), as required by the
WebAuthnJSON serialization conventions. - cbor_
bytes - Extract a CBOR byte string from a value.
- cbor_
map_ entries - Parse a CBOR map into ordered
(i64, Value)entries. - generate_
challenge_ bytes - Generate 32 random bytes (256 bits of entropy) for a
WebAuthnchallenge. - parse_
cose_ key - Parse a COSE key from its CBOR encoding (RFC 9052).
- verify_
cose_ signature - Verify a COSE signature using the parsed public key.