Function esp_idf_svc::sys::psa_aead_set_nonce

source ยท
pub unsafe extern "C" fn psa_aead_set_nonce(
    operation: *mut psa_aead_operation_s,
    nonce: *const u8,
    nonce_length: usize,
) -> i32
Expand description

Set the nonce for an authenticated encryption or decryption operation.

This function sets the nonce for the authenticated encryption or decryption operation.

The application must call psa_aead_encrypt_setup() or psa_aead_decrypt_setup() before calling this function.

If this function returns an error status, the operation enters an error state and must be aborted by calling psa_aead_abort().

\note When encrypting, applications should use psa_aead_generate_nonce() instead of this function, unless implementing a protocol that requires a non-random IV.

\param[in,out] operation Active AEAD operation. \param[in] nonce Buffer containing the nonce to use. \param nonce_length Size of the nonce in bytes.

\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_INVALID_ARGUMENT The size of \p nonce is not acceptable for the chosen algorithm. \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 \emptydescription \retval #PSA_ERROR_BAD_STATE The operation state is not valid (it must be active, with no nonce set), 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.