Decouple if statements 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:06:04 +00:00
parent 0576a6a174
commit 5390acada9

View File

@ -7429,6 +7429,8 @@ 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
@ -7439,7 +7441,9 @@ exit:
*/ */
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;
} }