libsec: fix probably_prime() endless loop for n == 3

This commit is contained in:
cinap_lenrek 2015-08-23 23:49:31 +02:00
parent 54a91861df
commit 59d16c3900

View file

@ -21,10 +21,10 @@ probably_prime(mpint *n, int nrep)
nrep = 18;
k = mptoi(n);
if(k == 2) /* 2 is prime */
return 1;
if(k < 2) /* 1 is not prime */
return 0;
if(k == 2 || k == 3) /* 2, 3 is prime */
return 1;
if((n->p[0] & 1) == 0) /* even is not prime */
return 0;