forked from wolfSSL/wolfssl
Maintenance: Prime
1. Prime test should return NO for 1. (normal math and fast math)
This commit is contained in:
@ -4715,6 +4715,11 @@ int mp_prime_is_prime (mp_int * a, int t, int *result)
|
|||||||
return MP_VAL;
|
return MP_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mp_isone(a)) {
|
||||||
|
*result = 0;
|
||||||
|
return MP_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
/* is the input equal to one of the primes in the table? */
|
/* is the input equal to one of the primes in the table? */
|
||||||
for (ix = 0; ix < PRIME_SIZE; ix++) {
|
for (ix = 0; ix < PRIME_SIZE; ix++) {
|
||||||
if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) {
|
if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) {
|
||||||
|
@ -4074,6 +4074,11 @@ int fp_isprime_ex(fp_int *a, int t, int* result)
|
|||||||
return FP_VAL;
|
return FP_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fp_isone(a)) {
|
||||||
|
*result = FP_NO;
|
||||||
|
return FP_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
/* check against primes table */
|
/* check against primes table */
|
||||||
for (r = 0; r < FP_PRIME_SIZE; r++) {
|
for (r = 0; r < FP_PRIME_SIZE; r++) {
|
||||||
if (fp_cmp_d(a, primes[r]) == FP_EQ) {
|
if (fp_cmp_d(a, primes[r]) == FP_EQ) {
|
||||||
|
Reference in New Issue
Block a user