summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_prime.c
diff options
context:
space:
mode:
authorUlf Möller <ulf@openssl.org>2000-02-01 23:48:55 +0000
committerUlf Möller <ulf@openssl.org>2000-02-01 23:48:55 +0000
commit1399f17a0733b776c363f18225a1461b3a6f8cb7 (patch)
treecb44b2e487838362689155844d566158ecc29c67 /crypto/bn/bn_prime.c
parent0bde1089f895718db2fe2637fda4a0c2ed6df904 (diff)
Bug fix: BN_is_prime() would fail with a high probability for small
primes (negligible for larger ones).
Diffstat (limited to 'crypto/bn/bn_prime.c')
-rw-r--r--crypto/bn/bn_prime.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c
index e2cfef3725..f6de801263 100644
--- a/crypto/bn/bn_prime.c
+++ b/crypto/bn/bn_prime.c
@@ -204,6 +204,7 @@ int BN_is_prime_fasttest(BIGNUM *a, int checks,
if (!BN_pseudo_rand(check,BN_num_bits(a),0,0)) goto err;
if (BN_cmp(check, a) >= 0)
BN_sub(check, check, a);
+ if (BN_is_zero(check)) BN_one(check);
j=witness(check,a,ctx,ctx2,mont);
if (j == -1) goto err;
if (j)