Skip to main content

encrypt_cose0

Function encrypt_cose0 

Source
pub(crate) fn encrypt_cose0(
    algorithm: CoseContentEncryptionAlgorithm,
    builder: CoseEncrypt0Builder,
    protected_header: Header,
    plaintext: &[u8],
    cek: &[u8],
) -> Result<CoseEncrypt0, CryptoError>
Expand description

Encrypts plaintext into a single-recipient COSE [CoseEncrypt0] message, dispatching to the CoseEncryptCipher selected by algorithm.

As with encrypt_cose, the cipher declares its algorithm in the (authenticated) protected header so decrypt_cose0 can recover it. cek is the content-encryption key and must match the selected cipher’s key length. Padding is applied for ContentFormat::Utf8 content.