Skip to content

Commit 0426149

Browse files
committed
Additional checks
1 parent 6e81627 commit 0426149

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mp_prime_is_prime.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result)
114114

115115
/* If the whole prime table up to p = 1619 has been tested, than all
116116
numbers below 1621^2 = 2,627,641 are prime now. log_2(1621^2) ~ 21.33 */
117-
if (bits < 21) {
117+
#if ((defined S_MP_PRIME_IS_DIVISIBLE_C) && (MP_PRIME_TAB_SIZE >= 256))
118+
if (bits < 2) {
118119
*result = true;
119120
return MP_OKAY;
120121
}
121-
122+
#endif
122123
/*
123124
Run the Miller-Rabin test with base 2 for the BPSW test.
124125
*/
@@ -266,7 +267,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result)
266267
goto LBL_B;
267268
}
268269
#endif
269-
if (bits < 43) {
270+
if ((bits >= 32) && (bits < 43)) {
270271
for (ix = 0; ix < 3; ix++) {
271272
mp_set(&b, bases32[ix]);
272273
if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) {

0 commit comments

Comments
 (0)