Expand description
COSE key parsing and signature verification (ES256 / RS256) via ring,
plus base64url helpers and CSPRNG challenge generation.
§Security
- All cryptographic primitives come from
ring(constant-time ECDSA/RSA 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 or RSA).
Constants§
- COSE_
ALG_ ES256 - COSE algorithm: ECDSA w/ SHA-256 on P-256.
- COSE_
ALG_ RS256 - COSE algorithm: RSASSA-PKCS1-v1_5 w/ SHA-256.
- COSE_
KTY_ EC2 - COSE key type: Elliptic-Curve key pair with x/y coordinates.
- COSE_
KTY_ OKP - COSE key type: Octet Key Pair (Ed25519 et al.). Not supported.
- 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.