summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-06-18 15:52:36 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-06-18 15:52:36 +0000
commit501774d37884d3baa1fdb59df732d0e04f147f24 (patch)
tree7a3acdeaa39cc8fd4ccab22c36e3a37008e634f3
parent05aab66b1469951129df969407d2d23809df8dd5 (diff)
Fix prime recognition when doing trial divisions
If gcd(a, primes[i]) == 0 then a could still be a prime, namely in the case that a == primes[i], so check for that case as well. Problem noted by Martin Grenouilloux ok jsing
-rw-r--r--lib/libcrypto/bn/bn_prime.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libcrypto/bn/bn_prime.c b/lib/libcrypto/bn/bn_prime.c
index e78c5686ab5..9ab89695d81 100644
--- a/lib/libcrypto/bn/bn_prime.c
+++ b/lib/libcrypto/bn/bn_prime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bn_prime.c,v 1.18 2017/01/29 17:49:22 beck Exp $ */
+/* $OpenBSD: bn_prime.c,v 1.19 2022/06/18 15:52:35 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -282,7 +282,7 @@ BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
if (mod == (BN_ULONG)-1)
goto err;
if (mod == 0)
- return 0;
+ return BN_is_word(a, primes[i]);
}
if (!BN_GENCB_call(cb, 1, -1))
goto err;