Skip to main content

verify_corim_signature

Function verify_corim_signature 

Source
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:

  1. The envelope decodes as a CoRIM-spec-compliant #6.18(COSE_Sign1) via [decode_signed_corim].
  2. The payload is nil (detached form).
  3. The COSE signature bytes are non-empty.
  4. If the protected header carries a content-type (key 3), it equals "application/rim+cbor".
  5. The protected header carries an x5chain or x5bag entry.
  6. The protected-header algorithm is supported (see below).
  7. The end-entity certificate parses as DER X.509 and exposes an RSA public key.
  8. The signature math verifies via pss_verify over the COSE Sig_structure1 TBS bytes built from the envelope’s protected header, the supplied document, 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.