private KeyRecRepContent(Asn1Sequence seq) { status = PkiStatusInfo.GetInstance(seq[0]); for (int pos = 1; pos < seq.Count; ++pos) { Asn1TaggedObject tObj = Asn1TaggedObject.GetInstance(seq[pos]); switch (tObj.TagNo) { case 0: newSigCert = CmpCertificate.GetInstance(tObj.GetObject()); break; case 1: caCerts = Asn1Sequence.GetInstance(tObj.GetObject()); break; case 2: keyPairHist = Asn1Sequence.GetInstance(tObj.GetObject()); break; default: throw new ArgumentException("unknown tag number: " + tObj.TagNo, "seq"); } } }
/** * Constructor that builds an instance of <code>RoleSyntax</code> by * extracting the encoded elements from the <code>Asn1Sequence</code> * object supplied. * @param seq an instance of <code>Asn1Sequence</code> that holds * the encoded elements used to build this <code>RoleSyntax</code>. */ private RoleSyntax( Asn1Sequence seq) { if (seq.Count < 1 || seq.Count > 2) { throw new ArgumentException("Bad sequence size: " + seq.Count); } for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject taggedObject = Asn1TaggedObject.GetInstance(seq[i]); switch (taggedObject.TagNo) { case 0: roleAuthority = GeneralNames.GetInstance(taggedObject, false); break; case 1: roleName = GeneralName.GetInstance(taggedObject, true); break; default: throw new ArgumentException("Unknown tag in RoleSyntax"); } } }
private Holder(Asn1Sequence seq) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (seq.Count > 3) { throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count)); } for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); switch (instance.TagNo) { case 0: baseCertificateID = IssuerSerial.GetInstance(instance, explicitly: false); break; case 1: entityName = GeneralNames.GetInstance(instance, explicitly: false); break; case 2: objectDigestInfo = ObjectDigestInfo.GetInstance(instance, isExplicit: false); break; default: throw new ArgumentException("unknown tag in Holder"); } } version = 1; }
private KeyRecRepContent(Asn1Sequence seq) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) status = PkiStatusInfo.GetInstance(seq[0]); for (int i = 1; i < seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); switch (instance.TagNo) { case 0: newSigCert = CmpCertificate.GetInstance(instance.GetObject()); break; case 1: caCerts = Asn1Sequence.GetInstance(instance.GetObject()); break; case 2: keyPairHist = Asn1Sequence.GetInstance(instance.GetObject()); break; default: throw new ArgumentException(string.Concat((object)"unknown tag number: ", (object)instance.TagNo), "seq"); } } }
private V2Form(Asn1Sequence seq) { if (seq.Count > 3) { throw new ArgumentException("Bad sequence size: " + seq.Count); } int num = 0; if (!(seq[0] is Asn1TaggedObject)) { num++; this.issuerName = GeneralNames.GetInstance(seq[0]); } for (int num2 = num; num2 != seq.Count; num2++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[num2]); if (instance.TagNo == 0) { this.baseCertificateID = IssuerSerial.GetInstance(instance, false); } else { if (instance.TagNo != 1) { throw new ArgumentException("Bad tag number: " + instance.TagNo); } this.objectDigestInfo = ObjectDigestInfo.GetInstance(instance, false); } } }
/** * 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); } } }
private RoleSyntax(Asn1Sequence seq) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (seq.Count < 1 || seq.Count > 2) { throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count)); } for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); switch (instance.TagNo) { case 0: roleAuthority = GeneralNames.GetInstance(instance, explicitly: false); break; case 1: roleName = GeneralName.GetInstance(instance, explicitly: true); break; default: throw new ArgumentException("Unknown tag in RoleSyntax"); } } }
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])); } } }
/** * Constructor for a holder for an v2 attribute certificate. * * * @param seq The ASN.1 sequence. */ private Holder( Asn1Sequence seq) { if (seq.Count > 3) { throw new ArgumentException("Bad sequence size: " + seq.Count); } for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject tObj = Asn1TaggedObject.GetInstance(seq[i]); switch (tObj.TagNo) { case 0: baseCertificateID = IssuerSerial.GetInstance(tObj, false); break; case 1: entityName = GeneralNames.GetInstance(tObj, false); break; case 2: objectDigestInfo = ObjectDigestInfo.GetInstance(tObj, false); break; default: throw new ArgumentException("unknown tag in Holder"); } } this.version = 1; }
private V2Form(Asn1Sequence seq) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (seq.Count > 3) { throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count)); } int num = 0; if (!(seq[0] is Asn1TaggedObject)) { num++; issuerName = GeneralNames.GetInstance(seq[0]); } for (int i = num; i != seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); if (instance.TagNo == 0) { baseCertificateID = IssuerSerial.GetInstance(instance, explicitly: false); continue; } if (instance.TagNo == 1) { objectDigestInfo = ObjectDigestInfo.GetInstance(instance, isExplicit: false); continue; } throw new ArgumentException(string.Concat((object)"Bad tag number: ", (object)instance.TagNo)); } }
private IssuingDistributionPoint(Asn1Sequence seq) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) this.seq = seq; for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); switch (instance.TagNo) { case 0: _distributionPoint = DistributionPointName.GetInstance(instance, explicitly: true); break; case 1: _onlyContainsUserCerts = DerBoolean.GetInstance(instance, isExplicit: false).IsTrue; break; case 2: _onlyContainsCACerts = DerBoolean.GetInstance(instance, isExplicit: false).IsTrue; break; case 3: _onlySomeReasons = new ReasonFlags(DerBitString.GetInstance(instance, isExplicit: false)); break; case 4: _indirectCRL = DerBoolean.GetInstance(instance, isExplicit: false).IsTrue; break; case 5: _onlyContainsAttributeCerts = DerBoolean.GetInstance(instance, isExplicit: false).IsTrue; break; default: throw new ArgumentException("unknown tag in IssuingDistributionPoint"); } } }
protected internal AuthorityKeyIdentifier( Asn1Sequence seq) { foreach (Asn1Encodable element in seq) { Asn1TaggedObject obj = Asn1TaggedObject.GetInstance(element); switch (obj.TagNo) { case 0: this.keyidentifier = Asn1OctetString.GetInstance(obj, false); break; case 1: this.certissuer = GeneralNames.GetInstance(obj, false); break; case 2: this.certserno = DerInteger.GetInstance(obj, false); break; default: throw new ArgumentException("illegal tag"); } } }
private CmsAlgorithmProtection(Asn1Sequence sequence) { if (sequence.Count != 2) { throw new ArgumentException("Sequence wrong size: One of signatureAlgorithm or macAlgorithm must be present"); } this.digestAlgorithm = AlgorithmIdentifier.GetInstance(sequence[0]); Asn1TaggedObject tagged = Asn1TaggedObject.GetInstance(sequence[1]); if (tagged.TagNo == 1) { this.signatureAlgorithm = AlgorithmIdentifier.GetInstance(tagged, false); this.macAlgorithm = null; } else if (tagged.TagNo == 2) { this.signatureAlgorithm = null; this.macAlgorithm = AlgorithmIdentifier.GetInstance(tagged, false); } else { throw new ArgumentException("Unknown tag found: " + tagged.TagNo); } }
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); } } }
private KeyRecRepContent(Asn1Sequence seq) { this.status = PkiStatusInfo.GetInstance(seq[0]); for (int i = 1; i < seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); switch (instance.TagNo) { case 0: this.newSigCert = CmpCertificate.GetInstance(instance.GetObject()); break; case 1: this.caCerts = Asn1Sequence.GetInstance(instance.GetObject()); break; case 2: this.keyPairHist = Asn1Sequence.GetInstance(instance.GetObject()); break; default: throw new ArgumentException("unknown tag number: " + instance.TagNo, "seq"); } } }
public CertBag(Asn1Sequence seq) { if (seq.Count != 2) { throw new ArgumentException("Wrong number of elements in sequence", "seq"); } certID = DerObjectIdentifier.GetInstance(seq[0]); certValue = Asn1TaggedObject.GetInstance(seq[1]).GetObject(); }
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: { { Asn1TaggedObject oMin = Asn1TaggedObject.GetInstance(seq[1]); if (oMin.TagNo != 0) { throw new ArgumentException("Bad tag number for 'minimum': " + oMin.TagNo); } minimum = DerInteger.GetInstance(oMin, false); } { Asn1TaggedObject oMax = Asn1TaggedObject.GetInstance(seq[2]); if (oMax.TagNo != 1) { throw new ArgumentException("Bad tag number for 'maximum': " + oMax.TagNo); } maximum = DerInteger.GetInstance(oMax, false); } break; } default: throw new ArgumentException("Bad sequence size: " + seq.Count); } }
public CertBag(Asn1Sequence seq) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (seq.Count != 2) { throw new ArgumentException("Wrong number of elements in sequence", "seq"); } certID = DerObjectIdentifier.GetInstance(seq[0]); certValue = Asn1TaggedObject.GetInstance(seq[1]).GetObject(); }
private ScvpReqRes(Asn1Sequence seq) { if (seq[0] is Asn1TaggedObject) { this.request = ContentInfo.GetInstance(Asn1TaggedObject.GetInstance(seq[0]), true); this.response = ContentInfo.GetInstance(seq[1]); return; } this.request = null; this.response = ContentInfo.GetInstance(seq[0]); }
public static Evidence GetInstance(object obj) { if (obj is Evidence) { return((Evidence)obj); } if (obj is Asn1TaggedObject) { return(new Evidence(Asn1TaggedObject.GetInstance(obj))); } throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj"); }
private GeneralSubtree(Asn1Sequence seq) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) baseName = GeneralName.GetInstance(seq[0]); switch (seq.Count) { case 2: { Asn1TaggedObject instance3 = Asn1TaggedObject.GetInstance(seq[1]); switch (instance3.TagNo) { case 0: minimum = DerInteger.GetInstance(instance3, isExplicit: false); break; case 1: maximum = DerInteger.GetInstance(instance3, isExplicit: false); break; default: throw new ArgumentException(string.Concat((object)"Bad tag number: ", (object)instance3.TagNo)); } break; } case 3: { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[1]); if (instance.TagNo != 0) { throw new ArgumentException(string.Concat((object)"Bad tag number for 'minimum': ", (object)instance.TagNo)); } minimum = DerInteger.GetInstance(instance, isExplicit: false); Asn1TaggedObject instance2 = Asn1TaggedObject.GetInstance(seq[2]); if (instance2.TagNo != 1) { throw new ArgumentException(string.Concat((object)"Bad tag number for 'maximum': ", (object)instance2.TagNo)); } maximum = DerInteger.GetInstance(instance2, isExplicit: false); break; } default: throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count)); case 1: break; } }
public static Evidence GetInstance(object obj) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (obj is Evidence) { return((Evidence)obj); } if (obj is Asn1TaggedObject) { return(new Evidence(Asn1TaggedObject.GetInstance(obj))); } throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj"); }
private ScvpReqRes(Asn1Sequence seq) { if (seq[0] is Asn1TaggedObject) { request = ContentInfo.GetInstance(Asn1TaggedObject.GetInstance(seq[0]), isExplicit: true); response = ContentInfo.GetInstance(seq[1]); } else { request = null; response = ContentInfo.GetInstance(seq[0]); } }
public static Evidence GetInstance(object obj) { if (obj is Evidence) { return((Evidence)obj); } if (obj is Asn1TaggedObject) { return(new Evidence(Asn1TaggedObject.GetInstance(obj))); } throw new ArgumentException("Unknown object in GetInstance: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj"); }
private GeneralSubtree(Asn1Sequence seq) { baseName = GeneralName.GetInstance(seq[0]); switch (seq.Count) { case 1: break; case 2: { Asn1TaggedObject instance3 = Asn1TaggedObject.GetInstance(seq[1]); switch (instance3.TagNo) { case 0: minimum = DerInteger.GetInstance(instance3, isExplicit: false); break; case 1: maximum = DerInteger.GetInstance(instance3, isExplicit: false); break; default: throw new ArgumentException("Bad tag number: " + instance3.TagNo); } break; } case 3: { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[1]); if (instance.TagNo != 0) { throw new ArgumentException("Bad tag number for 'minimum': " + instance.TagNo); } minimum = DerInteger.GetInstance(instance, isExplicit: false); Asn1TaggedObject instance2 = Asn1TaggedObject.GetInstance(seq[2]); if (instance2.TagNo != 1) { throw new ArgumentException("Bad tag number for 'maximum': " + instance2.TagNo); } maximum = DerInteger.GetInstance(instance2, isExplicit: false); break; } default: throw new ArgumentException("Bad sequence size: " + seq.Count); } }
private RevRepContent(Asn1Sequence seq) { this.status = Asn1Sequence.GetInstance(seq[0]); for (int i = 1; i < seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); if (instance.TagNo == 0) { this.revCerts = Asn1Sequence.GetInstance(instance, true); } else { this.crls = Asn1Sequence.GetInstance(instance, true); } } }
/** * Constructor from Asn1Sequence. * <p/> * The sequence is of type NameOrPseudonym: * <p/> * <pre> * PersonalData ::= SEQUENCE { * nameOrPseudonym NameOrPseudonym, * nameDistinguisher [0] INTEGER OPTIONAL, * dateOfBirth [1] GeneralizedTime OPTIONAL, * placeOfBirth [2] DirectoryString OPTIONAL, * gender [3] PrintableString OPTIONAL, * postalAddress [4] DirectoryString OPTIONAL * } * </pre> * * @param seq The ASN.1 sequence. */ private PersonalData( Asn1Sequence seq) { if (seq.Count < 1) { throw new ArgumentException("Bad sequence size: " + seq.Count); } IEnumerator e = seq.GetEnumerator(); e.MoveNext(); nameOrPseudonym = NameOrPseudonym.GetInstance(e.Current); while (e.MoveNext()) { Asn1TaggedObject o = Asn1TaggedObject.GetInstance(e.Current); int tag = o.TagNo; switch (tag) { case 0: nameDistinguisher = DerInteger.GetInstance(o, false).Value; break; case 1: dateOfBirth = DerGeneralizedTime.GetInstance(o, false); break; case 2: placeOfBirth = DirectoryString.GetInstance(o, true); break; case 3: gender = DerPrintableString.GetInstance(o, false).GetString(); break; case 4: postalAddress = DirectoryString.GetInstance(o, true); break; default: throw new ArgumentException("Bad tag number: " + o.TagNo); } } }
private byte[] Authenticode(byte[] bRequest, DateTime signTime) { string requestString = ""; for (int i = 0; i < bRequest.Length; i++) { if (bRequest[i] >= 32) { requestString += (char)bRequest[i]; } } bRequest = Convert.FromBase64String(requestString); Asn1InputStream asn1InputStream = new Asn1InputStream(bRequest); Asn1Sequence instance = Asn1Sequence.GetInstance(asn1InputStream.ReadObject()); Asn1Sequence instance2 = Asn1Sequence.GetInstance(instance[1]); Asn1TaggedObject instance3 = Asn1TaggedObject.GetInstance(instance2[1]); Asn1OctetString instance4 = Asn1OctetString.GetInstance(instance3.GetObject()); byte[] octets = instance4.GetOctets(); asn1InputStream.Close(); Asn1EncodableVector signedAttributes = new Asn1EncodableVector(); signedAttributes.Add(new Attribute(CmsAttributes.ContentType, new DerSet(new DerObjectIdentifier("1.2.840.113549.1.7.1")))); signedAttributes.Add(new Attribute(CmsAttributes.SigningTime, new DerSet(new DerUtcTime(signTime)))); AttributeTable signedAttributesTable = new AttributeTable(signedAttributes); signedAttributesTable.ToAsn1EncodableVector(); DefaultSignedAttributeTableGenerator signedAttributeGenerator = new DefaultSignedAttributeTableGenerator(signedAttributesTable); SignerInfoGeneratorBuilder signerInfoBuilder = new SignerInfoGeneratorBuilder(); signerInfoBuilder.WithSignedAttributeGenerator(signedAttributeGenerator); ISignatureFactory signatureFactory = new Asn1SignatureFactory(hashAlg + "WithRSA", priKey); CmsSignedDataGenerator generator = new CmsSignedDataGenerator(); generator.AddSignerInfoGenerator(signerInfoBuilder.Build(signatureFactory, x509Cert)); generator.AddCertificates(x509Store); CmsSignedData cmsSignedData = generator.Generate(new CmsProcessableByteArray(octets), true); byte[] result = cmsSignedData.ContentInfo.GetEncoded("DER"); return(Encoding.ASCII.GetBytes(Convert.ToBase64String(result).ToArray())); }
private RevRepContent(Asn1Sequence seq) { status = Asn1Sequence.GetInstance(seq[0]); for (int pos = 1; pos < seq.Count; ++pos) { Asn1TaggedObject tObj = Asn1TaggedObject.GetInstance(seq[pos]); if (tObj.TagNo == 0) { revCerts = Asn1Sequence.GetInstance(tObj, true); } else { crls = Asn1Sequence.GetInstance(tObj, true); } } }
private DistributionPoint(Asn1Sequence seq) { for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(seq[i]); switch (instance.TagNo) { case 0: distributionPoint = DistributionPointName.GetInstance(instance, explicitly: true); break; case 1: reasons = new ReasonFlags(DerBitString.GetInstance(instance, isExplicit: false)); break; case 2: cRLIssuer = GeneralNames.GetInstance(instance, explicitly: false); break; } } }