Function esp_idf_hal::sys::psa_hash_finish
source ยท pub unsafe extern "C" fn psa_hash_finish(
operation: *mut psa_hash_operation_s,
hash: *mut u8,
hash_size: usize,
hash_length: *mut usize,
) -> i32
Expand description
Finish the calculation of the hash of a message.
The application must call psa_hash_setup() before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to psa_hash_update().
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_hash_abort().
\warning Applications should not call this function if they expect a specific value for the hash. Call psa_hash_verify() instead. Beware that comparing integrity or authenticity data such as hash values with a function such as \c memcmp is risky because the time taken by the comparison may leak information about the hashed data which could allow an attacker to guess a valid hash and thereby bypass security controls.
\param[in,out] operation Active hash operation. \param[out] hash Buffer where the hash is to be written. \param hash_size Size of the \p hash buffer in bytes. \param[out] hash_length On success, the number of bytes that make up the hash value. This is always #PSA_HASH_LENGTH(\c alg) where \c alg is the hash algorithm that is calculated.
\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_BUFFER_TOO_SMALL The size of the \p hash buffer is too small. You can determine a sufficient buffer size by calling #PSA_HASH_LENGTH(\c alg) where \c alg is the hash algorithm that is calculated. \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_BAD_STATE The operation state is not valid (it must be active), 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.