Skip to content

Commit

Permalink
core: pta: attestation: check return value of crypto_bignum_bin2bn()
Browse files Browse the repository at this point in the history
Check the return value of crypto_bignum_bin2bn().

Signed-off-by: Clement Faure <clement.faure@nxp.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
clementfaure committed Aug 22, 2023
1 parent f602283 commit 37246d9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/pta/attestation.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ static TEE_Result generate_key(void)

res = allocate_key();
if (res)
return res;
goto err;

crypto_bignum_bin2bn((uint8_t *)&e, sizeof(e), key->e);
res = crypto_bignum_bin2bn((uint8_t *)&e, sizeof(e), key->e);
if (res)
goto err;

/*
* For security reasons, the RSA modulus size has to be at least the
Expand All @@ -68,9 +70,12 @@ static TEE_Result generate_key(void)
COMPILE_TIME_ASSERT(CFG_ATTESTATION_PTA_KEY_SIZE >=
TEE_SHA256_HASH_SIZE);
res = crypto_acipher_gen_rsa_key(key, CFG_ATTESTATION_PTA_KEY_SIZE);
if (res)
free_key();
if (!res)
goto out;

err:
free_key();
out:
return res;
}

Expand Down

0 comments on commit 37246d9

Please sign in to comment.