mbedtls_ccm_update() function
This function feeds an input buffer into an ongoing CCM 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_ccm_finish(). The lengths \p input_len of the data parts should eventually add up exactly to the plaintext length \c plaintext_len passed to mbedtls_ccm_set_lengths(). 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: except for the last part of input data, 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*. For the last part of input data, the output length is equal to the input length plus the number of bytes (*A*) buffered in the previous call to the function (if any). The function uses the plaintext length \c plaintext_len passed to mbedtls_ccm_set_lengths() to detect the last part of input data. In particular: - It is always correct to call this function with \p output_size >= \p input_len + 15. - If \p input_len is a multiple of 16 for all the calls to this function during an operation (not necessary for the last one) then it is correct to use \p output_size =\p input_len.
Arguments
ctx
The CCM context. This must have been started with mbedtls_ccm_starts() and the lengths of the message and additional data must have been declared with mbedtls_ccm_set_lengths().
input
The buffer holding the input data. If \p input_len is greater than zero, this must be a readable buffer of at least \p input_len bytes.
input_len
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 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_len
On success, \p *output_len contains the actual length of the output written in \p output. On failure, the content of \p *output_len is unspecified.
Return value
\c 0 on success. #MBEDTLS_ERR_CCM_BAD_INPUT on failure: \p ctx is in an invalid state, total input length too long, or \p output_size too small.
Notes
This function is not implemented in Mbed TLS yet.
mbedtls_ccm_update() is called by 3 functions and calls 4 functions:
![]()
mbedtls_ccm_update()
mbedtls_ccm_update() reads 8 variables and writes 2 variables:
![]()
mbedtls_ccm_update()