psa_hash_verify() function
Finish the calculation of the hash of a message and compare it with an expected value. 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(). It then compares the calculated hash with the expected hash passed as a parameter to this function. 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().
Arguments
operation
Active hash operation.
hash
Buffer containing the expected hash value.
hash_length
Size of the \p hash buffer in bytes.
Return value
#PSA_SUCCESS The expected hash is identical to the actual hash of the message. #PSA_ERROR_INVALID_SIGNATURE The hash of the message was calculated successfully, but it differs from the expected hash. #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription #PSA_ERROR_HARDWARE_FAILURE \emptydescription #PSA_ERROR_CORRUPTION_DETECTED \emptydescription #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.
Notes
Implementations shall make the best effort to ensure that the comparison between the actual hash and the expected hash is performed in constant time.
psa_hash_verify() calls 6 functions:
![]()
psa_hash_verify()
psa_hash_verify() reads 1 variable:
![]()
psa_hash_verify()