Skip to main content

ccm_encrypt

Function ccm_encrypt 

Source
pub fn ccm_encrypt(
    aes: &Aes,
    m: usize,
    l: usize,
    nonce: &[u8],
    aad: &[u8],
    plaintext: &[u8],
) -> Option<(Vec<u8>, Vec<u8>)>
Expand description

AES-CCM encrypt with the generic (M, L) parameters.

nonce.len() must be exactly 15 - L. plaintext.len() must fit in 2^(8*L) bytes (no overflow check is enforced for L >= 8 since usize is bounded). AAD must currently be < 2^16 - 2^8 bytes (the canonical 2-byte length encoding).

Returns (ciphertext, tag) where ciphertext.len() == plaintext.len() and tag.len() == M.