mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-09 23:38:23 +00:00
tpm2: Move code out of RsaAdjustPrimeCandidate
To simplify the code and get rid of the libtpms-specific implementation of RsaAdjustPrimeCandidate move its code into the case statements in TpmRsa_GeneratePrimeForRSA. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
aa582228d6
commit
09a67f4588
@ -124,12 +124,6 @@ TpmRsa_GeneratePrimeForRSA(
|
||||
RAND_STATE* rand // IN: the random state
|
||||
);
|
||||
|
||||
// libtpms: added begin
|
||||
void RsaAdjustPrimeCandidate(Crypt_Int* prime,
|
||||
SEED_COMPAT_LEVEL seedCompatLevel // IN: compatibility level
|
||||
);
|
||||
// libtpms: added end
|
||||
|
||||
#endif // ALG_RSA
|
||||
|
||||
#endif // _CRYPT_PRIME_FP_H_
|
||||
|
||||
@ -392,25 +392,6 @@ RsaAdjustPrimeCandidate_New(
|
||||
// issues.
|
||||
//
|
||||
|
||||
|
||||
|
||||
LIB_EXPORT void RsaAdjustPrimeCandidate(Crypt_Int* prime,
|
||||
SEED_COMPAT_LEVEL seedCompatLevel // IN: compatibility level; libtpms added
|
||||
)
|
||||
{
|
||||
switch (seedCompatLevel) {
|
||||
case SEED_COMPAT_LEVEL_ORIGINAL:
|
||||
RsaAdjustPrimeCandidate_PreRev155(prime);
|
||||
break;
|
||||
case SEED_COMPAT_LEVEL_LAST:
|
||||
/* case SEED_COMPAT_LEVEL_RSA_PRIME_ADJUST_FIX: */
|
||||
RsaAdjustPrimeCandidate_New(prime);
|
||||
break;
|
||||
default:
|
||||
FAIL(FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
//***TpmRsa_GeneratePrimeForRSA()
|
||||
// Function to generate a prime of the desired size with the proper attributes
|
||||
// for an RSA prime.
|
||||
@ -444,16 +425,17 @@ TPM_RC TpmRsa_GeneratePrimeForRSA(
|
||||
DRBG_Generate(rand, (BYTE *)prime->d, (UINT16)BITS_TO_BYTES(bits));
|
||||
if (g_inFailureMode)
|
||||
return TPM_RC_FAILURE;
|
||||
RsaAdjustPrimeCandidate_PreRev155(prime);
|
||||
break;
|
||||
case SEED_COMPAT_LEVEL_LAST:
|
||||
/* case SEED_COMPAT_LEVEL_RSA_PRIME_ADJUST_FIX: */
|
||||
/* case SEED_COMPAT_LEVEL_RSA_PRIME_ADJUST_FIX: */
|
||||
if(!TpmMath_GetRandomInteger(prime, bits, rand)) // new
|
||||
return TPM_RC_FAILURE;
|
||||
break;
|
||||
default:
|
||||
FAIL(FATAL_ERROR_INTERNAL);
|
||||
RsaAdjustPrimeCandidate_New(prime);
|
||||
break;
|
||||
default:
|
||||
FAIL(FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
RsaAdjustPrimeCandidate(prime, DRBG_GetSeedCompatLevel(rand));
|
||||
// libtpms changed end
|
||||
found = RsaCheckPrime(prime, exponent, rand) == TPM_RC_SUCCESS;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user