Maintenance: Prime

1. Prime test should return NO for 1. (sp math)
This commit is contained in:
John Safranek
2019-11-22 10:01:21 -08:00
parent 452ba5b502
commit 0a924af894

View File

@ -1703,6 +1703,11 @@ int sp_prime_is_prime(sp_int *a, int t, int* result)
err = MP_VAL;
}
if (sp_isone(a)) {
*result = MP_NO;
return MP_OKAY;
}
if (err == MP_OKAY && a->used == 1) {
/* check against primes table */
for (i = 0; i < SP_PRIME_SIZE; i++) {
@ -1783,6 +1788,11 @@ int sp_prime_is_prime_ex(sp_int* a, int t, int* result, WC_RNG* rng)
if (a == NULL || result == NULL || rng == NULL)
err = MP_VAL;
if (sp_isone(a)) {
*result = MP_NO;
return MP_OKAY;
}
if (err == MP_OKAY && a->used == 1) {
/* check against primes table */
for (i = 0; i < SP_PRIME_SIZE; i++) {