esp_aes_gcm_update() function
This function feeds an input buffer into an ongoing GCM encryption or decryption operation. You may call this function zero, one or more times to pass successive parts of the input: the plaintext to encrypt, or the ciphertext (not including the tag) to decrypt. After the last part of the input, call mbedtls_gcm_finish(). This function may produce output in one of the following ways: - Immediate output: the output length is always equal to the input length. - Buffered output: the output consists of a whole number of 16-byte blocks. If the total input length so far (not including associated data) is 16 \* *B* + *A* with *A* < 16 then the total output length is 16 \* *B*. In particular: - It is always correct to call this function with \p output_size >= \p input_length + 15. - If \p input_length is a multiple of 16 for all the calls to this function during an operation, then it is correct to use \p output_size = \p input_length.
Arguments
ctx
The GCM context. This must be initialized.
input
The buffer holding the input data. If \p input_length is greater than zero, this must be a readable buffer of at least \p input_length bytes.
input_length
The length of the input data in bytes.
output
The buffer for the output data. If \p output_size is greater than zero, this must be a writable buffer of of at least \p output_size bytes.
output_size
The size of the output buffer in bytes. See the function description regarding the output size.
output_length
On success, \p *output_length contains the actual length of the output written in \p output. On failure, the content of \p *output_length is unspecified.
Return value
\c 0 on success. #MBEDTLS_ERR_GCM_BAD_INPUT on failure: total input length too long, unsupported input/output buffer overlap detected, or \p output_size too small.
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.
esp_aes_gcm_update() is called by 3 functions and calls 6 functions:
![]()
esp_aes_gcm_update()
esp_aes_gcm_update() reads 14 variables and writes 2 variables:
![]()
esp_aes_gcm_update()