Skip to content

Commit

Permalink
Additional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
czurnieden committed Jun 20, 2023
1 parent 3f65f51 commit 7a9df19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mp_prime_is_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result)

/* If the whole prime table up to p = 1619 has been tested, than all
numbers below 1621^2 = 2,627,641 are prime now. log_2(1621^2) ~ 21.33 */
if (bits < 21) {
#if ((defined S_MP_PRIME_IS_DIVISIBLE_C) && (MP_PRIME_TAB_SIZE >= 256))
if (bits < 2) {
*result = true;
return MP_OKAY;
}

#endif
/*
Run the Miller-Rabin test with base 2 for the BPSW test.
*/
Expand Down Expand Up @@ -266,7 +267,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result)
goto LBL_B;
}
#endif
if (bits < 43) {
if ((bits >= 32) && (bits < 43)) {
for (ix = 0; ix < 3; ix++) {
mp_set(&b, bases32[ix]);
if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) {
Expand Down

0 comments on commit 7a9df19

Please sign in to comment.