mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-15 19:20:55 +00:00
Move local buffer allocation just before usage
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
4892d75e9b
commit
8b8e485961
@ -4418,9 +4418,6 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
|
||||
LOCAL_INPUT_DECLARE(input_external, input);
|
||||
LOCAL_OUTPUT_DECLARE(output_external, output);
|
||||
|
||||
LOCAL_INPUT_ALLOC(input_external, input_length, input);
|
||||
LOCAL_OUTPUT_ALLOC_WITH_COPY(output_external, output_size, output);
|
||||
|
||||
if (operation->id == 0) {
|
||||
status = PSA_ERROR_BAD_STATE;
|
||||
goto exit;
|
||||
@ -4431,6 +4428,9 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
LOCAL_INPUT_ALLOC(input_external, input_length, input);
|
||||
LOCAL_OUTPUT_ALLOC_WITH_COPY(output_external, output_size, output);
|
||||
|
||||
status = psa_driver_wrapper_cipher_update(operation,
|
||||
input,
|
||||
input_length,
|
||||
@ -4458,8 +4458,6 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
|
||||
|
||||
LOCAL_OUTPUT_DECLARE(output_external, output);
|
||||
|
||||
LOCAL_OUTPUT_ALLOC_WITH_COPY(output_external, output_size, output);
|
||||
|
||||
if (operation->id == 0) {
|
||||
status = PSA_ERROR_BAD_STATE;
|
||||
goto exit;
|
||||
@ -4470,6 +4468,8 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
LOCAL_OUTPUT_ALLOC_WITH_COPY(output_external, output_size, output);
|
||||
|
||||
status = psa_driver_wrapper_cipher_finish(operation,
|
||||
output,
|
||||
output_size,
|
||||
@ -4524,9 +4524,6 @@ psa_status_t psa_cipher_encrypt(mbedtls_svc_key_id_t key,
|
||||
LOCAL_INPUT_DECLARE(input_external, input);
|
||||
LOCAL_OUTPUT_DECLARE(output_external, output);
|
||||
|
||||
LOCAL_INPUT_ALLOC(input_external, input_length, input);
|
||||
LOCAL_OUTPUT_ALLOC(output_external, output_size, output);
|
||||
|
||||
if (!PSA_ALG_IS_CIPHER(alg)) {
|
||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||
goto exit;
|
||||
@ -4561,6 +4558,9 @@ psa_status_t psa_cipher_encrypt(mbedtls_svc_key_id_t key,
|
||||
}
|
||||
}
|
||||
|
||||
LOCAL_INPUT_ALLOC(input_external, input_length, input);
|
||||
LOCAL_OUTPUT_ALLOC(output_external, output_size, output);
|
||||
|
||||
status = psa_driver_wrapper_cipher_encrypt(
|
||||
&attributes, slot->key.data, slot->key.bytes,
|
||||
alg, local_iv, default_iv_length, input, input_length,
|
||||
@ -4604,9 +4604,6 @@ psa_status_t psa_cipher_decrypt(mbedtls_svc_key_id_t key,
|
||||
LOCAL_INPUT_DECLARE(input_external, input);
|
||||
LOCAL_OUTPUT_DECLARE(output_external, output);
|
||||
|
||||
LOCAL_INPUT_ALLOC(input_external, input_length, input);
|
||||
LOCAL_OUTPUT_ALLOC(output_external, output_size, output);
|
||||
|
||||
if (!PSA_ALG_IS_CIPHER(alg)) {
|
||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||
goto exit;
|
||||
@ -4632,6 +4629,9 @@ psa_status_t psa_cipher_decrypt(mbedtls_svc_key_id_t key,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
LOCAL_INPUT_ALLOC(input_external, input_length, input);
|
||||
LOCAL_OUTPUT_ALLOC(output_external, output_size, output);
|
||||
|
||||
status = psa_driver_wrapper_cipher_decrypt(
|
||||
&attributes, slot->key.data, slot->key.bytes,
|
||||
alg, input, input_length,
|
||||
|
Loading…
x
Reference in New Issue
Block a user