Merge pull request #2618 from ejohnstown/maintenance-prime

Maintenance: Prime
This commit is contained in:
toddouska
2019-11-27 14:06:23 -08:00
committed by GitHub
4 changed files with 60 additions and 5 deletions

View File

@@ -4717,10 +4717,15 @@ int mp_prime_is_prime (mp_int * a, int t, int *result)
return MP_VAL;
}
if (mp_isone(a)) {
*result = MP_NO;
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) {
*result = 1;
*result = MP_YES;
return MP_OKAY;
}
}
@@ -4780,6 +4785,11 @@ int mp_prime_is_prime_ex (mp_int * a, int t, int *result, WC_RNG *rng)
return MP_VAL;
}
if (mp_isone(a)) {
*result = MP_NO;
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) {