psa_mac_sign_finish() function
Finish the calculation of the MAC of a message. The application must call psa_mac_sign_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(). 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(). \warning Applications should not call this function if they expect a specific value for the MAC. Call psa_mac_verify_finish() instead. Beware that comparing integrity or authenticity data such as MAC values with a function such as \c memcmp is risky because the time taken by the comparison may leak information about the MAC value which could allow an attacker to guess a valid MAC and thereby bypass security controls.
Arguments
operation
Active MAC operation.
mac
Buffer where the MAC value is to be written.
mac_size
Size of the \p mac buffer in bytes.
mac_length
On success, the number of bytes that make up the MAC value. This is always #PSA_MAC_LENGTH(\c key_type, \c key_bits, \c alg) where \c key_type and \c key_bits are the type and bit-size respectively of the key and \c alg is the MAC algorithm that is calculated.
Return value
#PSA_SUCCESS Success. #PSA_ERROR_BUFFER_TOO_SMALL The size of the \p mac buffer is too small. You can determine a sufficient buffer size by calling PSA_MAC_LENGTH(). #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 sign 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.