psa_cipher_encrypt() function
Encrypt a message using a symmetric cipher. This function encrypts a message with a random IV (initialization vector). Use the multipart operation interface with a #psa_cipher_operation_t object to provide other forms of IV.
Arguments
key
Identifier of the key to use for the operation. It must allow the usage #PSA_KEY_USAGE_ENCRYPT.
alg
The cipher algorithm to compute (\c PSA_ALG_XXX value such that #PSA_ALG_IS_CIPHER(\p alg) is true).
input
Buffer containing the message to encrypt.
input_length
Size of the \p input buffer in bytes.
output
Buffer where the output is to be written. The output contains the IV followed by the ciphertext proper.
output_size
Size of the \p output buffer in bytes.
output_length
On success, the number of bytes that make up the output.
Return value
#PSA_SUCCESS Success. #PSA_ERROR_INVALID_HANDLE \emptydescription #PSA_ERROR_NOT_PERMITTED \emptydescription #PSA_ERROR_INVALID_ARGUMENT \p key is not compatible with \p alg. #PSA_ERROR_NOT_SUPPORTED \p alg is not supported or is not a cipher algorithm. #PSA_ERROR_BUFFER_TOO_SMALL \emptydescription #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 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_encrypt() calls 9 functions:
![]()
psa_cipher_encrypt()
psa_cipher_encrypt() reads 7 variables:
![]()
psa_cipher_encrypt()