minor tweak to preserve L value on encoding when provided.
{
this.y = key.getY();
this.dhSpec = key.getParams();
+ if (dhSpec instanceof DHDomainParameterSpec)
+ {
+ DHDomainParameterSpec dhSp = (DHDomainParameterSpec)dhSpec;
+ this.dhPublicKey = new DHPublicKeyParameters(y, dhSp.getDomainParameters());
+ }
+ else
+ {
this.dhPublicKey = new DHPublicKeyParameters(y, new DHParameters(dhSpec.getP(), dhSpec.getG()));
}
+ }
BCDHPublicKey(
DHPublicKeyParameters params)
@@ -123,13 +131,15 @@ public BCDHPublicKey(
if (params.getL() != null)
{
this.dhSpec = new DHParameterSpec(params.getP(), params.getG(), params.getL().intValue());
+ this.dhPublicKey = new DHPublicKeyParameters(y, new DHParameters(dhSpec.getP(), dhSpec.getG(), BigInteger.valueOf(dhSpec.getL())));
}
else
{
this.dhSpec = new DHParameterSpec(params.getP(), params.getG());
- }
this.dhPublicKey = new DHPublicKeyParameters(y, new DHParameters(dhSpec.getP(), dhSpec.getG()));
}
+
+ }
else if (id.equals(X9ObjectIdentifiers.dhpublicnumber))
{
DomainParameters params = DomainParameters.getInstance(seq);
