Skip to content

Commit 35db88c

Browse files
committed
Use improved safe-prime generation
1 parent 0870910 commit 35db88c

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

core/src/main/java/org/bouncycastle/crypto/generators/CramerShoupParametersGenerator.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,7 @@ private static class ParametersHelper
8686
*/
8787
static BigInteger[] generateSafePrimes(int size, int certainty, SecureRandom random)
8888
{
89-
BigInteger p, q;
90-
int qLength = size - 1;
91-
92-
for (; ; )
93-
{
94-
q = BigIntegers.createRandomPrime(qLength, 2, random);
95-
p = q.shiftLeft(1).add(ONE);
96-
if (p.isProbablePrime(certainty) && (certainty <= 2 || q.isProbablePrime(certainty)))
97-
{
98-
break;
99-
}
100-
}
101-
102-
return new BigInteger[]{p, q};
89+
return DHParametersHelper.generateSafePrimes(size, certainty, random, false);
10390
}
10491

10592
static BigInteger selectGenerator(BigInteger p, SecureRandom random)

0 commit comments

Comments
 (0)