public static DHParameter getInstance( Object obj) { if (obj instanceof DHParameter) { return (DHParameter)obj; } if (obj != null) { return new DHParameter(ASN1Sequence.getInstance(obj)); } return null; }
public static DHParameter getInstance( Object obj) { if (obj instanceof DHParameter) { return (DHParameter)obj; } if (obj != null) { return new DHParameter(ASN1Sequence.getInstance(obj)); } return null; }
public byte[] getEncoded() { if (info != null) { return KeyUtil.getEncodedSubjectPublicKeyInfo(info); } return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.dhKeyAgreement, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL())), new ASN1Integer(y)); }
/** * Return the PKCS#3 ASN.1 structure DHParameter. * <p> * <pre> * DHParameter ::= SEQUENCE { * prime INTEGER, -- p * base INTEGER, -- g * privateValueLength INTEGER OPTIONAL} * </pre> */ protected byte[] engineGetEncoded() { DHParameter dhP = new DHParameter(currentSpec.getP(), currentSpec.getG(), currentSpec.getL()); try { return dhP.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new RuntimeException("Error encoding DHParameters"); } }
/** * Return a PKCS8 representation of the key. The sequence returned * represents a full PrivateKeyInfo object. * * @return a PKCS8 representation of the key. */ public byte[] getEncoded() { try { if (info != null) { return info.getEncoded(ASN1Encoding.DER); } PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.dhKeyAgreement, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL())), new ASN1Integer(getX())); return info.getEncoded(ASN1Encoding.DER); } catch (IOException e) { return null; } }
public byte[] getEncoded() { if (info != null) { return KeyUtil.getEncodedSubjectPublicKeyInfo(info); } if (dhSpec instanceof DHDomainParameterSpec && ((DHDomainParameterSpec)dhSpec).getQ() != null) { DHParameters params = ((DHDomainParameterSpec)dhSpec).getDomainParameters(); DHValidationParameters validationParameters = params.getValidationParameters(); ValidationParams vParams = null; if (validationParameters != null) { vParams = new ValidationParams(validationParameters.getSeed(), validationParameters.getCounter()); } return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.dhpublicnumber, new DomainParameters(params.getP(), params.getG(), params.getQ(), params.getJ(), vParams).toASN1Primitive()), new ASN1Integer(y)); } return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.dhKeyAgreement, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL()).toASN1Primitive()), new ASN1Integer(y)); }
info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.dhKeyAgreement, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL()).toASN1Primitive()), new ASN1Integer(getX()));
DHParameter params = new DHParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters()); DERInteger derX = (DERInteger)keyInfo.getPrivateKey();
DHParameter params = new DHParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters()); DERInteger derX = (DERInteger)keyInfo.getPrivateKey();