diff options
| author | tb <> | 2022-06-18 15:52:35 +0000 |
|---|---|---|
| committer | tb <> | 2022-06-18 15:52:35 +0000 |
| commit | 0331711a5cf4c451e85f6a7ddae090f1f2374c7e (patch) | |
| tree | 151eb3f95ee74e829df842540b6413d18db542bb /src | |
| parent | bf9b69a49580f3d785f8e1ea109c7c3e83dfd3fb (diff) | |
| download | openbsd-0331711a5cf4c451e85f6a7ddae090f1f2374c7e.tar.gz openbsd-0331711a5cf4c451e85f6a7ddae090f1f2374c7e.tar.bz2 openbsd-0331711a5cf4c451e85f6a7ddae090f1f2374c7e.zip | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_prime.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c index e78c5686ab..9ab89695d8 100644 --- a/src/lib/libcrypto/bn/bn_prime.c +++ b/src/lib/libcrypto/bn/bn_prime.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_prime.c,v 1.18 2017/01/29 17:49:22 beck Exp $ */ | 1 | /* $OpenBSD: bn_prime.c,v 1.19 2022/06/18 15:52:35 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -282,7 +282,7 @@ BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, | |||
| 282 | if (mod == (BN_ULONG)-1) | 282 | if (mod == (BN_ULONG)-1) |
| 283 | goto err; | 283 | goto err; |
| 284 | if (mod == 0) | 284 | if (mod == 0) |
| 285 | return 0; | 285 | return BN_is_word(a, primes[i]); |
| 286 | } | 286 | } |
| 287 | if (!BN_GENCB_call(cb, 1, -1)) | 287 | if (!BN_GENCB_call(cb, 1, -1)) |
| 288 | goto err; | 288 | goto err; |
