forked from wolfSSL/wolfssl
Maintenance: Prime
1. Prime test should return NO for 1. (ex function, normal math and fast math) 2. Call mp_init() on the k value for the primality test case in the wolfCrypt test.
This commit is contained in:
@ -4783,6 +4783,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) {
|
||||
|
@ -4129,6 +4129,11 @@ int mp_prime_is_prime_ex(mp_int* a, int t, int* result, WC_RNG* rng)
|
||||
if (a == NULL || result == NULL || rng == NULL)
|
||||
return FP_VAL;
|
||||
|
||||
if (fp_isone(a)) {
|
||||
*result = FP_NO;
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
if (ret == FP_YES) {
|
||||
fp_digit d;
|
||||
int r;
|
||||
|
@ -24631,7 +24631,9 @@ static int GenerateNextP(mp_int* p1, mp_int* p2, int k)
|
||||
int ret;
|
||||
mp_int ki;
|
||||
|
||||
ret = mp_set(&ki, k);
|
||||
ret = mp_init(&ki);
|
||||
if (ret == 0)
|
||||
ret = mp_set(&ki, k);
|
||||
if (ret == 0)
|
||||
ret = mp_sub_d(p1, 1, p2);
|
||||
if (ret == 0)
|
||||
|
Reference in New Issue
Block a user