{
DHParameterSpec dhParams = new DHParameterSpec(p, g, privateValueSize);
String algName = "DH";
int size = p.bitLength();
new BouncyCastleProvider().setParameter(ConfigurableProvider.DH_DEFAULT_PARAMS, dhParams);
KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algName, "BC");
keyGen.initialize(dhParams.getP().bitLength());
testTwoParty("DH", size, privateValueSize, keyGen);
KeyPair aKeyPair = keyGen.generateKeyPair();
new BouncyCastleProvider().setParameter(ConfigurableProvider.DH_DEFAULT_PARAMS, null);
//
// public key encoding test
//
byte[] pubEnc = aKeyPair.getPublic().getEncoded();