AsymmetricCipherKeyPair p2 = pGen.generateKeyPair();
//
// two way
//
BasicAgreement e1 = new ECDHBasicAgreement();
BasicAgreement e2 = new ECDHBasicAgreement();
e1.init(p1.getPrivate());
e2.init(p2.getPrivate());
BigInteger k1 = e1.calculateAgreement(p2.getPublic());
BigInteger k2 = e2.calculateAgreement(p1.getPublic());
if (!k1.equals(k2))
{
return new SimpleTestResult(false, this.getName() + ": calculated agreement test failed");
}
//
// two way
//
e1 = new ECDHCBasicAgreement();
e2 = new ECDHCBasicAgreement();
e1.init(p1.getPrivate());
e2.init(p2.getPrivate());
k1 = e1.calculateAgreement(p2.getPublic());
k2 = e2.calculateAgreement(p1.getPublic());
if (!k1.equals(k2))
{
return new SimpleTestResult(false, this.getName() + ": calculated agreement test failed");
}