- for (BigInteger n : primes) {
- if (BigInteger.ZERO.equals(modulus.mod(n))) {
- throw new GigiApiException(SprintfCommand.createSimple("Small factors check of public key: Key is divisible by {0}.", n.toString()));
- }
+ BigInteger n = modulus.gcd(primeProduct);
+ if ( !BigInteger.ONE.equals(n)) {
+ throw new GigiApiException(SprintfCommand.createSimple("Small factors check of public key: Key has known factor of {0}.", n.toString()));