public static DHPublicKey getInstance(Object obj) { if (obj == null || obj instanceof DHPublicKey) { return (DHPublicKey)obj; } if (obj instanceof ASN1Integer) { return new DHPublicKey((ASN1Integer)obj); } throw new IllegalArgumentException("Invalid DHPublicKey: " + obj.getClass().getName()); }
/** * Return a DHPublicKey from the passed in tagged object. * * @param obj a tagged object. * @param explicit true if the contents of the object is explictly tagged, false otherwise. * @return a DHPublicKey */ public static DHPublicKey getInstance(ASN1TaggedObject obj, boolean explicit) { return getInstance(ASN1Integer.getInstance(obj, explicit)); }
AsymmetricKeyParameter getPublicKeyParameters(SubjectPublicKeyInfo keyInfo, Object defaultParams) throws IOException { DHPublicKey dhPublicKey = DHPublicKey.getInstance(keyInfo.parsePublicKey()); BigInteger y = dhPublicKey.getY(); DomainParameters dhParams = DomainParameters.getInstance(keyInfo.getAlgorithm().getParameters()); BigInteger p = dhParams.getP(); BigInteger g = dhParams.getG(); BigInteger q = dhParams.getQ(); BigInteger j = null; if (dhParams.getJ() != null) { j = dhParams.getJ(); } DHValidationParameters validation = null; ValidationParams dhValidationParms = dhParams.getValidationParams(); if (dhValidationParms != null) { byte[] seed = dhValidationParms.getSeed(); BigInteger pgenCounter = dhValidationParms.getPgenCounter(); // TODO Check pgenCounter size? validation = new DHValidationParameters(seed, pgenCounter.intValue()); } return new DHPublicKeyParameters(y, new DHParameters(p, g, q, j, validation)); } }
DHPublicKey dhPublicKey = DHPublicKey.getInstance(keyInfo.parsePublicKey()); BigInteger y = dhPublicKey.getY().getValue();
public static DHPublicKey getInstance(ASN1TaggedObject obj, boolean explicit) { return getInstance(ASN1Integer.getInstance(obj, explicit)); }
/** * Return a DHPublicKey from the passed in object. * * @param obj an object for conversion or a byte[]. * @return a DHPublicKey */ public static DHPublicKey getInstance(Object obj) { if (obj == null || obj instanceof DHPublicKey) { return (DHPublicKey)obj; } if (obj instanceof ASN1Integer) { return new DHPublicKey((ASN1Integer)obj); } throw new IllegalArgumentException("Invalid DHPublicKey: " + obj.getClass().getName()); }