pub unsafe extern "C" fn psa_aead_generate_nonce(
    operation: *mut psa_aead_operation_t,
    nonce: *mut u8,
    nonce_size: usize,
    nonce_length: *mut usize
) -> psa_status_t
Expand description

Generate a random nonce for an authenticated encryption operation.

This function generates a random nonce for the authenticated encryption operation with an appropriate size for the chosen algorithm, key type and key size.

The application must call psa_aead_encrypt_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().

\param[in,out] operation Active AEAD operation. \param[out] nonce Buffer where the generated nonce is to be written. \param nonce_size Size of the \p nonce buffer in bytes. \param[out] nonce_length On success, the number of bytes of the generated nonce.

\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_BUFFER_TOO_SMALL The size of the \p nonce buffer 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 \emptydescription \retval #PSA_ERROR_BAD_STATE The operation state is not valid (it must be an active aead encrypt operation, 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.