Function esp_idf_svc::hal::sys::psa_mac_compute
source ยท pub unsafe extern "C" fn psa_mac_compute(
key: u32,
alg: u32,
input: *const u8,
input_length: usize,
mac: *mut u8,
mac_size: usize,
mac_length: *mut usize,
) -> i32
Expand description
Calculate the MAC (message authentication code) of a message.
\note To verify the MAC of a message against an expected value, use psa_mac_verify() 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.
\param key Identifier of the key to use for the operation. It must allow the usage PSA_KEY_USAGE_SIGN_MESSAGE. \param alg The MAC algorithm to compute (\c PSA_ALG_XXX value such that #PSA_ALG_IS_MAC(\p alg) is true). \param[in] input Buffer containing the input message. \param input_length Size of the \p input buffer in bytes. \param[out] mac Buffer where the MAC value is to be written. \param mac_size Size of the \p mac buffer in bytes. \param[out] mac_length On success, the number of bytes that make up the MAC value.
\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_INVALID_HANDLE \emptydescription \retval #PSA_ERROR_NOT_PERMITTED \emptydescription \retval #PSA_ERROR_INVALID_ARGUMENT \p key is not compatible with \p alg. \retval #PSA_ERROR_NOT_SUPPORTED \p alg is not supported or is not a MAC algorithm. \retval #PSA_ERROR_BUFFER_TOO_SMALL \p mac_size is too small \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 The key could not be retrieved from storage. \retval #PSA_ERROR_BAD_STATE 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.