pub unsafe extern "C" fn psa_aead_encrypt(
key: mbedtls_svc_key_id_t,
alg: psa_algorithm_t,
nonce: *const u8,
nonce_length: usize,
additional_data: *const u8,
additional_data_length: usize,
plaintext: *const u8,
plaintext_length: usize,
ciphertext: *mut u8,
ciphertext_size: usize,
ciphertext_length: *mut usize,
) -> psa_status_tExpand description
Process an authenticated encryption operation.
\param key Identifier of the key to use for the
operation. It must allow the usage
#PSA_KEY_USAGE_ENCRYPT.
\param alg The AEAD algorithm to compute
(\c PSA_ALG_XXX value such that
#PSA_ALG_IS_AEAD(\p alg) is true).
\param[in] nonce Nonce or IV to use.
\param nonce_length Size of the \p nonce buffer in bytes.
\param[in] additional_data Additional data that will be authenticated
but not encrypted.
\param additional_data_length Size of \p additional_data in bytes.
\param[in] plaintext Data that will be authenticated and
encrypted.
\param plaintext_length Size of \p plaintext in bytes.
For #PSA_ALG_CHACHA20_POLY1305, this must
not exceed UINT32_MAX * 64 bytes.
\param[out] ciphertext Output buffer for the authenticated and
encrypted data. The additional data is not
part of this output. For algorithms where the
encrypted data and the authentication tag
are defined as separate outputs, the
authentication tag is appended to the
encrypted data.
\param ciphertext_size Size of the \p ciphertext buffer in bytes.
This must be appropriate for the selected
algorithm and key:
- A sufficient output size is
#PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\c key_type,
\p alg, \p plaintext_length) where
\c key_type is the type of \p key.
- #PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(\p
plaintext_length) evaluates to the maximum
ciphertext size of any supported AEAD
encryption.
\param[out] ciphertext_length On success, the size of the output
in the \p ciphertext buffer.
\retval #PSA_SUCCESS Success. \retval #PSA_ERROR_INVALID_HANDLE \emptydescription \retval #PSA_ERROR_NOT_PERMITTED \emptydescription \retval #PSA_ERROR_INVALID_ARGUMENT \p key is not compatible with \p alg, or \p plaintext_length is not acceptable for \p alg. \retval #PSA_ERROR_NOT_SUPPORTED \p alg is not supported or is not an AEAD algorithm. \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription \retval #PSA_ERROR_BUFFER_TOO_SMALL \p ciphertext_size is too small. #PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\c key_type, \p alg, \p plaintext_length) or #PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(\p plaintext_length) can be used to determine the required buffer size. \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 library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.