public void test(TestHarness harness)
{
try
{
// Alice side
DHParameterSpec spec1 = new DHParameterSpec(skip1024Modulus, skip1024Base);
harness.verbose("*** Generating Alice's Diffie-Hellman key-pair");
KeyPairGenerator aliceKPG = KeyPairGenerator.getInstance("DH");
aliceKPG.initialize(spec1);
KeyPair aliceKP = aliceKPG.generateKeyPair();
harness.verbose("*** Initializing Alice's Diffie-Hellman key-agreement");
KeyAgreement aliceKA = KeyAgreement.getInstance("DH");
aliceKA.init(aliceKP.getPrivate());
harness.verbose("*** Alice sends Bob her encoded key...");
byte[] alicePubKEnc = aliceKP.getPublic().getEncoded();
// Bob side
KeyFactory bobKF = KeyFactory.getInstance("DH");
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(alicePubKEnc);
PublicKey alicePubK = bobKF.generatePublic(x509KeySpec);
// Bob gets the DH parameters associated with Alice's public key.
// He MUST use the same parameters when generating his own key-pair
DHParameterSpec spec2 = ((DHPublicKey) alicePubK).getParams();
harness.verbose("*** Generating Bob's Diffie-Hellman key-pair");
KeyPairGenerator bobKPG = KeyPairGenerator.getInstance("DH");
bobKPG.initialize(spec2);
KeyPair bobKP = bobKPG.generateKeyPair();