KeyFactory keyFac = KeyFactory.getInstance("DH", provider);
//Use server's public key to initiate a DHPublicKeySpec and then use
//this DHPublicKeySpec to initiate a publicKey object
BigInteger publicKey = new BigInteger(1, targetPublicKey);
DHPublicKeySpec dhKeySpec =
new DHPublicKeySpec(publicKey, modulus__, base__);
PublicKey pubKey = keyFac.generatePublic(dhKeySpec);
//Execute the first phase of DH keyagreement protocal.
keyAgreement_.doPhase(pubKey, true);