Function esp_idf_sys::psa_cipher_generate_iv

source ยท
pub unsafe extern "C" fn psa_cipher_generate_iv(
    operation: *mut psa_cipher_operation_t,
    iv: *mut u8,
    iv_size: usize,
    iv_length: *mut usize,
) -> psa_status_t
Expand description

Generate an IV for a symmetric encryption operation.

This function generates a random IV (initialization vector), nonce or initial counter value for the encryption operation as appropriate for the chosen algorithm, key type and key size.

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

\param[in,out] operation Active cipher operation. \param[out] iv Buffer where the generated IV is to be written. \param iv_size Size of the \p iv buffer in bytes. \param[out] iv_length On success, the number of bytes of the generated IV.

\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_BUFFER_TOO_SMALL The size of the \p iv 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 active, with no IV 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.