pub fn verify_corim_signature(signature: &[u8], document: &[u8]) -> Result<()>Expand description
Cryptographically verify a detached COSE_Sign1 CoRIM signature against the document it endorses.
The issuer X.509 certificate is taken from the envelope’s protected
header per RFC 9360: x5chain (key 33) is preferred, with x5bag
(key 32) as a fallback. For a chain or bag, the end-entity (leaf)
certificate is used.
Enforces:
- The envelope decodes as a CoRIM-spec-compliant
#6.18(COSE_Sign1)via [decode_signed_corim]. - The payload is nil (detached form).
- The COSE signature bytes are non-empty.
- If the protected header carries a
content-type(key 3), it equals"application/rim+cbor". - The protected header carries an
x5chainorx5bagentry. - The protected-header algorithm is supported (see below).
- The end-entity certificate parses as DER X.509 and exposes an RSA public key.
- The signature math verifies via
pss_verifyover the COSESig_structure1TBS bytes built from the envelope’s protected header, the supplieddocument, and empty external AAD.
§Supported algorithms
Only PS384 is currently accepted: RSA-PSS with SHA-384,
MGF1-SHA-384, and a salt length equal to the hash output size
(48 bytes), per RFC 8230 section 2 (COSE alg ID -38).
All other algorithms (RSA PKCS#1 v1.5, ECDSA, EdDSA, other PSS
variants) are rejected with a targeted error – adding support
would require extending the crypto crate with the corresponding
primitives or COSE alg-ID mappings here.
§Arguments
signature- Detached COSE_Sign1 CoRIM envelope (nil payload).document- The CoRIM document the signature should endorse.