mbedtls_cipher_auth_decrypt() function
The generic autenticated decryption (AEAD) function.
Syntax
int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx,
const unsigned char *iv,
size_t iv_len,
const unsigned char *ad,
size_t ad_len,
const unsigned char *input,
size_t ilen,
unsigned char *output,
size_t *olen,
const unsigned char *tag,
size_t tag_len );
Arguments
ctx
The generic cipher context. This must be initialized and and bound to a key.
iv
The IV to use, or NONCE_COUNTER for CTR-mode ciphers. This must be a readable buffer of at least \p iv_len Bytes.
iv_len
The IV length for ciphers with variable-size IV. This parameter is discarded by ciphers with fixed-size IV.
ad
The additional data to be authenticated. This must be a readable buffer of at least \p ad_len Bytes.
ad_len
The length of \p ad.
input
The buffer holding the input data. This must be a readable buffer of at least \p ilen Bytes.
ilen
The length of the input data.
output
The buffer for the output data. This must be able to hold at least \p ilen Bytes.
olen
The length of the output data, to be updated with the actual number of Bytes written. This must not be \c NULL.
tag
The buffer holding the authentication tag. This must be a readable buffer of at least \p tag_len Bytes.
tag_len
The length of the authentication tag.
Return value
\c 0 on success. #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on parameter-verification failure. #MBEDTLS_ERR_CIPHER_AUTH_FAILED if data is not authentic. A cipher-specific error code on failure.
Notes
If the data is not authentic, then the output buffer is zeroed out to prevent the unauthentic plaintext being used, making this interface safer.