private PollRepContent(ASN1Sequence seq) { certReqId = new ASN1Integer[seq.size()]; checkAfter = new ASN1Integer[seq.size()]; reason = new PKIFreeText[seq.size()]; for (int i = 0; i != seq.size(); i++) { ASN1Sequence s = ASN1Sequence.getInstance(seq.getObjectAt(i)); certReqId[i] = ASN1Integer.getInstance(s.getObjectAt(0)); checkAfter[i] = ASN1Integer.getInstance(s.getObjectAt(1)); if (s.size() > 2) { reason[i] = PKIFreeText.getInstance(s.getObjectAt(2)); } } }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new Asn1P11SlotIdentifier(slotId)); vector.add(new DERUTF8String(label)); vector.add(new ASN1Integer(keysize)); if (publicExponent != null) { vector.add(new ASN1Integer(publicExponent)); } return new DERSequence(vector); }
public DVCSCertInfo( DVCSRequestInformation dvReqInfo, DigestInfo messageImprint, ASN1Integer serialNumber, DVCSTime responseTime) { this.dvReqInfo = dvReqInfo; this.messageImprint = messageImprint; this.serialNumber = serialNumber; this.responseTime = responseTime; }
public CertResponse( ASN1Integer certReqId, PKIStatusInfo status, CertifiedKeyPair certifiedKeyPair, ASN1OctetString rspInfo) { if (certReqId == null) { throw new IllegalArgumentException("'certReqId' cannot be null"); } if (status == null) { throw new IllegalArgumentException("'status' cannot be null"); } this.certReqId = certReqId; this.status = status; this.certifiedKeyPair = certifiedKeyPair; this.rspInfo = rspInfo; }
private McElieceCCA2PublicKey(ASN1Sequence seq) { oid = ((ASN1ObjectIdentifier)seq.getObjectAt(0)); BigInteger bigN = ((ASN1Integer)seq.getObjectAt(1)).getValue(); n = bigN.intValue(); BigInteger bigT = ((ASN1Integer)seq.getObjectAt(2)).getValue(); t = bigT.intValue(); matrixG = ((ASN1OctetString)seq.getObjectAt(3)).getOctets(); }
public RSAPrivateKeyStructure( ASN1Sequence seq) { Enumeration e = seq.getObjects(); BigInteger v = ((ASN1Integer)e.nextElement()).getValue(); if (v.intValue() != 0 && v.intValue() != 1) { throw new IllegalArgumentException("wrong version for RSA private key"); } version = v.intValue(); modulus = ((ASN1Integer)e.nextElement()).getValue(); publicExponent = ((ASN1Integer)e.nextElement()).getValue(); privateExponent = ((ASN1Integer)e.nextElement()).getValue(); prime1 = ((ASN1Integer)e.nextElement()).getValue(); prime2 = ((ASN1Integer)e.nextElement()).getValue(); exponent1 = ((ASN1Integer)e.nextElement()).getValue(); exponent2 = ((ASN1Integer)e.nextElement()).getValue(); coefficient = ((ASN1Integer)e.nextElement()).getValue(); if (e.hasMoreElements()) { otherPrimeInfos = (ASN1Sequence)e.nextElement(); } }
/** * Produce an object suitable for an ASN1OutputStream. * <pre> * ECParameters ::= SEQUENCE { * version INTEGER { ecpVer1(1) } (ecpVer1), * fieldID FieldID {{FieldTypes}}, * curve X9Curve, * base X9ECPoint, * order INTEGER, * cofactor INTEGER OPTIONAL * } * </pre> */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new ASN1Integer(1)); v.add(fieldID); v.add(new X9Curve(curve, seed)); v.add(new X9ECPoint(g)); v.add(new ASN1Integer(n)); if (h != null) { v.add(new ASN1Integer(h)); } return new DERSequence(v); }
private PBKDF2Params( ASN1Sequence seq) { Enumeration e = seq.getObjects(); octStr = (ASN1OctetString)e.nextElement(); iterationCount = (ASN1Integer)e.nextElement(); if (e.hasMoreElements()) { keyLength = (ASN1Integer)e.nextElement(); } else { keyLength = null; } }
/** * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. */ protected byte[] engineGetEncoded() throws IOException { PSSParameterSpec pssSpec = currentSpec; AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( DigestFactory.getOID(pssSpec.getDigestAlgorithm()), DERNull.INSTANCE); MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( PKCSObjectIdentifiers.id_mgf1, new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField())); return pssP.getEncoded("DER"); }
/** * @deprecated use getInstance() */ public EnvelopedData( ASN1Sequence seq) { int index = 0; version = (ASN1Integer)seq.getObjectAt(index++); Object tmp = seq.getObjectAt(index++); if (tmp instanceof ASN1TaggedObject) { originatorInfo = OriginatorInfo.getInstance((ASN1TaggedObject)tmp, false); tmp = seq.getObjectAt(index++); } recipientInfos = ASN1Set.getInstance(tmp); encryptedContentInfo = EncryptedContentInfo.getInstance(seq.getObjectAt(index++)); if(seq.size() > index) { unprotectedAttrs = ASN1Set.getInstance((ASN1TaggedObject)seq.getObjectAt(index), false); } }
private CscaMasterList( ASN1Sequence seq) { if (seq == null || seq.size() == 0) { throw new IllegalArgumentException( "null or empty sequence passed."); } if (seq.size() != 2) { throw new IllegalArgumentException( "Incorrect sequence size: " + seq.size()); } version = ASN1Integer.getInstance(seq.getObjectAt(0)); ASN1Set certSet = ASN1Set.getInstance(seq.getObjectAt(1)); certList = new Certificate[certSet.size()]; for (int i = 0; i < certList.length; i++) { certList[i] = Certificate.getInstance(certSet.getObjectAt(i)); } }
public DHDomainParameters(ASN1Integer p, ASN1Integer g, ASN1Integer q, ASN1Integer j, DHValidationParms validationParms) { if (p == null) { throw new IllegalArgumentException("'p' cannot be null"); } if (g == null) { throw new IllegalArgumentException("'g' cannot be null"); } if (q == null) { throw new IllegalArgumentException("'q' cannot be null"); } this.p = p; this.g = g; this.q = q; this.j = j; this.validationParms = validationParms; }
private CertResponse(ASN1Sequence seq) { certReqId = ASN1Integer.getInstance(seq.getObjectAt(0)); status = PKIStatusInfo.getInstance(seq.getObjectAt(1)); if (seq.size() >= 3) { if (seq.size() == 3) { ASN1Encodable o = seq.getObjectAt(2); if (o instanceof ASN1OctetString) { rspInfo = ASN1OctetString.getInstance(o); } else { certifiedKeyPair = CertifiedKeyPair.getInstance(o); } } else { certifiedKeyPair = CertifiedKeyPair.getInstance(seq.getObjectAt(2)); rspInfo = ASN1OctetString.getInstance(seq.getObjectAt(3)); } } }
private TimeStampedData(ASN1Sequence seq) { this.version = ASN1Integer.getInstance(seq.getObjectAt(0)); int index = 1; if (seq.getObjectAt(index) instanceof DERIA5String) { this.dataUri = DERIA5String.getInstance(seq.getObjectAt(index++)); } if (seq.getObjectAt(index) instanceof MetaData || seq.getObjectAt(index) instanceof ASN1Sequence) { this.metaData = MetaData.getInstance(seq.getObjectAt(index++)); } if (seq.getObjectAt(index) instanceof ASN1OctetString) { this.content = ASN1OctetString.getInstance(seq.getObjectAt(index++)); } this.temporalEvidence = Evidence.getInstance(seq.getObjectAt(index)); }
/** * create an AuthorityKeyIdentifier with the GeneralNames tag and * the serial number provided as well. */ public AuthorityKeyIdentifier( SubjectPublicKeyInfo spki, GeneralNames name, BigInteger serialNumber) { Digest digest = new SHA1Digest(); byte[] resBuf = new byte[digest.getDigestSize()]; byte[] bytes = spki.getPublicKeyData().getBytes(); digest.update(bytes, 0, bytes.length); digest.doFinal(resBuf, 0); this.keyidentifier = new DEROctetString(resBuf); this.certissuer = GeneralNames.getInstance(name.toASN1Primitive()); this.certserno = new ASN1Integer(serialNumber); }
public SignerInfo( SignerIdentifier sid, AlgorithmIdentifier digAlgorithm, ASN1Set authenticatedAttributes, AlgorithmIdentifier digEncryptionAlgorithm, ASN1OctetString encryptedDigest, ASN1Set unauthenticatedAttributes) { if (sid.isTagged()) { this.version = new ASN1Integer(3); } else { this.version = new ASN1Integer(1); } this.sid = sid; this.digAlgorithm = digAlgorithm; this.authenticatedAttributes = authenticatedAttributes; this.digEncryptionAlgorithm = digEncryptionAlgorithm; this.encryptedDigest = encryptedDigest; this.unauthenticatedAttributes = unauthenticatedAttributes; }
/** Sets the X.509 version. Note: for X509v3, use 2 here. */ public CertTemplateBuilder setVersion(int ver) { version = new ASN1Integer(ver); return this; }
/** * create a cA=true object for the given path length constraint. * * @param pathLenConstraint */ public BasicConstraints( int pathLenConstraint) { this.cA = ASN1Boolean.getInstance(true); this.pathLenConstraint = new ASN1Integer(pathLenConstraint); }
public KEKRecipientInfo( KEKIdentifier kekid, AlgorithmIdentifier keyEncryptionAlgorithm, ASN1OctetString encryptedKey) { this.version = new ASN1Integer(4); this.kekid = kekid; this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; this.encryptedKey = encryptedKey; }
/** * @deprecated use X500Name constructor */ public IssuerAndSerialNumber( X509Name name, ASN1Integer serialNumber) { this.name = X500Name.getInstance(name); this.serialNumber = serialNumber; }
private BigInteger[] derDecode( byte[] encoding) throws IOException { ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(encoding); return new BigInteger[]{ ((ASN1Integer)s.getObjectAt(0)).getValue(), ((ASN1Integer)s.getObjectAt(1)).getValue() }; }
/** * @deprecated use getInstance() method. */ public SignerInfo( ASN1Sequence seq) { Enumeration e = seq.getObjects(); version = (ASN1Integer)e.nextElement(); sid = SignerIdentifier.getInstance(e.nextElement()); digAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement()); Object obj = e.nextElement(); if (obj instanceof ASN1TaggedObject) { authenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject)obj, false); digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement()); } else { authenticatedAttributes = null; digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(obj); } encryptedDigest = DEROctetString.getInstance(e.nextElement()); if (e.hasMoreElements()) { unauthenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject)e.nextElement(), false); } else { unauthenticatedAttributes = null; } }
public AttributeCertificateHolder(X500Name issuerName, BigInteger serialNumber) { holder = new Holder(new IssuerSerial( new GeneralNames(new GeneralName(issuerName)), new ASN1Integer(serialNumber))); }
private byte[] derEncode( BigInteger r, BigInteger s) throws IOException { ASN1Integer[] rs = new ASN1Integer[]{ new ASN1Integer(r), new ASN1Integer(s) }; return new DERSequence(rs).getEncoded(ASN1Encoding.DER); }
public CertRequest( ASN1Integer certReqId, CertTemplate certTemplate, Controls controls) { this.certReqId = certReqId; this.certTemplate = certTemplate; this.controls = controls; }
/** * Create a builder for a version 3 certificate. * * @param issuer the certificate issuer * @param serial the certificate serial number * @param notBefore the date before which the certificate is not valid * @param notAfter the date after which the certificate is not valid * @param subject the certificate subject * @param publicKeyInfo the info structure for the public key to be associated with this certificate. */ public X509v3CertificateBuilder(X500Name issuer, BigInteger serial, Date notBefore, Date notAfter, X500Name subject, SubjectPublicKeyInfo publicKeyInfo) { tbsGen = new V3TBSCertificateGenerator(); tbsGen.setSerialNumber(new ASN1Integer(serial)); tbsGen.setIssuer(issuer); tbsGen.setStartDate(new Time(notBefore)); tbsGen.setEndDate(new Time(notAfter)); tbsGen.setSubject(subject); tbsGen.setSubjectPublicKeyInfo(publicKeyInfo); extGenerator = new ExtensionsGenerator(); }
public X509v2AttributeCertificateBuilder(AttributeCertificateHolder holder, AttributeCertificateIssuer issuer, BigInteger serialNumber, Date notBefore, Date notAfter) { acInfoGen = new V2AttributeCertificateInfoGenerator(); extGenerator = new ExtensionsGenerator(); acInfoGen.setHolder(holder.holder); acInfoGen.setIssuer(AttCertIssuer.getInstance(issuer.form)); acInfoGen.setSerialNumber(new ASN1Integer(serialNumber)); acInfoGen.setStartDate(new ASN1GeneralizedTime(notBefore)); acInfoGen.setEndDate(new ASN1GeneralizedTime(notAfter)); }
public IssuerAndSerialNumber( X500Name name, BigInteger serialNumber) { this.name = name; this.serialNumber = new ASN1Integer(serialNumber); }
public PBEParameter( byte[] salt, int iterations) { if (salt.length != 8) { throw new IllegalArgumentException("salt length must be 8"); } this.salt = new DEROctetString(salt); this.iterations = new ASN1Integer(iterations); }
private static CertID createCertID(DigestCalculator digCalc, X509CertificateHolder issuerCert, ASN1Integer serialNumber) throws OCSPException { try { OutputStream dgOut = digCalc.getOutputStream(); dgOut.write(issuerCert.toASN1Structure().getSubject().getEncoded(ASN1Encoding.DER)); dgOut.close(); ASN1OctetString issuerNameHash = new DEROctetString(digCalc.getDigest()); SubjectPublicKeyInfo info = issuerCert.getSubjectPublicKeyInfo(); dgOut = digCalc.getOutputStream(); dgOut.write(info.getPublicKeyData().getBytes()); dgOut.close(); ASN1OctetString issuerKeyHash = new DEROctetString(digCalc.getDigest()); return new CertID(digCalc.getAlgorithmIdentifier(), issuerNameHash, issuerKeyHash, serialNumber); } catch (Exception e) { throw new OCSPException("problem creating ID: " + e, e); } }
private static RSASSAPSSparams createPSSParams(AlgorithmIdentifier hashAlgId, int saltSize) { return new RSASSAPSSparams( hashAlgId, new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, hashAlgId), new ASN1Integer(saltSize), new ASN1Integer(1)); }
JCEElGamalPrivateKey( PrivateKeyInfo info) throws IOException { ElGamalParameter params = new ElGamalParameter((ASN1Sequence)info.getAlgorithmId().getParameters()); DERInteger derX = ASN1Integer.getInstance(info.parsePrivateKey()); this.x = derX.getValue(); this.elSpec = new ElGamalParameterSpec(params.getP(), params.getG()); }
/** * @return notYoungerThan if that's what we are, -1 otherwise */ public int notYoungerThan() { if (declaration.getTagNo() != 0) { return -1; } return ASN1Integer.getInstance(declaration, false).getValue().intValue(); }
public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); // encode <oidString> v.add(oid); // encode <n> v.add(new ASN1Integer(n)); // encode <k> v.add(new ASN1Integer(k)); // encode <field> v.add(new DEROctetString(encField)); // encode <gp> v.add(new DEROctetString(encGp)); // encode <p> v.add(new DEROctetString(encP)); // encode <h> v.add(new DEROctetString(encH)); // encode <q> ASN1EncodableVector asnQInv = new ASN1EncodableVector(); for (int i = 0; i < encqInv.length; i++) { asnQInv.add(new DEROctetString(encqInv[i])); } v.add(new DERSequence(asnQInv)); return new DERSequence(v); }
private RainbowPublicKey(ASN1Sequence seq) { // <oidString> or version if (seq.getObjectAt(0) instanceof ASN1Integer) { version = ASN1Integer.getInstance(seq.getObjectAt(0)); } else { oid = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); } docLength = ASN1Integer.getInstance(seq.getObjectAt(1)); ASN1Sequence asnCoeffQuad = ASN1Sequence.getInstance(seq.getObjectAt(2)); coeffQuadratic = new byte[asnCoeffQuad.size()][]; for (int quadSize = 0; quadSize < asnCoeffQuad.size(); quadSize++) { coeffQuadratic[quadSize] = ASN1OctetString.getInstance(asnCoeffQuad.getObjectAt(quadSize)).getOctets(); } ASN1Sequence asnCoeffSing = (ASN1Sequence)seq.getObjectAt(3); coeffSingular = new byte[asnCoeffSing.size()][]; for (int singSize = 0; singSize < asnCoeffSing.size(); singSize++) { coeffSingular[singSize] = ASN1OctetString.getInstance(asnCoeffSing.getObjectAt(singSize)).getOctets(); } ASN1Sequence asnCoeffScalar = (ASN1Sequence)seq.getObjectAt(4); coeffScalar = ASN1OctetString.getInstance(asnCoeffScalar.getObjectAt(0)).getOctets(); }
public PKIHeaderBuilder( int pvno, GeneralName sender, GeneralName recipient) { this(new ASN1Integer(pvno), sender, recipient); }
public SignerInfo( ASN1Sequence seq) { Enumeration e = seq.getObjects(); version = (ASN1Integer)e.nextElement(); issuerAndSerialNumber = IssuerAndSerialNumber.getInstance(e.nextElement()); digAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement()); Object obj = e.nextElement(); if (obj instanceof ASN1TaggedObject) { authenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject)obj, false); digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement()); } else { authenticatedAttributes = null; digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(obj); } encryptedDigest = DEROctetString.getInstance(e.nextElement()); if (e.hasMoreElements()) { unauthenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject)e.nextElement(), false); } else { unauthenticatedAttributes = null; } }
public ECGOST3410ParamSetParameters( BigInteger a, BigInteger b, BigInteger p, BigInteger q, int x, BigInteger y) { this.a = new ASN1Integer(a); this.b = new ASN1Integer(b); this.p = new ASN1Integer(p); this.q = new ASN1Integer(q); this.x = new ASN1Integer(x); this.y = new ASN1Integer(y); }
public static CRLNumber getInstance(Object o) { if (o instanceof CRLNumber) { return (CRLNumber)o; } else if (o != null) { return new CRLNumber(ASN1Integer.getInstance(o).getValue()); } return null; }
public EnvelopedData( OriginatorInfo originatorInfo, ASN1Set recipientInfos, EncryptedContentInfo encryptedContentInfo, ASN1Set unprotectedAttrs) { version = new ASN1Integer(calculateVersion(originatorInfo, recipientInfos, unprotectedAttrs)); this.originatorInfo = originatorInfo; this.recipientInfos = recipientInfos; this.encryptedContentInfo = encryptedContentInfo; this.unprotectedAttrs = unprotectedAttrs; }