psa_mac_verify_finish() function
Finish the calculation of the MAC of a message and compare it with an expected value. The application must call psa_mac_verify_setup() before calling this function. This function calculates the MAC of the message formed by concatenating the inputs passed to preceding calls to psa_mac_update(). It then compares the calculated MAC with the expected MAC 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_mac_abort().
Arguments
operation
Active MAC operation.
mac
Buffer containing the expected MAC value.
mac_length
Size of the \p mac buffer in bytes.
Return value
#PSA_SUCCESS The expected MAC is identical to the actual MAC of the message. #PSA_ERROR_INVALID_SIGNATURE The MAC of the message was calculated successfully, but it differs from the expected MAC. #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription #PSA_ERROR_HARDWARE_FAILURE \emptydescription #PSA_ERROR_CORRUPTION_DETECTED \emptydescription #PSA_ERROR_STORAGE_FAILURE \emptydescription #PSA_ERROR_BAD_STATE The operation state is not valid (it must be an active mac verify operation), 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 MAC and the expected MAC is performed in constant time.