public boolean equals( Object obj) { if (!(obj instanceof DHParameters)) { return false; } DHParameters pm = (DHParameters)obj; if (this.getQ() != null) { if (!this.getQ().equals(pm.getQ())) { return false; } } else { if (pm.getQ() != null) { return false; } } return pm.getP().equals(p) && pm.getG().equals(g); }
public boolean equals( Object obj) { if (!(obj instanceof DHParameters)) { return false; } DHParameters pm = (DHParameters)obj; if (this.getQ() != null) { if (!this.getQ().equals(pm.getQ())) { return false; } } else { if (pm.getQ() != null) { return false; } } return pm.getP().equals(p) && pm.getG().equals(g); }
private BigInteger validate(BigInteger y, DHParameters dhParams) { if (y == null) { throw new NullPointerException("y value cannot be null"); } // TLS check if (y.compareTo(TWO) < 0 || y.compareTo(dhParams.getP().subtract(TWO)) > 0) { throw new IllegalArgumentException("invalid DH public key"); } if (dhParams.getQ() != null) { if (ONE.equals(y.modPow(dhParams.getQ(), dhParams.getP()))) { return y; } throw new IllegalArgumentException("Y value does not appear to be in correct group"); } else { return y; // we can't validate without Q. } }
BigInteger xInverse = x.modInverse(DH_GROUP_PARAMETERS.getQ()); BigInteger i = iDoubleBlind.modPow(xInverse, DH_GROUP_PARAMETERS.getP());
BigInteger calculatePrivate(DHParameters dhParams, SecureRandom random) { BigInteger p = dhParams.getP(); int limit = dhParams.getL(); if (limit != 0) { return new BigInteger(limit, random).setBit(limit - 1); } BigInteger min = TWO; int m = dhParams.getM(); if (m != 0) { min = ONE.shiftLeft(m - 1); } BigInteger max = p.subtract(TWO); BigInteger q = dhParams.getQ(); if (q != null) { max = q.subtract(TWO); } return BigIntegers.createRandomInRange(min, max, random); }
BigInteger q = dhParams.getQ(); if (q == null)