mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-31 05:19:16 +01:00
Merge pull request #2474 from SparkiDev/sp_int_prime
Add support for prime checking to sp_int.c
This commit is contained in:
@@ -4164,7 +4164,11 @@ exit:
|
||||
void bench_rsaKeyGen(int doAsync)
|
||||
{
|
||||
int k, keySz;
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
const int keySizes[2] = {1024, 2048};
|
||||
#else
|
||||
const int keySizes[1] = {2048};
|
||||
#endif
|
||||
|
||||
for (k = 0; k < (int)(sizeof(keySizes)/sizeof(int)); k++) {
|
||||
keySz = keySizes[k];
|
||||
|
||||
@@ -2060,7 +2060,6 @@ static int _DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
|
||||
keyP = &key->p;
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
if (ret == 0 && !trusted) {
|
||||
int isPrime = 0;
|
||||
if (rng != NULL)
|
||||
@@ -2071,10 +2070,6 @@ static int _DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
|
||||
if (ret == 0 && isPrime == 0)
|
||||
ret = DH_CHECK_PUB_E;
|
||||
}
|
||||
#else
|
||||
(void)trusted;
|
||||
(void)rng;
|
||||
#endif
|
||||
|
||||
if (ret == 0 && mp_init(&key->g) != MP_OKAY)
|
||||
ret = MP_INIT_E;
|
||||
|
||||
@@ -606,7 +606,7 @@ int wc_CheckRsaKey(RsaKey* key)
|
||||
ret = MP_READ_E;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SP_RSA
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
#ifndef WOLFSSL_SP_NO_2048
|
||||
if (mp_count_bits(&key->n) == 2048) {
|
||||
ret = sp_ModExp_2048(k, &key->e, &key->n, tmp);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1774,6 +1774,7 @@ int sp_ModExp_2048(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_DH
|
||||
#ifdef HAVE_FFDHE_2048
|
||||
extern void sp_2048_lshift_32(sp_digit* r, const sp_digit* a, int n);
|
||||
#ifdef HAVE_INTEL_AVX2
|
||||
@@ -2055,6 +2056,7 @@ int sp_DhExp_2048(mp_int* base, const byte* exp, word32 expLen,
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
/* Perform the modular exponentiation for Diffie-Hellman.
|
||||
*
|
||||
* base Base. MP integer.
|
||||
@@ -3832,6 +3834,7 @@ int sp_ModExp_3072(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_DH
|
||||
#ifdef HAVE_FFDHE_3072
|
||||
extern void sp_3072_lshift_48(sp_digit* r, const sp_digit* a, int n);
|
||||
#ifdef HAVE_INTEL_AVX2
|
||||
@@ -4113,6 +4116,7 @@ int sp_DhExp_3072(mp_int* base, const byte* exp, word32 expLen,
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
/* Perform the modular exponentiation for Diffie-Hellman.
|
||||
*
|
||||
* base Base. MP integer.
|
||||
|
||||
@@ -4063,7 +4063,8 @@ int fp_isprime_ex(fp_int *a, int t, int* result)
|
||||
int r, res;
|
||||
|
||||
if (t <= 0 || t > FP_PRIME_SIZE) {
|
||||
return FP_NO;
|
||||
*result = FP_NO;
|
||||
return FP_VAL;
|
||||
}
|
||||
|
||||
/* check against primes table */
|
||||
|
||||
@@ -11470,7 +11470,11 @@ static int rsa_keygen_test(WC_RNG* rng)
|
||||
byte* pem = NULL;
|
||||
word32 idx = 0;
|
||||
int derSz = 0;
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
int keySz = 1024;
|
||||
#else
|
||||
int keySz = 2048;
|
||||
#endif
|
||||
|
||||
XMEMSET(&genKey, 0, sizeof(genKey));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user