1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Decouple if statement in psa_raw_key_agreement exit.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
Thomas Daubney
2024-02-22 11:08:22 +00:00
parent 2ea8d8fa3c
commit 09cf4f2e78

View File

@ -5332,17 +5332,21 @@ psa_status_t psa_raw_key_agreement(psa_algorithm_t alg,
output_length); output_length);
exit: exit:
/* Check for successful allocation of output,
* with an unsuccessful status. */
if (output != NULL && status != PSA_SUCCESS) { if (output != NULL && status != PSA_SUCCESS) {
/* If an error happens and is not handled properly, the output /* If an error happens and is not handled properly, the output
* may be used as a key to protect sensitive data. Arrange for such * may be used as a key to protect sensitive data. Arrange for such
* a key to be random, which is likely to result in decryption or * a key to be random, which is likely to result in decryption or
* verification errors. This is better than filling the buffer with * verification errors. This is better than filling the buffer with
* some constant data such as zeros, which would result in the data * some constant data such as zeros, which would result in the data
* being protected with a reproducible, easily knowable key. * being protected with a reproducible, easily knowable key.
*/ */
psa_generate_random(output, output_size); psa_generate_random(output, output_size);
*output_length = output_size; *output_length = output_size;
} else { }
if (output == NULL) {
/* output allocation failed. */ /* output allocation failed. */
*output_length = 0; *output_length = 0;
} }