diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index 668253303..12b5b8059 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -4715,6 +4715,11 @@ int mp_prime_is_prime (mp_int * a, int t, int *result) return MP_VAL; } + if (mp_isone(a)) { + *result = 0; + return MP_OKAY; + } + /* is the input equal to one of the primes in the table? */ for (ix = 0; ix < PRIME_SIZE; ix++) { if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) { diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index a5c409f47..2f7d347fa 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -4074,6 +4074,11 @@ int fp_isprime_ex(fp_int *a, int t, int* result) return FP_VAL; } + if (fp_isone(a)) { + *result = FP_NO; + return FP_OKAY; + } + /* check against primes table */ for (r = 0; r < FP_PRIME_SIZE; r++) { if (fp_cmp_d(a, primes[r]) == FP_EQ) {