github added bitLength check for GCD test
@@ -148,6 +148,8 @@ public static BigInteger createRandomBigInteger(int bitLength, SecureRandom rand
+ "ce86165a978d719ebf647f362d33fca29cd179fb42401cbaf3df0c614056f9c8"
+ "f3cfd51e474afb6bc6974f78db8aba8e9e517fded658591ab7502bd41849462f",
16);
+ private static final int SQR_MAX_SMALL = 20; // bitlength of 743 * 743
+
/**
* Return a prime number candidate of the specified bit length.
*
@@ -181,12 +183,14 @@ public static BigInteger createRandomPrime(int bitLength, int certainty, SecureR
base[base.length - 1] |= 0x01;
rv = new BigInteger(1, base);
-
+ if (bitLength > SQR_MAX_SMALL)
+ {
while (!rv.gcd(SMALL_PRIMES_PRODUCT).equals(ONE))
{
rv = rv.add(TWO);
}
}
+ }
while (!rv.isProbablePrime(certainty));
return rv;
