summaryrefslogtreecommitdiffhomepage
path: root/libtommath/bn_mp_prime_is_prime.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtommath/bn_mp_prime_is_prime.c')
-rw-r--r--libtommath/bn_mp_prime_is_prime.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libtommath/bn_mp_prime_is_prime.c b/libtommath/bn_mp_prime_is_prime.c
index c23685d..6af5c2c 100644
--- a/libtommath/bn_mp_prime_is_prime.c
+++ b/libtommath/bn_mp_prime_is_prime.c
@@ -332,16 +332,15 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
}
/*
* That number might got too big and the witness has to be
- * smaller than or equal to "a"
+ * smaller than "a"
*/
len = mp_count_bits(&b);
- if (len > size_a) {
- len = len - size_a;
+ if (len >= size_a) {
+ len = (len - size_a) + 1;
if ((err = mp_div_2d(&b, len, &b, NULL)) != MP_OKAY) {
goto LBL_B;
}
}
-
/* Although the chance for b <= 3 is miniscule, try again. */
if (mp_cmp_d(&b, 3uL) != MP_GT) {
ix--;