mbedtls_chachapoly_auth_decrypt() function
This function performs a complete ChaCha20-Poly1305 authenticated decryption with the previously-set key.
Arguments
ctx
The ChaCha20-Poly1305 context to use (holds the key).
length
The length (in Bytes) of the data to decrypt.
nonce
The \c 96 Bit (\c 12 bytes) nonce/IV to use.
aad
The buffer containing the additional authenticated data (AAD). This pointer can be \c NULL if `aad_len == 0`.
aad_len
The length (in bytes) of the AAD data to process.
tag
The buffer holding the authentication tag. This must be a readable buffer of length \c 16 Bytes.
input
The buffer containing the data to decrypt. This pointer can be \c NULL if `ilen == 0`.
output
The buffer to where the decrypted data is written. This pointer can be \c NULL if `ilen == 0`.
Return value
\c 0 on success. #MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED if the data was not authentic. Another negative error code on other kinds of failure.
Notes
Before using this function, you must set the key with \c mbedtls_chachapoly_setkey().