mbedtls_gcm_auth_decrypt() function
This function performs a GCM authenticated decryption of a buffer.
Arguments
ctx
The GCM context. This must be initialized.
length
The length of the ciphertext to decrypt, which is also the length of the decrypted plaintext.
iv
The initialization vector. This must be a readable buffer of at least \p iv_len Bytes.
iv_len
The length of the IV.
add
The buffer holding the additional data. This must be of at least that size in Bytes.
add_len
The length of the additional data.
tag
The buffer holding the tag to verify. This must be a readable buffer of at least \p tag_len Bytes.
tag_len
The length of the tag to verify.
input
The buffer holding the ciphertext. If \p length is greater than zero, this must be a readable buffer of at least that size.
output
The buffer for holding the decrypted plaintext. If \p length is greater than zero, this must be a writable buffer of at least that size.
Return value
\c 0 if successful and authenticated. #MBEDTLS_ERR_GCM_AUTH_FAILED if the tag does not match. #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths or pointers are not valid or a cipher-specific error code if the decryption failed.
Notes
For decryption, the output buffer cannot be the same as input buffer. If the buffers overlap, the output buffer must trail at least 8 Bytes behind the input buffer.