Skip to content

Commit

Permalink
tpm2: Check return code of BN_div()
Browse files Browse the repository at this point in the history
Resolves: #304
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Mar 30, 2022
1 parent bd42b67 commit ffaaeb0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/tpm2/crypto/openssl/Helpers.c
Expand Up @@ -521,8 +521,7 @@ InitOpenSSLRSAPrivateKey(OBJECT *rsaKey, // IN
ERROR_RETURN(TPM_RC_FAILURE);
/* Q = N/P; no remainder */
BN_set_flags(P, BN_FLG_CONSTTIME); // P is secret
BN_div(Q, Qr, N, P, ctx);
if(!BN_is_zero(Qr))
if (!BN_div(Q, Qr, N, P, ctx) || !BN_is_zero(Qr))
ERROR_RETURN(TPM_RC_BINDING);
BN_set_flags(Q, BN_FLG_CONSTTIME); // Q is secret

Expand Down

0 comments on commit ffaaeb0

Please sign in to comment.