GetInstance() public static method

public static GetInstance ( Asn1TaggedObject obj, bool explicitly ) : Time
obj Asn1TaggedObject
explicitly bool
return Time
Example #1
0
        internal TbsCertificateList(Asn1Sequence seq)
        {
            //IL_002d: Unknown result type (might be due to invalid IL or missing references)
            if (seq.Count < 3 || seq.Count > 7)
            {
                throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count));
            }
            int num = 0;

            this.seq = seq;
            if (seq[num] is DerInteger)
            {
                version = DerInteger.GetInstance(seq[num++]);
            }
            else
            {
                version = new DerInteger(0);
            }
            signature  = AlgorithmIdentifier.GetInstance(seq[num++]);
            issuer     = X509Name.GetInstance(seq[num++]);
            thisUpdate = Time.GetInstance(seq[num++]);
            if (num < seq.Count && (seq[num] is DerUtcTime || seq[num] is DerGeneralizedTime || seq[num] is Time))
            {
                nextUpdate = Time.GetInstance(seq[num++]);
            }
            if (num < seq.Count && !(seq[num] is DerTaggedObject))
            {
                revokedCertificates = Asn1Sequence.GetInstance(seq[num++]);
            }
            if (num < seq.Count && seq[num] is DerTaggedObject)
            {
                crlExtensions = X509Extensions.GetInstance(seq[num]);
            }
        }
Example #2
0
 public CrlEntry(Asn1Sequence seq)
 {
     if (seq.Count < 2 || seq.Count > 3)
     {
         throw new ArgumentException("Bad sequence size: " + seq.Count);
     }
     this.seq             = seq;
     this.userCertificate = DerInteger.GetInstance(seq[0]);
     this.revocationDate  = Time.GetInstance(seq[1]);
 }
Example #3
0
 public CrlEntry(Asn1Sequence seq)
 {
     //IL_002d: Unknown result type (might be due to invalid IL or missing references)
     if (seq.Count < 2 || seq.Count > 3)
     {
         throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count));
     }
     this.seq        = seq;
     userCertificate = DerInteger.GetInstance(seq[0]);
     revocationDate  = Time.GetInstance(seq[1]);
 }
        internal TbsCertificateList(
            Asn1Sequence seq)
        {
            if (seq.Count < 3 || seq.Count > 7)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }

            int seqPos = 0;

            this.seq = seq;

            if (seq[seqPos] is DerInteger)
            {
                version = DerInteger.GetInstance(seq[seqPos++]);
            }
            else
            {
                version = new DerInteger(0);
            }

            signature  = AlgorithmIdentifier.GetInstance(seq[seqPos++]);
            issuer     = X509Name.GetInstance(seq[seqPos++]);
            thisUpdate = Time.GetInstance(seq[seqPos++]);

            if (seqPos < seq.Count &&
                (seq[seqPos] is DerUtcTime ||
                 seq[seqPos] is DerGeneralizedTime ||
                 seq[seqPos] is Time))
            {
                nextUpdate = Time.GetInstance(seq[seqPos++]);
            }

            if (seqPos < seq.Count &&
                !(seq[seqPos] is DerTaggedObject))
            {
                Asn1Sequence certs = Asn1Sequence.GetInstance(seq[seqPos++]);
                revokedCertificates = new CrlEntry[certs.Count];

                for (int i = 0; i < revokedCertificates.Length; i++)
                {
                    revokedCertificates[i] = new CrlEntry(Asn1Sequence.GetInstance(certs[i]));
                }
            }

            if (seqPos < seq.Count &&
                seq[seqPos] is DerTaggedObject)
            {
                crlExtensions = X509Extensions.GetInstance(seq[seqPos++]);
            }
        }
        public CrlEntry(
            Asn1Sequence seq)
        {
            if (seq.Count < 2 || seq.Count > 3)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }

            this.seq = seq;

            userCertificate = DerInteger.GetInstance(seq[0]);
            revocationDate  = Time.GetInstance(seq[1]);

            if (seq.Count == 3)
            {
                crlEntryExtensions = X509Extensions.GetInstance(seq[2]);
            }
        }
Example #6
0
        internal TbsCertificateStructure(
            Asn1Sequence seq)
        {
            int seqStart = 0;

            this.seq = seq;

            //
            // some certficates don't include a version number - we assume v1
            //
            if (seq[0] is DerTaggedObject)
            {
                version = DerInteger.GetInstance((Asn1TaggedObject)seq[0], true);
            }
            else
            {
                seqStart = -1;                          // field 0 is missing!
                version  = new DerInteger(0);
            }

            bool isV1 = false;
            bool isV2 = false;

            if (version.Value.Equals(BigInteger.Zero))
            {
                isV1 = true;
            }
            else if (version.Value.Equals(BigInteger.One))
            {
                isV2 = true;
            }
            else if (!version.Value.Equals(BigInteger.Two))
            {
                throw new ArgumentException("version number not recognised");
            }

            serialNumber = DerInteger.GetInstance(seq[seqStart + 1]);

            signature = AlgorithmIdentifier.GetInstance(seq[seqStart + 2]);
            issuer    = X509Name.GetInstance(seq[seqStart + 3]);

            //
            // before and after dates
            //
            Asn1Sequence dates = (Asn1Sequence)seq[seqStart + 4];

            startDate = Time.GetInstance(dates[0]);
            endDate   = Time.GetInstance(dates[1]);

            subject = X509Name.GetInstance(seq[seqStart + 5]);

            //
            // public key info.
            //
            subjectPublicKeyInfo = SubjectPublicKeyInfo.GetInstance(seq[seqStart + 6]);

            int extras = seq.Count - (seqStart + 6) - 1;

            if (extras != 0 && isV1)
            {
                throw new ArgumentException("version 1 certificate contains extra data");
            }

            while (extras > 0)
            {
                DerTaggedObject extra = (DerTaggedObject)seq[seqStart + 6 + extras];

                switch (extra.TagNo)
                {
                case 1:
                {
                    issuerUniqueID = DerBitString.GetInstance(extra, false);
                    break;
                }

                case 2:
                {
                    subjectUniqueID = DerBitString.GetInstance(extra, false);
                    break;
                }

                case 3:
                {
                    if (isV2)
                    {
                        throw new ArgumentException("version 2 certificate cannot contain extensions");
                    }

                    extensions = X509Extensions.GetInstance(extra);
                    break;
                }
                }
                extras--;
            }
        }
Example #7
0
 public static Time GetInstance(Asn1TaggedObject obj, bool explicitly)
 {
     return(Time.GetInstance(obj.GetObject()));
 }