Function esp_idf_svc::sys::mbedtls_ccm_update

source ยท
pub unsafe extern "C" fn mbedtls_ccm_update(
    ctx: *mut mbedtls_ccm_context,
    input: *const u8,
    input_len: usize,
    output: *mut u8,
    output_size: usize,
    output_len: *mut usize,
) -> i32
Expand description

\brief 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.

\note This function is not implemented in Mbed TLS yet.

\param 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(). \param 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. \param input_len The length of the input data in bytes. \param 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. \param output_size The size of the output buffer in bytes. See the function description regarding the output size. \param 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 \c 0 on success. \return #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.