mirror of
https://github.com/stefanberger/libtpms
synced 2026-01-17 07:34:57 +00:00
tpm2: Rename RsaInitializeExponent to RsaInitializeExponentOld
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
0de1cea8a5
commit
d28f4e0e34
@ -79,7 +79,12 @@ BN_TYPE(prime, (MAX_RSA_KEY_BITS / 2));
|
||||
# error This verson only works with CRT formatted data
|
||||
#endif // !CRT_FORMAT_RSA
|
||||
|
||||
typedef struct privateExponent
|
||||
// libtpms added begin: keep old privateExponent
|
||||
/* The privateExponentOld is part of the OBJECT and we keep it there even though
|
||||
* upstream got rid of it and stores Q, dP, dQ, and qInv by appending them to
|
||||
* P stored in TPMT_SENSITIVE.TPMU_SENSITIVE_COMPOSITE.TPM2B_PRIVATE_KEY_RSA
|
||||
*/
|
||||
typedef struct privateExponentOld
|
||||
{
|
||||
bn_prime_t Q;
|
||||
bn_prime_t dP;
|
||||
@ -87,5 +92,18 @@ typedef struct privateExponent
|
||||
bn_prime_t qInv;
|
||||
} privateExponent_t;
|
||||
|
||||
#include "BnMemory_fp.h"
|
||||
|
||||
static inline void
|
||||
RsaInitializeExponentOld(
|
||||
privateExponent_t *pExp
|
||||
)
|
||||
{
|
||||
BN_INIT(pExp->Q);
|
||||
BN_INIT(pExp->dP);
|
||||
BN_INIT(pExp->dQ);
|
||||
BN_INIT(pExp->qInv);
|
||||
} // libtpms added end
|
||||
|
||||
#endif // _CRYPT_RSA_H
|
||||
|
||||
|
||||
@ -69,10 +69,6 @@ BOOL
|
||||
CryptRsaStartup(
|
||||
void
|
||||
);
|
||||
void
|
||||
RsaInitializeExponent(
|
||||
privateExponent_t *pExp
|
||||
);
|
||||
INT16
|
||||
CryptRsaPssSaltSize(
|
||||
INT16 hashSize,
|
||||
|
||||
@ -97,17 +97,6 @@ CryptRsaStartup(
|
||||
function returns the pointer to the private exponent value so that it can be used in an
|
||||
initializer for a data declaration */
|
||||
|
||||
void
|
||||
RsaInitializeExponent(
|
||||
privateExponent_t *pExp
|
||||
)
|
||||
{
|
||||
BN_INIT(pExp->Q);
|
||||
BN_INIT(pExp->dP);
|
||||
BN_INIT(pExp->dQ);
|
||||
BN_INIT(pExp->qInv);
|
||||
}
|
||||
|
||||
#if 0 // libtpms added
|
||||
/* 10.2.17.4.2 MakePgreaterThanQ() */
|
||||
/* This function swaps the pointers for P and Q if Q happens to be larger than Q. */
|
||||
@ -200,7 +189,7 @@ ComputePrivateExponent(
|
||||
BOOL qOK;
|
||||
BN_PRIME(pT);
|
||||
//
|
||||
RsaInitializeExponent(pExp);
|
||||
RsaInitializeExponentOld(pExp);
|
||||
BnCopy((bigNum)&pExp->Q, Q);
|
||||
// make p the larger value so that m2 is always less than p
|
||||
if(BnUnsignedCmp(P, Q) < 0)
|
||||
@ -1007,7 +996,7 @@ CryptRsaLoadPrivateExponent(
|
||||
{
|
||||
TEST(TPM_ALG_NULL);
|
||||
// Make sure that the bigNum used for the exponent is properly initialized
|
||||
RsaInitializeExponent(&rsaKey->privateExponent);
|
||||
RsaInitializeExponentOld(&rsaKey->privateExponent);
|
||||
// Find the second prime by division
|
||||
BnDiv(bnQ, bnQr, bnN, bnP);
|
||||
if(!BnEqualZero(bnQr))
|
||||
@ -1322,7 +1311,7 @@ CryptRsaGenerateKey(
|
||||
return OpenSSLCryptRsaGenerateKey(rsaKey, e, keySizeInBits);
|
||||
#endif // libtpms added end
|
||||
// Need to initialize the privateExponent structure
|
||||
RsaInitializeExponent(&rsaKey->privateExponent);
|
||||
RsaInitializeExponentOld(&rsaKey->privateExponent);
|
||||
|
||||
// The prime is computed in P. When a new prime is found, Q is checked to
|
||||
// see if it is zero. If so, P is copied to Q and a new P is found.
|
||||
|
||||
@ -877,7 +877,7 @@ OpenSSLCryptRsaGenerateKey(
|
||||
ERROR_RETURN(TPM_RC_FAILURE);
|
||||
|
||||
// Need to initialize the privateExponent structure
|
||||
RsaInitializeExponent(&rsaKey->privateExponent);
|
||||
RsaInitializeExponentOld(&rsaKey->privateExponent);
|
||||
|
||||
if ((ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL)) == NULL ||
|
||||
EVP_PKEY_keygen_init(ctx) != 1 ||
|
||||
@ -943,7 +943,7 @@ OpenSSLCryptRsaGenerateKey(
|
||||
ERROR_RETURN(TPM_RC_FAILURE);
|
||||
|
||||
// Need to initialize the privateExponent structure
|
||||
RsaInitializeExponent(&rsaKey->privateExponent);
|
||||
RsaInitializeExponentOld(&rsaKey->privateExponent);
|
||||
|
||||
rsa = RSA_new();
|
||||
if (rsa == NULL)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user