Fix for AVATAR_JS-87, check in known primes first

Reviewed-by: asquare
This commit is contained in:
Jean-Francois 2013-11-22 09:52:02 +01:00
parent 513e5d2a79
commit 5163e2c11e

View File

@ -210,6 +210,18 @@ public final class DiffieHellman {
}
public static void checkPrime(BigInteger prime) throws Exception {
// Is it a known Prime?
for(BigInteger bi : PRIMES.values()) {
if (bi.equals(prime)) {
return;
}
}
// is it a group?
for(BigInteger bi : WELL_KNOWN_GROUPS.values()) {
if (bi.equals(prime)) {
return;
}
}
checkSafePrimeForGenerator2(prime);
}