psa_aead_decrypt() function
Process an authenticated decryption operation.
Syntax
psa_status_t psa_aead_decrypt(mbedtls_svc_key_id_t key,
psa_algorithm_t alg,
const uint8_t *nonce,
size_t nonce_length,
const uint8_t *additional_data,
size_t additional_data_length,
const uint8_t *ciphertext,
size_t ciphertext_length,
uint8_t *plaintext,
size_t plaintext_size,
size_t *plaintext_length);
Arguments
key
Identifier of the key to use for the operation. It must allow the usage #PSA_KEY_USAGE_DECRYPT.
alg
The AEAD algorithm to compute (\c PSA_ALG_XXX value such that #PSA_ALG_IS_AEAD(\p alg) is true).
nonce_length
Size of the \p nonce buffer in bytes.
additional_data
Additional data that has been authenticated but not encrypted.
additional_data_length
Size of \p additional_data in bytes.
ciphertext
Data that has been authenticated and encrypted. For algorithms where the encrypted data and the authentication tag are defined as separate inputs, the buffer must contain the encrypted data followed by the authentication tag.
ciphertext_length
Size of \p ciphertext in bytes.
plaintext
Output buffer for the decrypted data.
plaintext_size
Size of the \p plaintext buffer in bytes. This must be appropriate for the selected algorithm and key: - A sufficient output size is #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\c key_type, \p alg, \p ciphertext_length) where \c key_type is the type of \p key. - #PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(\p ciphertext_length) evaluates to the maximum plaintext size of any supported AEAD decryption.
plaintext_length
On success, the size of the output in the \p plaintext buffer.
Return value
#PSA_SUCCESS Success. #PSA_ERROR_INVALID_HANDLE \emptydescription #PSA_ERROR_INVALID_SIGNATURE The ciphertext is not authentic. #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 an AEAD algorithm. #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription #PSA_ERROR_BUFFER_TOO_SMALL \p plaintext_size is too small. #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\c key_type, \p alg, \p ciphertext_length) or #PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(\p ciphertext_length) can be used to determine the required buffer size. #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.