pub unsafe extern "C" fn EverCrypt_AEAD_encrypt(
s: *mut EverCrypt_AEAD_state_s,
iv: *mut u8,
iv_len: u32,
ad: *mut u8,
ad_len: u32,
plain: *mut u8,
plain_len: u32,
cipher: *mut u8,
tag: *mut u8,
) -> EverCrypt_Error_error_code
Expand description
Encrypt and authenticate a message (plain
) with associated data (ad
).
@param s Pointer to the The AEAD state created by EverCrypt_AEAD_create_in
. It already contains the encryption key.
@param iv Pointer to iv_len
bytes of memory where the nonce is read from.
@param iv_len Length of the nonce. Note: ChaCha20Poly1305 requires a 12 byte nonce.
@param ad Pointer to ad_len
bytes of memory where the associated data is read from.
@param ad_len Length of the associated data.
@param plain Pointer to plain_len
bytes of memory where the to-be-encrypted plaintext is read from.
@param plain_len Length of the to-be-encrypted plaintext.
@param cipher Pointer to plain_len
bytes of memory where the ciphertext is written to.
@param tag Pointer to TAG_LEN
bytes of memory where the tag is written to.
The length of the tag
must be of a suitable length for the chosen algorithm:
Spec_Agile_AEAD_AES128_GCM
(TAG_LEN=16)
Spec_Agile_AEAD_AES256_GCM
(TAG_LEN=16)
Spec_Agile_AEAD_CHACHA20_POLY1305
(TAG_LEN=16)
@return EverCrypt_AEAD_encrypt
may return either EverCrypt_Error_Success
or EverCrypt_Error_InvalidKey
(EverCrypt_error.h
). The latter is returned if and only if the s
parameter is NULL
.