Function esp_idf_svc::hal::sys::psa_cipher_set_iv
source ยท pub unsafe extern "C" fn psa_cipher_set_iv(
operation: *mut psa_cipher_operation_s,
iv: *const u8,
iv_length: usize,
) -> i32
Expand description
Set the IV for a symmetric encryption or decryption operation.
This function sets the IV (initialization vector), nonce or initial counter value for the encryption or decryption operation.
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().
\note When encrypting, applications should use psa_cipher_generate_iv() instead of this function, unless implementing a protocol that requires a non-random IV.
\param[in,out] operation Active cipher operation. \param[in] iv Buffer containing the IV to use. \param iv_length Size of the IV in bytes.
\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_INVALID_ARGUMENT The size of \p iv is not acceptable for the chosen algorithm, or the chosen algorithm does not use an IV. \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 cipher encrypt operation, 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.