mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Copy input and output in psa_cipher_encrypt()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
8f35a4f003
commit
c6977b4899
@ -4346,6 +4346,20 @@ psa_status_t psa_cipher_encrypt(mbedtls_svc_key_id_t key,
|
|||||||
size_t default_iv_length = 0;
|
size_t default_iv_length = 0;
|
||||||
psa_key_attributes_t attributes;
|
psa_key_attributes_t attributes;
|
||||||
|
|
||||||
|
psa_crypto_local_input_t local_input = PSA_CRYPTO_LOCAL_INPUT_INIT;
|
||||||
|
status = psa_crypto_local_input_alloc(input, input_length, &local_input);
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
input = local_input.buffer;
|
||||||
|
|
||||||
|
psa_crypto_local_output_t local_output = PSA_CRYPTO_LOCAL_OUTPUT_INIT;
|
||||||
|
status = psa_crypto_local_output_alloc(output, output_size, &local_output);
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
output = local_output.buffer;
|
||||||
|
|
||||||
if (!PSA_ALG_IS_CIPHER(alg)) {
|
if (!PSA_ALG_IS_CIPHER(alg)) {
|
||||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -4401,6 +4415,9 @@ exit:
|
|||||||
*output_length = 0;
|
*output_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
psa_crypto_local_input_free(&local_input);
|
||||||
|
psa_crypto_local_output_free(&local_output);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user