psa_cipher_generate_iv() function
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().
Arguments
operation
Active cipher operation.
iv
Buffer where the generated IV is to be written.
iv_size
Size of the \p iv buffer in bytes.
iv_length
On success, the number of bytes of the generated IV.
Return value
#PSA_SUCCESS Success. #PSA_ERROR_BUFFER_TOO_SMALL The size of the \p iv buffer is too small. #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription #PSA_ERROR_HARDWARE_FAILURE \emptydescription #PSA_ERROR_CORRUPTION_DETECTED \emptydescription #PSA_ERROR_STORAGE_FAILURE \emptydescription #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.
psa_cipher_generate_iv() calls 6 functions:
![]()
psa_cipher_generate_iv()
psa_cipher_generate_iv() reads 5 variables and writes 1 variable:
![]()
psa_cipher_generate_iv()