private EncryptedValue(Asn1Sequence seq) { int index = 0; while (seq[index] is Asn1TaggedObject) { Asn1TaggedObject tObj = (Asn1TaggedObject)seq[index]; switch (tObj.TagNo) { case 0: intendedAlg = AlgorithmIdentifier.GetInstance(tObj, false); break; case 1: symmAlg = AlgorithmIdentifier.GetInstance(tObj, false); break; case 2: encSymmKey = DerBitString.GetInstance(tObj, false); break; case 3: keyAlg = AlgorithmIdentifier.GetInstance(tObj, false); break; case 4: valueHint = Asn1OctetString.GetInstance(tObj, false); break; } ++index; } encValue = DerBitString.GetInstance(seq[index]); }
private RevDetails(Asn1Sequence seq) { certDetails = CertTemplate.GetInstance(seq[0]); crlEntryDetails = seq.Count <= 1 ? null : X509Extensions.GetInstance(seq[1]); }
public KekIdentifier( Asn1Sequence seq) { keyIdentifier = (Asn1OctetString) seq[0]; switch (seq.Count) { case 1: break; case 2: if (seq[1] is DerGeneralizedTime) { date = (DerGeneralizedTime) seq[1]; } else { other = OtherKeyAttribute.GetInstance(seq[2]); } break; case 3: date = (DerGeneralizedTime) seq[1]; other = OtherKeyAttribute.GetInstance(seq[2]); break; default: throw new ArgumentException("Invalid KekIdentifier"); } }
public RsassaPssParameters( Asn1Sequence seq) { hashAlgorithm = DefaultHashAlgorithm; maskGenAlgorithm = DefaultMaskGenFunction; saltLength = DefaultSaltLength; trailerField = DefaultTrailerField; for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject o = (Asn1TaggedObject)seq[i]; switch (o.TagNo) { case 0: hashAlgorithm = AlgorithmIdentifier.GetInstance(o, true); break; case 1: maskGenAlgorithm = AlgorithmIdentifier.GetInstance(o, true); break; case 2: saltLength = DerInteger.GetInstance(o, true); break; case 3: trailerField = DerInteger.GetInstance(o, true); break; default: throw new ArgumentException("unknown tag"); } } }
private EssCertIDv2( Asn1Sequence seq) { if (seq.Count > 3) throw new ArgumentException("Bad sequence size: " + seq.Count, "seq"); int count = 0; if (seq[0] is Asn1OctetString) { // Default value this.hashAlgorithm = DefaultAlgID; } else { this.hashAlgorithm = AlgorithmIdentifier.GetInstance(seq[count++].ToAsn1Object()); } this.certHash = Asn1OctetString.GetInstance(seq[count++].ToAsn1Object()).GetOctets(); if (seq.Count > count) { this.issuerSerial = IssuerSerial.GetInstance( Asn1Sequence.GetInstance(seq[count].ToAsn1Object())); } }
/** * Constructor from Asn1Sequence. * <p/> * The sequence is of type CertificatePair: * <p/> * <pre> * CertificatePair ::= SEQUENCE { * forward [0] Certificate OPTIONAL, * reverse [1] Certificate OPTIONAL, * -- at least one of the pair shall be present -- } * </pre> * * @param seq The ASN.1 sequence. */ private CertificatePair( Asn1Sequence seq) { if (seq.Count != 1 && seq.Count != 2) { throw new ArgumentException("Bad sequence size: " + seq.Count, "seq"); } foreach (object obj in seq) { Asn1TaggedObject o = Asn1TaggedObject.GetInstance(obj); if (o.TagNo == 0) { forward = X509CertificateStructure.GetInstance(o, true); } else if (o.TagNo == 1) { reverse = X509CertificateStructure.GetInstance(o, true); } else { throw new ArgumentException("Bad tag number: " + o.TagNo); } } }
public PublicKeyAndChallenge( Asn1Sequence seq) { pkacSeq = seq; spki = SubjectPublicKeyInfo.GetInstance(seq[0]); challenge = DerIA5String.GetInstance(seq[1]); }
public SemanticsInformation( Asn1Sequence seq) { if (seq.Count < 1) { throw new ArgumentException("no objects in SemanticsInformation"); } IEnumerator e = seq.GetEnumerator(); e.MoveNext(); object obj = e.Current; if (obj is DerObjectIdentifier) { semanticsIdentifier = DerObjectIdentifier.GetInstance(obj); if (e.MoveNext()) { obj = e.Current; } else { obj = null; } } if (obj != null) { Asn1Sequence generalNameSeq = Asn1Sequence.GetInstance(obj ); nameRegistrationAuthorities = new GeneralName[generalNameSeq.Count]; for (int i= 0; i < generalNameSeq.Count; i++) { nameRegistrationAuthorities[i] = GeneralName.GetInstance(generalNameSeq[i]); } } }
public RevocationValues( IEnumerable crlVals, IEnumerable ocspVals, OtherRevVals otherRevVals) { //if (otherRevVals == null) // throw new ArgumentNullException("otherRevVals"); if (crlVals != null) { if (!CollectionUtilities.CheckElementsAreOfType(crlVals, typeof(CertificateList))) throw new ArgumentException("Must contain only 'CertificateList' objects", "crlVals"); this.crlVals = new DerSequence( Asn1EncodableVector.FromEnumerable(crlVals)); } if (ocspVals != null) { if (!CollectionUtilities.CheckElementsAreOfType(ocspVals, typeof(BasicOcspResponse))) throw new ArgumentException("Must contain only 'BasicOcspResponse' objects", "ocspVals"); this.ocspVals = new DerSequence( Asn1EncodableVector.FromEnumerable(ocspVals)); } this.otherRevVals = otherRevVals; }
private PbmParameter(Asn1Sequence seq) { salt = Asn1OctetString.GetInstance(seq[0]); owf = AlgorithmIdentifier.GetInstance(seq[1]); iterationCount = DerInteger.GetInstance(seq[2]); mac = AlgorithmIdentifier.GetInstance(seq[3]); }
public X9ECParameters( Asn1Sequence seq) { if (!(seq[0] is DerInteger) || !((DerInteger) seq[0]).Value.Equals(BigInteger.One)) { throw new ArgumentException("bad version in X9ECParameters"); } X9Curve x9c = new X9Curve( X9FieldID.GetInstance(seq[1]), Asn1Sequence.GetInstance(seq[2])); this.curve = x9c.Curve; object p = seq[3]; if (p is X9ECPoint) { this.g = ((X9ECPoint)p); } else { this.g = new X9ECPoint(curve, (Asn1OctetString)p); } this.n = ((DerInteger)seq[4]).Value; this.seed = x9c.GetSeed(); if (seq.Count == 6) { this.h = ((DerInteger)seq[5]).Value; } }
public Pbkdf2Params( Asn1Sequence seq) { if (seq.Count < 2 || seq.Count > 4) throw new ArgumentException("Wrong number of elements in sequence", "seq"); this.octStr = (Asn1OctetString)seq[0]; this.iterationCount = (DerInteger)seq[1]; Asn1Encodable kl = null, d = null; if (seq.Count > 3) { kl = seq[2]; d = seq[3]; } else if (seq.Count > 2) { if (seq[2] is DerInteger) { kl = seq[2]; } else { d = seq[2]; } } if (kl != null) { keyLength = (DerInteger)kl; } if (d != null) { prf = AlgorithmIdentifier.GetInstance(d); } }
private void checkConstruction( NameOrPseudonym id, string pseudonym, DirectoryString surname, Asn1Sequence givenName) { checkValues(id, pseudonym, surname, givenName); id = NameOrPseudonym.GetInstance(id); checkValues(id, pseudonym, surname, givenName); Asn1InputStream aIn = new Asn1InputStream(id.ToAsn1Object().GetEncoded()); if (surname != null) { Asn1Sequence seq = (Asn1Sequence) aIn.ReadObject(); id = NameOrPseudonym.GetInstance(seq); } else { IAsn1String s = (IAsn1String) aIn.ReadObject(); id = NameOrPseudonym.GetInstance(s); } checkValues(id, pseudonym, surname, givenName); }
private PrivateKeyInfo( Asn1Sequence seq) { IEnumerator e = seq.GetEnumerator(); e.MoveNext(); IBigInteger version = ((DerInteger) e.Current).Value; if (version.IntValue != 0) { throw new ArgumentException("wrong version for private key info"); } e.MoveNext(); algID = AlgorithmIdentifier.GetInstance(e.Current); try { e.MoveNext(); Asn1OctetString data = (Asn1OctetString) e.Current; privKey = Asn1Object.FromByteArray(data.GetOctets()); } catch (IOException) { throw new ArgumentException("Error recoverying private key from sequence"); } if (e.MoveNext()) { attributes = Asn1Set.GetInstance((Asn1TaggedObject) e.Current, false); } }
public SingleResponse( Asn1Sequence seq) { this.certID = CertID.GetInstance(seq[0]); this.certStatus = CertStatus.GetInstance(seq[1]); this.thisUpdate = (DerGeneralizedTime)seq[2]; if (seq.Count > 4) { this.nextUpdate = DerGeneralizedTime.GetInstance( (Asn1TaggedObject) seq[3], true); this.singleExtensions = X509Extensions.GetInstance( (Asn1TaggedObject) seq[4], true); } else if (seq.Count > 3) { Asn1TaggedObject o = (Asn1TaggedObject) seq[3]; if (o.TagNo == 0) { this.nextUpdate = DerGeneralizedTime.GetInstance(o, true); } else { this.singleExtensions = X509Extensions.GetInstance(o, true); } } }
/** * Creates a new <code>NoticeReference</code> instance. * * @param orgName a <code>string</code> value * @param numbers an <code>Asn1Sequence</code> value */ public NoticeReference( string orgName, Asn1Sequence numbers) { organization = new DisplayText(orgName); noticeNumbers = numbers; }
private CertifiedKeyPair(Asn1Sequence seq) { certOrEncCert = CertOrEncCert.GetInstance(seq[0]); if (seq.Count >= 2) { if (seq.Count == 2) { Asn1TaggedObject tagged = Asn1TaggedObject.GetInstance(seq[1]); if (tagged.TagNo == 0) { privateKey = EncryptedValue.GetInstance(tagged.GetObject()); } else { publicationInfo = PkiPublicationInfo.GetInstance(tagged.GetObject()); } } else { privateKey = EncryptedValue.GetInstance(Asn1TaggedObject.GetInstance(seq[1])); publicationInfo = PkiPublicationInfo.GetInstance(Asn1TaggedObject.GetInstance(seq[2])); } } }
private V2Form( Asn1Sequence seq) { if (seq.Count > 3) { throw new ArgumentException("Bad sequence size: " + seq.Count); } int index = 0; if (!(seq[0] is Asn1TaggedObject)) { index++; this.issuerName = GeneralNames.GetInstance(seq[0]); } for (int i = index; i != seq.Count; i++) { Asn1TaggedObject o = Asn1TaggedObject.GetInstance(seq[i]); if (o.TagNo == 0) { baseCertificateID = IssuerSerial.GetInstance(o, false); } else if (o.TagNo == 1) { objectDigestInfo = ObjectDigestInfo.GetInstance(o, false); } else { throw new ArgumentException("Bad tag number: " + o.TagNo); } } }
public RsaesOaepParameters( Asn1Sequence seq) { hashAlgorithm = DefaultHashAlgorithm; maskGenAlgorithm = DefaultMaskGenFunction; pSourceAlgorithm = DefaultPSourceAlgorithm; for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject o = (Asn1TaggedObject)seq[i]; switch (o.TagNo) { case 0: hashAlgorithm = AlgorithmIdentifier.GetInstance(o, true); break; case 1: maskGenAlgorithm = AlgorithmIdentifier.GetInstance(o, true); break; case 2: pSourceAlgorithm = AlgorithmIdentifier.GetInstance(o, true); break; default: throw new ArgumentException("unknown tag"); } } }
private AttributeCertificateInfo( Asn1Sequence seq) { if (seq.Count < 7 || seq.Count > 9) { throw new ArgumentException("Bad sequence size: " + seq.Count); } this.version = DerInteger.GetInstance(seq[0]); this.holder = Holder.GetInstance(seq[1]); this.issuer = AttCertIssuer.GetInstance(seq[2]); this.signature = AlgorithmIdentifier.GetInstance(seq[3]); this.serialNumber = DerInteger.GetInstance(seq[4]); this.attrCertValidityPeriod = AttCertValidityPeriod.GetInstance(seq[5]); this.attributes = Asn1Sequence.GetInstance(seq[6]); for (int i = 7; i < seq.Count; i++) { Asn1Encodable obj = (Asn1Encodable) seq[i]; if (obj is DerBitString) { this.issuerUniqueID = DerBitString.GetInstance(seq[i]); } else if (obj is Asn1Sequence || obj is X509Extensions) { this.extensions = X509Extensions.GetInstance(seq[i]); } } }
private CertResponse(Asn1Sequence seq) { certReqId = DerInteger.GetInstance(seq[0]); status = PkiStatusInfo.GetInstance(seq[1]); if (seq.Count >= 3) { if (seq.Count == 3) { Asn1Encodable o = seq[2]; if (o is Asn1OctetString) { rspInfo = Asn1OctetString.GetInstance(o); } else { certifiedKeyPair = CertifiedKeyPair.GetInstance(o); } } else { certifiedKeyPair = CertifiedKeyPair.GetInstance(seq[2]); rspInfo = Asn1OctetString.GetInstance(seq[3]); } } }
private CrlOcspRef( Asn1Sequence seq) { if (seq == null) throw new ArgumentNullException("seq"); foreach (Asn1TaggedObject taggedObj in seq) { Asn1Object asn1Obj = taggedObj.GetObject(); switch (taggedObj.TagNo) { case 0: this.crlids = CrlListID.GetInstance(asn1Obj); break; case 1: this.ocspids = OcspListID.GetInstance(asn1Obj); break; case 2: this.otherRev = OtherRevRefs.GetInstance(asn1Obj); break; default: throw new ArgumentException("Illegal tag in CrlOcspRef", "seq"); } } }
public PkiStatusInfo( Asn1Sequence seq) { this.status = DerInteger.GetInstance(seq[0]); this.statusString = null; this.failInfo = null; if (seq.Count > 2) { this.statusString = PkiFreeText.GetInstance(seq[1]); this.failInfo = DerBitString.GetInstance(seq[2]); } else if (seq.Count > 1) { object obj = seq[1]; if (obj is DerBitString) { this.failInfo = DerBitString.GetInstance(obj); } else { this.statusString = PkiFreeText.GetInstance(obj); } } }
private GeneralSubtree( Asn1Sequence seq) { baseName = GeneralName.GetInstance(seq[0]); switch (seq.Count) { case 1: break; case 2: { Asn1TaggedObject o = Asn1TaggedObject.GetInstance(seq[1]); switch (o.TagNo) { case 0: minimum = DerInteger.GetInstance(o, false); break; case 1: maximum = DerInteger.GetInstance(o, false); break; default: throw new ArgumentException("Bad tag number: " + o.TagNo); } break; } case 3: { minimum = DerInteger.GetInstance(Asn1TaggedObject.GetInstance(seq[1])); maximum = DerInteger.GetInstance(Asn1TaggedObject.GetInstance(seq[2])); break; } default: throw new ArgumentException("Bad sequence size: " + seq.Count); } }
public CompressedData( Asn1Sequence seq) { this.version = (DerInteger) seq[0]; this.compressionAlgorithm = AlgorithmIdentifier.GetInstance(seq[1]); this.encapContentInfo = ContentInfo.GetInstance(seq[2]); }
public OriginatorInfo( Asn1Sequence seq) { switch (seq.Count) { case 0: // empty break; case 1: Asn1TaggedObject o = (Asn1TaggedObject) seq[0]; switch (o.TagNo) { case 0 : certs = Asn1Set.GetInstance(o, false); break; case 1 : crls = Asn1Set.GetInstance(o, false); break; default: throw new ArgumentException("Bad tag in OriginatorInfo: " + o.TagNo); } break; case 2: certs = Asn1Set.GetInstance((Asn1TaggedObject) seq[0], false); crls = Asn1Set.GetInstance((Asn1TaggedObject) seq[1], false); break; default: throw new ArgumentException("OriginatorInfo too big"); } }
public PolicyInformation( DerObjectIdentifier policyIdentifier, Asn1Sequence policyQualifiers) { this.policyIdentifier = policyIdentifier; this.policyQualifiers = policyQualifiers; }
/** * Constructor from Asn1Sequence. * <p/> * <p/> * <pre> * NamingAuthority ::= SEQUENCE * { * namingAuthorityID OBJECT IDENTIFIER OPTIONAL, * namingAuthorityUrl IA5String OPTIONAL, * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL * } * </pre> * * @param seq The ASN.1 sequence. */ private NamingAuthority( Asn1Sequence seq) { if (seq.Count > 3) throw new ArgumentException("Bad sequence size: " + seq.Count); IEnumerator e = seq.GetEnumerator(); if (e.MoveNext()) { Asn1Encodable o = (Asn1Encodable) e.Current; if (o is DerObjectIdentifier) { namingAuthorityID = (DerObjectIdentifier) o; } else if (o is DerIA5String) { namingAuthorityUrl = DerIA5String.GetInstance(o).GetString(); } else if (o is IAsn1String) { namingAuthorityText = DirectoryString.GetInstance(o); } else { throw new ArgumentException("Bad object encountered: " + o.GetType().Name); } } if (e.MoveNext()) { Asn1Encodable o = (Asn1Encodable) e.Current; if (o is DerIA5String) { namingAuthorityUrl = DerIA5String.GetInstance(o).GetString(); } else if (o is IAsn1String) { namingAuthorityText = DirectoryString.GetInstance(o); } else { throw new ArgumentException("Bad object encountered: " + o.GetType().Name); } } if (e.MoveNext()) { Asn1Encodable o = (Asn1Encodable) e.Current; if (o is IAsn1String) { namingAuthorityText = DirectoryString.GetInstance(o); } else { throw new ArgumentException("Bad object encountered: " + o.GetType().Name); } } }
public OcspListID( params OcspResponsesID[] ocspResponses) { if (ocspResponses == null) throw new ArgumentNullException("ocspResponses"); this.ocspResponses = new DerSequence(ocspResponses); }
public CompleteCertificateRefs( params OtherCertID[] otherCertIDs) { if (otherCertIDs == null) throw new ArgumentNullException("otherCertIDs"); this.otherCertIDs = new DerSequence(otherCertIDs); }
public static ResponseData GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
public static TbsCertificateStructure GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
/** * return an AuthEnvelopedData object from a tagged object. * * @param obj the tagged object holding the object we want. * @param isExplicit true if the object is meant to be explicitly * tagged false otherwise. * @throws ArgumentException if the object held by the * tagged object cannot be converted. */ public static AuthEnvelopedData GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
/** * Constructor from Asn1Sequence. * <p/> * <p/> * <pre> * NamingAuthority ::= SEQUENCE * { * namingAuthorityID OBJECT IDENTIFIER OPTIONAL, * namingAuthorityUrl IA5String OPTIONAL, * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL * } * </pre> * * @param seq The ASN.1 sequence. */ private NamingAuthority( Asn1Sequence seq) { if (seq.Count > 3) { throw new ArgumentException("Bad sequence size: " + seq.Count); } IEnumerator e = seq.GetEnumerator(); if (e.MoveNext()) { Asn1Encodable o = (Asn1Encodable)e.Current; if (o is DerObjectIdentifier) { namingAuthorityID = (DerObjectIdentifier)o; } else if (o is DerIA5String) { namingAuthorityUrl = DerIA5String.GetInstance(o).GetString(); } else if (o is IAsn1String) { namingAuthorityText = DirectoryString.GetInstance(o); } else { throw new ArgumentException("Bad object encountered: " + o.GetType().Name); } } if (e.MoveNext()) { Asn1Encodable o = (Asn1Encodable)e.Current; if (o is DerIA5String) { namingAuthorityUrl = DerIA5String.GetInstance(o).GetString(); } else if (o is IAsn1String) { namingAuthorityText = DirectoryString.GetInstance(o); } else { throw new ArgumentException("Bad object encountered: " + o.GetType().Name); } } if (e.MoveNext()) { Asn1Encodable o = (Asn1Encodable)e.Current; if (o is IAsn1String) { namingAuthorityText = DirectoryString.GetInstance(o); } else { throw new ArgumentException("Bad object encountered: " + o.GetType().Name); } } }
public static RsaPublicKeyStructure GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
public static DHValidationParms GetInstance(Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
public static DHDomainParameters GetInstance(Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
public OriginatorPublicKey( Asn1Sequence seq) { this.mAlgorithm = AlgorithmIdentifier.GetInstance(seq[0]); this.mPublicKey = DerBitString.GetInstance(seq[1]); }
internal AttributeCertificateHolder( Asn1Sequence seq) { holder = Holder.GetInstance(seq); }
/** * return an OriginatorPublicKey object from a tagged object. * * @param obj the tagged object holding the object we want. * @param explicitly true if the object is meant to be explicitly * tagged false otherwise. * @exception ArgumentException if the object held by the * tagged object cannot be converted. */ public static OriginatorPublicKey GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
public static PkiStatusInfo GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
internal static void PrepareNextCertB1(int i, IList[] policyNodes, string id_p, IDictionary m_idp, X509Certificate cert) { bool flag = false; IEnumerator enumerator = policyNodes[i].GetEnumerator(); while (enumerator.MoveNext()) { PkixPolicyNode pkixPolicyNode = (PkixPolicyNode)enumerator.Current; if (pkixPolicyNode.ValidPolicy.Equals(id_p)) { flag = true; pkixPolicyNode.ExpectedPolicies = (ISet)m_idp[id_p]; break; } } if (!flag) { enumerator = policyNodes[i].GetEnumerator(); while (enumerator.MoveNext()) { PkixPolicyNode pkixPolicyNode2 = (PkixPolicyNode)enumerator.Current; if (PkixCertPathValidatorUtilities.ANY_POLICY.Equals(pkixPolicyNode2.ValidPolicy)) { ISet policyQualifiers = null; Asn1Sequence asn1Sequence = null; try { asn1Sequence = Asn1Sequence.GetInstance(PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.CertificatePolicies)); } catch (Exception innerException) { throw new Exception("Certificate policies cannot be decoded.", innerException); } IEnumerator enumerator2 = asn1Sequence.GetEnumerator(); while (enumerator2.MoveNext()) { PolicyInformation policyInformation = null; try { policyInformation = PolicyInformation.GetInstance(enumerator2.Current); } catch (Exception innerException2) { throw new Exception("Policy information cannot be decoded.", innerException2); } if (PkixCertPathValidatorUtilities.ANY_POLICY.Equals(policyInformation.PolicyIdentifier.Id)) { try { policyQualifiers = PkixCertPathValidatorUtilities.GetQualifierSet(policyInformation.PolicyQualifiers); break; } catch (PkixCertPathValidatorException cause) { throw new PkixCertPathValidatorException("Policy qualifier info set could not be built.", cause); } } } bool critical = false; ISet criticalExtensionOids = cert.GetCriticalExtensionOids(); if (criticalExtensionOids != null) { critical = criticalExtensionOids.Contains(X509Extensions.CertificatePolicies.Id); } PkixPolicyNode parent = pkixPolicyNode2.Parent; if (PkixCertPathValidatorUtilities.ANY_POLICY.Equals(parent.ValidPolicy)) { PkixPolicyNode pkixPolicyNode3 = new PkixPolicyNode(Platform.CreateArrayList(), i, (ISet)m_idp[id_p], parent, policyQualifiers, id_p, critical); parent.AddChild(pkixPolicyNode3); policyNodes[i].Add(pkixPolicyNode3); return; } break; } } } }
public static GeneralSubtree GetInstance( Asn1TaggedObject o, bool isExplicit) { return(new GeneralSubtree(Asn1Sequence.GetInstance(o, isExplicit))); }
/** * return an RecipientEncryptedKey object from a tagged object. * * @param obj the tagged object holding the object we want. * @param isExplicit true if the object is meant to be explicitly * tagged false otherwise. * @exception ArgumentException if the object held by the * tagged object cannot be converted. */ public static RecipientEncryptedKey GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
/** * Return a X509Name based on the passed in tagged object. * * @param obj tag object holding name. * @param explicitly true if explicitly tagged false otherwise. * @return the X509Name */ public static X509Name GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
private RecipientEncryptedKey( Asn1Sequence seq) { identifier = KeyAgreeRecipientIdentifier.GetInstance(seq[0]); encryptedKey = (Asn1OctetString)seq[1]; }
public static DistributionPoint GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
/** * return an KeyAgreeRecipientIdentifier object from a tagged object. * * @param obj the tagged object holding the object we want. * @param isExplicit true if the object is meant to be explicitly * tagged false otherwise. * @exception ArgumentException if the object held by the * tagged object cannot be converted. */ public static KeyAgreeRecipientIdentifier GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
public static NamingAuthority GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
public static AsymmetricKeyParameter CreateKey( SubjectPublicKeyInfo keyInfo) { AlgorithmIdentifier algID = keyInfo.AlgorithmID; DerObjectIdentifier algOid = algID.Algorithm; // TODO See RSAUtil.isRsaOid in Java build if (algOid.Equals(PkcsObjectIdentifiers.RsaEncryption) || algOid.Equals(X509ObjectIdentifiers.IdEARsa) || algOid.Equals(PkcsObjectIdentifiers.IdRsassaPss) || algOid.Equals(PkcsObjectIdentifiers.IdRsaesOaep)) { RsaPublicKeyStructure pubKey = RsaPublicKeyStructure.GetInstance( keyInfo.ParsePublicKey()); return(new RsaKeyParameters(false, pubKey.Modulus, pubKey.PublicExponent)); } else if (algOid.Equals(X9ObjectIdentifiers.DHPublicNumber)) { Asn1Sequence seq = Asn1Sequence.GetInstance(algID.Parameters.ToAsn1Object()); DHPublicKey dhPublicKey = DHPublicKey.GetInstance(keyInfo.ParsePublicKey()); BigInteger y = dhPublicKey.Y.Value; if (IsPkcsDHParam(seq)) { return(ReadPkcsDHParam(algOid, y, seq)); } DHDomainParameters dhParams = DHDomainParameters.GetInstance(seq); BigInteger p = dhParams.P.Value; BigInteger g = dhParams.G.Value; BigInteger q = dhParams.Q.Value; BigInteger j = null; if (dhParams.J != null) { j = dhParams.J.Value; } DHValidationParameters validation = null; DHValidationParms dhValidationParms = dhParams.ValidationParms; if (dhValidationParms != null) { byte[] seed = dhValidationParms.Seed.GetBytes(); BigInteger pgenCounter = dhValidationParms.PgenCounter.Value; // TODO Check pgenCounter size? validation = new DHValidationParameters(seed, pgenCounter.IntValue); } return(new DHPublicKeyParameters(y, new DHParameters(p, g, q, j, validation))); } else if (algOid.Equals(PkcsObjectIdentifiers.DhKeyAgreement)) { Asn1Sequence seq = Asn1Sequence.GetInstance(algID.Parameters.ToAsn1Object()); DerInteger derY = (DerInteger)keyInfo.ParsePublicKey(); return(ReadPkcsDHParam(algOid, derY.Value, seq)); } else if (algOid.Equals(OiwObjectIdentifiers.ElGamalAlgorithm)) { ElGamalParameter para = new ElGamalParameter( Asn1Sequence.GetInstance(algID.Parameters.ToAsn1Object())); DerInteger derY = (DerInteger)keyInfo.ParsePublicKey(); return(new ElGamalPublicKeyParameters( derY.Value, new ElGamalParameters(para.P, para.G))); } else if (algOid.Equals(X9ObjectIdentifiers.IdDsa) || algOid.Equals(OiwObjectIdentifiers.DsaWithSha1)) { DerInteger derY = (DerInteger)keyInfo.ParsePublicKey(); Asn1Encodable ae = algID.Parameters; DsaParameters parameters = null; if (ae != null) { DsaParameter para = DsaParameter.GetInstance(ae.ToAsn1Object()); parameters = new DsaParameters(para.P, para.Q, para.G); } return(new DsaPublicKeyParameters(derY.Value, parameters)); } else if (algOid.Equals(X9ObjectIdentifiers.IdECPublicKey)) { X962Parameters para = X962Parameters.GetInstance(algID.Parameters.ToAsn1Object()); X9ECParameters x9; if (para.IsNamedCurve) { x9 = ECKeyPairGenerator.FindECCurveByOid((DerObjectIdentifier)para.Parameters); } else { x9 = new X9ECParameters((Asn1Sequence)para.Parameters); } Asn1OctetString key = new DerOctetString(keyInfo.PublicKeyData.GetBytes()); X9ECPoint derQ = new X9ECPoint(x9.Curve, key); ECPoint q = derQ.Point; if (para.IsNamedCurve) { return(new ECPublicKeyParameters("EC", q, (DerObjectIdentifier)para.Parameters)); } ECDomainParameters dParams = new ECDomainParameters(x9.Curve, x9.G, x9.N, x9.H, x9.GetSeed()); return(new ECPublicKeyParameters(q, dParams)); } else if (algOid.Equals(CryptoProObjectIdentifiers.GostR3410x2001)) { Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance(algID.Parameters); DerObjectIdentifier publicKeyParamSet = gostParams.PublicKeyParamSet; ECDomainParameters ecP = ECGost3410NamedCurves.GetByOid(publicKeyParamSet); if (ecP == null) { return(null); } Asn1OctetString key; try { key = (Asn1OctetString)keyInfo.ParsePublicKey(); } catch (IOException e) { throw new ArgumentException("error recovering GOST3410_2001 public key", e); } int fieldSize = 32; int keySize = 2 * fieldSize; byte[] keyEnc = key.GetOctets(); if (keyEnc.Length != keySize) { throw new ArgumentException("invalid length for GOST3410_2001 public key"); } byte[] x9Encoding = new byte[1 + keySize]; x9Encoding[0] = 0x04; for (int i = 1; i <= fieldSize; ++i) { x9Encoding[i] = keyEnc[fieldSize - i]; x9Encoding[i + fieldSize] = keyEnc[keySize - i]; } ECPoint q = ecP.Curve.DecodePoint(x9Encoding); return(new ECPublicKeyParameters("ECGOST3410", q, publicKeyParamSet)); } else if (algOid.Equals(CryptoProObjectIdentifiers.GostR3410x94)) { Gost3410PublicKeyAlgParameters algParams = Gost3410PublicKeyAlgParameters.GetInstance(algID.Parameters); Asn1OctetString key; try { key = (Asn1OctetString)keyInfo.ParsePublicKey(); } catch (IOException e) { throw new ArgumentException("error recovering GOST3410_94 public key", e); } byte[] keyBytes = Arrays.Reverse(key.GetOctets()); // was little endian BigInteger y = new BigInteger(1, keyBytes); return(new Gost3410PublicKeyParameters(y, algParams.PublicKeyParamSet)); } else if (algOid.Equals(EdECObjectIdentifiers.id_X25519)) { return(new X25519PublicKeyParameters(GetRawKey(keyInfo, X25519PublicKeyParameters.KeySize), 0)); } else if (algOid.Equals(EdECObjectIdentifiers.id_X448)) { return(new X448PublicKeyParameters(GetRawKey(keyInfo, X448PublicKeyParameters.KeySize), 0)); } else if (algOid.Equals(EdECObjectIdentifiers.id_Ed25519)) { return(new Ed25519PublicKeyParameters(GetRawKey(keyInfo, Ed25519PublicKeyParameters.KeySize), 0)); } else if (algOid.Equals(EdECObjectIdentifiers.id_Ed448)) { return(new Ed448PublicKeyParameters(GetRawKey(keyInfo, Ed448PublicKeyParameters.KeySize), 0)); } else if (algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256) || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512)) { Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance(algID.Parameters); DerObjectIdentifier publicKeyParamSet = gostParams.PublicKeyParamSet; ECGost3410Parameters ecDomainParameters = new ECGost3410Parameters( new ECNamedDomainParameters(publicKeyParamSet, ECGost3410NamedCurves.GetByOid(publicKeyParamSet)), publicKeyParamSet, gostParams.DigestParamSet, gostParams.EncryptionParamSet); Asn1OctetString key; try { key = (Asn1OctetString)keyInfo.ParsePublicKey(); } catch (IOException e) { throw new ArgumentException("error recovering GOST3410_2012 public key", e); } int fieldSize = 32; if (algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512)) { fieldSize = 64; } int keySize = 2 * fieldSize; byte[] keyEnc = key.GetOctets(); if (keyEnc.Length != keySize) { throw new ArgumentException("invalid length for GOST3410_2012 public key"); } byte[] x9Encoding = new byte[1 + keySize]; x9Encoding[0] = 0x04; for (int i = 1; i <= fieldSize; ++i) { x9Encoding[i] = keyEnc[fieldSize - i]; x9Encoding[i + fieldSize] = keyEnc[keySize - i]; } ECPoint q = ecDomainParameters.Curve.DecodePoint(x9Encoding); return(new ECPublicKeyParameters(q, ecDomainParameters)); } else { throw new SecurityUtilityException("algorithm identifier in public key not recognised: " + algOid); } }
/** * return a CompressedData object from a tagged object. * * @param ato the tagged object holding the object we want. * @param explicitly true if the object is meant to be explicitly * tagged false otherwise. * @exception ArgumentException if the object held by the * tagged object cannot be converted. */ public static CompressedData GetInstance( Asn1TaggedObject ato, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(ato, explicitly))); }
public static Gost3410PublicKeyAlgParameters GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
/// <summary> Create an RfcLdapMessage using the specified Ldap Response.</summary> public RfcLdapMessage(Asn1Sequence op) : this(op, null) { }
public PkiFreeText( DerUtf8String p) { strings = new DerSequence(p); }
public static IssuerSerial GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
internal EncryptionScheme( Asn1Sequence seq) : this((DerObjectIdentifier)seq[0], seq[1]) { }
public static ExtendedKeyUsage GetInstance( Asn1TaggedObject obj, bool explicitly) { return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly))); }
public static AttributeCertificateInfo GetInstance( Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
public static CertificatePolicies GetInstance(Asn1TaggedObject obj, bool isExplicit) { return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit))); }
private ProtectedPart(Asn1Sequence seq) { header = PkiHeader.GetInstance(seq[0]); body = PkiBody.GetInstance(seq[1]); }