Function esp_idf_hal::sys::psa_aead_finish
source ยท pub unsafe extern "C" fn psa_aead_finish(
operation: *mut psa_aead_operation_s,
ciphertext: *mut u8,
ciphertext_size: usize,
ciphertext_length: *mut usize,
tag: *mut u8,
tag_size: usize,
tag_length: *mut usize,
) -> i32
Expand description
Finish encrypting a message in an AEAD operation.
The operation must have been set up with psa_aead_encrypt_setup().
This function finishes the authentication of the additional data formed by concatenating the inputs passed to preceding calls to psa_aead_update_ad() with the plaintext formed by concatenating the inputs passed to preceding calls to psa_aead_update().
This function has two output buffers:
- \p ciphertext contains trailing ciphertext that was buffered from preceding calls to psa_aead_update().
- \p tag contains the authentication tag.
When this function returns successfully, the operation becomes inactive. If this function returns an error status, the operation enters an error state and must be aborted by calling psa_aead_abort().
\param[in,out] operation Active AEAD operation. \param[out] ciphertext Buffer where the last part of the ciphertext is to be written. \param ciphertext_size Size of the \p ciphertext buffer in bytes. This must be appropriate for the selected algorithm and key: - A sufficient output size is #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type, \c alg) where \c key_type is the type of key and \c alg is the algorithm that were used to set up the operation. - #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE evaluates to the maximum output size of any supported AEAD algorithm. \param[out] ciphertext_length On success, the number of bytes of returned ciphertext. \param[out] tag Buffer where the authentication tag is to be written. \param tag_size Size of the \p tag buffer in bytes. This must be appropriate for the selected algorithm and key: - The exact tag size is #PSA_AEAD_TAG_LENGTH(\c key_type, \c key_bits, \c alg) where \c key_type and \c key_bits are the type and bit-size of the key, and \c alg is the algorithm that were used in the call to psa_aead_encrypt_setup(). - #PSA_AEAD_TAG_MAX_SIZE evaluates to the maximum tag size of any supported AEAD algorithm. \param[out] tag_length On success, the number of bytes that make up the returned tag.
\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_BUFFER_TOO_SMALL The size of the \p ciphertext or \p tag buffer is too small. #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type, \c alg) or #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE can be used to determine the required \p ciphertext buffer size. #PSA_AEAD_TAG_LENGTH(\c key_type, \c key_bits, \c alg) or #PSA_AEAD_TAG_MAX_SIZE can be used to determine the required \p tag buffer size. \retval #PSA_ERROR_INVALID_ARGUMENT The total length of input to psa_aead_update_ad() so far is less than the additional data length that was previously specified with psa_aead_set_lengths(), or the total length of input to psa_aead_update() so far is less than the plaintext length that was previously specified with psa_aead_set_lengths(). \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription \retval #PSA_ERROR_HARDWARE_FAILURE \emptydescription \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription \retval #PSA_ERROR_BAD_STATE The operation state is not valid (it must be an active encryption operation with a nonce set), or the library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.