aboutsummaryrefslogtreecommitdiff
path: root/crypto/bn/bn_prime.c
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2017-04-20 09:20:50 -0700
committerRich Salz <rsalz@openssl.org>2017-04-20 16:10:10 -0400
commit6e64c560663f5542fdc2580bb7b030c19b6919e4 (patch)
treecab54406234402d95b8f1fae5ad7b57db7f7cd28 /crypto/bn/bn_prime.c
parentc0452248ea1a59a41023a4765ef7d9825e80a62b (diff)
downloadopenssl-6e64c560663f5542fdc2580bb7b030c19b6919e4.zip
openssl-6e64c560663f5542fdc2580bb7b030c19b6919e4.tar.gz
openssl-6e64c560663f5542fdc2580bb7b030c19b6919e4.tar.bz2
Small primes are primes too.
Previously, BN_is_prime_fasttest_ex, when doing trial-division, would check whether the candidate is a multiple of a number of small primes and, if so, reject it. However, three is a multiple of three yet is still a prime number. This change accepts small primes as prime when doing trial-division. Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3264)
Diffstat (limited to 'crypto/bn/bn_prime.c')
-rw-r--r--crypto/bn/bn_prime.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c
index bbb124f..9295aeb 100644
--- a/crypto/bn/bn_prime.c
+++ b/crypto/bn/bn_prime.c
@@ -176,7 +176,7 @@ int 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;