Skip to main content

decrypt_cose

Function decrypt_cose 

Source
pub(crate) fn decrypt_cose(
    cose_encrypt: &CoseEncrypt,
    default_algorithm: Option<CoseContentEncryptionAlgorithm>,
    cek: &[u8],
) -> Result<Vec<u8>, CryptoError>
Expand description

Authenticates and decrypts a multi-recipient COSE [CoseEncrypt] message, dispatching to the CoseEncryptCipher indicated by the content-encryption algorithm declared in the message’s protected header.

When the protected header omits the content-encryption algorithm (some legacy envelopes), default_algorithm is used instead; pass None to require the header to declare it.

Returns an error if the algorithm cannot be determined or is unsupported, if cek has the wrong length for that cipher, or if authentication fails.