2 is a prime
authorNils Larsch <nils@openssl.org>
Fri, 13 Jan 2006 23:27:59 +0000 (23:27 +0000)
committerNils Larsch <nils@openssl.org>
Fri, 13 Jan 2006 23:27:59 +0000 (23:27 +0000)
PR: 1266

crypto/bn/bn_prime.c

index d03403a600d8ca7a2cd7c7ef3d06dde708a78f52..d57f6582110f6c74bec114939fa51ca4cf42a25a 100644 (file)
@@ -258,7 +258,8 @@ int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
 
        /* first look for small factors */
        if (!BN_is_odd(a))
-               return 0;
+               /* a is even => a is prime if and only if a == 2 */
+               return BN_is_word(a, 2);
        if (do_trial_division)
                {
                for (i = 1; i < NUMPRIMES; i++)