Compare commits

..

2 Commits

Author SHA1 Message Date
Lealem Amedie
064aace824 Add ability to switch to STD RSA method 2025-07-02 10:03:28 -06:00
kaleb-himes
844e961ff5 Check-in FIPS 140-3 PILOT changes 2023-08-28 15:43:24 -07:00
2 changed files with 25 additions and 8 deletions

View File

@@ -2271,7 +2271,10 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
#endif
#ifndef RSA_LOW_MEM
if ((mp_count_bits(&key->p) == 1024) &&
(mp_count_bits(&key->q) == 1024)) {
(mp_count_bits(&key->q) == 1024) &&
(mp_count_bits(&key->dP) > 0) &&
(mp_count_bits(&key->dQ) > 0) &&
(mp_count_bits(&key->u) > 0)) {
return sp_RsaPrivate_2048(in, inLen, &key->d, &key->p, &key->q,
&key->dP, &key->dQ, &key->u, &key->n,
out, outLen);
@@ -2302,7 +2305,10 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
#endif
#ifndef RSA_LOW_MEM
if ((mp_count_bits(&key->p) == 1536) &&
(mp_count_bits(&key->q) == 1536)) {
(mp_count_bits(&key->q) == 1536) &&
(mp_count_bits(&key->dP) > 0) &&
(mp_count_bits(&key->dQ) > 0) &&
(mp_count_bits(&key->u) > 0)) {
return sp_RsaPrivate_3072(in, inLen, &key->d, &key->p, &key->q,
&key->dP, &key->dQ, &key->u, &key->n,
out, outLen);
@@ -2333,7 +2339,10 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
#endif
#ifndef RSA_LOW_MEM
if ((mp_count_bits(&key->p) == 2048) &&
(mp_count_bits(&key->q) == 2048)) {
(mp_count_bits(&key->q) == 2048) &&
(mp_count_bits(&key->dP) > 0) &&
(mp_count_bits(&key->dQ) > 0) &&
(mp_count_bits(&key->u) > 0)) {
return sp_RsaPrivate_4096(in, inLen, &key->d, &key->p, &key->q,
&key->dP, &key->dQ, &key->u, &key->n,
out, outLen);
@@ -2434,7 +2443,13 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
if (ret == 0 && mp_exptmod(tmp, &key->d, &key->n, tmp) != MP_OKAY)
ret = MP_EXPTMOD_E;
#else
if (ret == 0) {
if (ret == 0 && (mp_iszero(&key->p) || mp_iszero(&key->q) ||
mp_iszero(&key->dP) || mp_iszero(&key->dQ))) {
if (mp_exptmod(tmp, &key->d, &key->n, tmp) != MP_OKAY) {
ret = MP_EXPTMOD_E;
}
}
else if (ret == 0) {
#ifdef WOLFSSL_SMALL_STACK
mp_int* tmpa;
mp_int* tmpb = NULL;

View File

@@ -58,10 +58,10 @@ enum FipsCastStateId {
};
enum FipsModeId {
FIPS_MODE_INIT,
FIPS_MODE_NORMAL,
FIPS_MODE_DEGRADED,
FIPS_MODE_FAILED
FIPS_MODE_INIT = 0,
FIPS_MODE_NORMAL = 1,
FIPS_MODE_DEGRADED = 2,
FIPS_MODE_FAILED = 3
};
@@ -73,6 +73,7 @@ WOLFSSL_API int wolfCrypt_SetCb_fips(wolfCrypt_fips_cb cbf);
/* Public get status functions */
WOLFSSL_API int wolfCrypt_GetStatus_fips(void);
WOLFSSL_API int wolfCrypt_GetMode_fips(void);
WOLFSSL_API const char* wolfCrypt_GetCoreHash_fips(void);
#ifdef HAVE_FORCE_FIPS_FAILURE
@@ -87,6 +88,7 @@ WOLFSSL_LOCAL int DoKnownAnswerTests(char*, int); /* FIPSv1 and FIPSv2 */
WOLFSSL_API int wc_RunCast_fips(int);
WOLFSSL_API int wc_GetCastStatus_fips(int);
WOLFSSL_API int wc_RunAllCast_fips(void);
#ifdef __cplusplus
} /* extern "C" */