public boolean equals( Object obj) { if (!(obj instanceof DHKeyParameters)) { return false; } DHKeyParameters dhKey = (DHKeyParameters)obj; if (params == null) { return dhKey.getParameters() == null; } else { return params.equals(dhKey.getParameters()); } }
public boolean equals( Object obj) { if (!(obj instanceof DHKeyParameters)) { return false; } DHKeyParameters dhKey = (DHKeyParameters)obj; if (params == null) { return dhKey.getParameters() == null; } else { return params.equals(dhKey.getParameters()); } }
BigInteger message) if (!pub.getParameters().equals(dhParams))
if (!pub.getParameters().equals(dhParams))
/** * given a message from a given party and the corresponding public key, * calculate the next message in the agreement sequence. In this case * this will represent the shared secret. */ public BigInteger calculateAgreement( DHPublicKeyParameters pub, BigInteger message) { if (!pub.getParameters().equals(dhParams)) { throw new IllegalArgumentException("Diffie-Hellman public key has wrong parameters."); } BigInteger p = dhParams.getP(); return message.modPow(key.getX(), p).multiply(pub.getY().modPow(privateValue, p)).mod(p); } }
/** * given a short term public key from a given party calculate the next * message in the agreement sequence. */ public BigInteger calculateAgreement( CipherParameters pubKey) { DHPublicKeyParameters pub = (DHPublicKeyParameters)pubKey; if (!pub.getParameters().equals(dhParams)) { throw new IllegalArgumentException("Diffie-Hellman public key has wrong parameters."); } return pub.getY().modPow(key.getX(), dhParams.getP()); } }