From 40864da53391b111f0c554f46bd8f64ee884c554 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Tue, 2 Jul 2019 14:37:43 +1000 Subject: [PATCH] Fix prime testing to do t iterations of random values in range --- wolfcrypt/src/integer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index f1f1b25d3..ca6627048 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -4654,8 +4654,10 @@ int mp_prime_is_prime_ex (mp_int * a, int t, int *result, WC_RNG *rng) goto LBL_B; } - if (mp_cmp_d(&b, 2) != MP_GT || mp_cmp(&b, &c) != MP_LT) + if (mp_cmp_d(&b, 2) != MP_GT || mp_cmp(&b, &c) != MP_LT) { + ix--; continue; + } if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) { goto LBL_B;