Function hacl_sys::EverCrypt_AEAD_decrypt
source · pub unsafe extern "C" fn EverCrypt_AEAD_decrypt(
s: *mut EverCrypt_AEAD_state_s,
iv: *mut u8,
iv_len: u32,
ad: *mut u8,
ad_len: u32,
cipher: *mut u8,
cipher_len: u32,
tag: *mut u8,
dst: *mut u8
) -> EverCrypt_Error_error_code
Expand description
Verify the authenticity of ad
|| cipher
and decrypt cipher
into dst
.
@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 cipher Pointer to cipher_len
bytes of memory where the ciphertext is read from.
@param cipher_len Length of the ciphertext.
@param tag Pointer to TAG_LEN
bytes of memory where the tag is read from.
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)
@param dst Pointer to cipher_len
bytes of memory where the decrypted plaintext will be written to.
@return EverCrypt_AEAD_decrypt
returns …
EverCrypt_Error_Success
… on success and either of …
EverCrypt_Error_InvalidKey
(returned if and only if the s
parameter is NULL
),
EverCrypt_Error_InvalidIVLength
(see note about requirements on IV size above), or
EverCrypt_Error_AuthenticationFailure
(in case the ciphertext could not be authenticated, e.g., due to modifications)
… on failure (EverCrypt_error.h
).
Upon success, the plaintext will be written into dst
.