From 7edfb28a2e998bd56d3252444342fd54f2a15dfb Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Mon, 28 Aug 2023 09:24:27 -0400 Subject: [PATCH] tpm2: RSADP: Replace local bnP with P of new privateExponent Replace the local variable bnP with Z->P. Initialize Z->P with the value that bnP had been initialized with. Signed-off-by: Stefan Berger --- src/tpm2/crypto/openssl/CryptRsa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tpm2/crypto/openssl/CryptRsa.c b/src/tpm2/crypto/openssl/CryptRsa.c index a8104e75..2a5b17df 100644 --- a/src/tpm2/crypto/openssl/CryptRsa.c +++ b/src/tpm2/crypto/openssl/CryptRsa.c @@ -319,7 +319,7 @@ RSADP( ) { BN_RSA_INITIALIZED(bnM, inOut); - BN_RSA_INITIALIZED(bnP, &key->sensitive.sensitive.rsa); + NEW_PRIVATE_EXPONENT(Z); if(UnsignedCompareB(inOut->size, inOut->buffer, key->publicArea.unique.rsa.t.size, key->publicArea.unique.rsa.t.buffer) >= 0) @@ -334,7 +334,8 @@ RSADP( != TPM_RC_SUCCESS) return TPM_RC_BINDING; } - VERIFY(RsaPrivateKeyOp(bnM, bnP, &key->privateExponent)); + VERIFY(BnFrom2B(Z->P, &key->sensitive.sensitive.rsa.b) != NULL); + VERIFY(RsaPrivateKeyOp(bnM, Z->P, &key->privateExponent)); VERIFY(BnTo2B(bnM, inOut, inOut->size)); return TPM_RC_SUCCESS; Error: