Exemplo n.º 1
0
        public TBSCertificateStructure(
            ASN1Sequence seq)
        {
            int seqStart = 0;

            this.seq = seq;

            //
            // some certficates don't include a version number - we assume v1
            //
            if (seq.getObjectAt(0) is DERTaggedObject)
            {
                version = DERInteger.getInstance(seq.getObjectAt(0));
            }
            else
            {
                seqStart = -1;          // field 0 is missing!
                version  = new DERInteger(0);
            }

            serialNumber = DERInteger.getInstance(seq.getObjectAt(seqStart + 1));

            signature = AlgorithmIdentifier.getInstance(seq.getObjectAt(seqStart + 2));
            issuer    = X509Name.getInstance(seq.getObjectAt(seqStart + 3));

            //
            // before and after dates
            //
            ASN1Sequence dates = (ASN1Sequence)seq.getObjectAt(seqStart + 4);

            startDate = Time.getInstance(dates.getObjectAt(0));
            endDate   = Time.getInstance(dates.getObjectAt(1));

            subject = X509Name.getInstance(seq.getObjectAt(seqStart + 5));

            //
            // public key info.
            //
            subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(seq.getObjectAt(seqStart + 6));

            for (int extras = seq.size() - (seqStart + 6) - 1; extras > 0; extras--)
            {
                DERTaggedObject extra = (DERTaggedObject)seq.getObjectAt(seqStart + 6 + extras);

                switch ((int)extra.getTagNo())
                {
                case 1:
                    issuerUniqueId = DERBitString.getInstance(extra, false);
                    break;

                case 2:
                    subjectUniqueId = DERBitString.getInstance(extra, false);
                    break;

                case 3:
                    extensions = X509Extensions.getInstance(extra);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public TBSCertList(
            ASN1Sequence seq)
        {
            int seqPos = 0;

            this.seq = seq;

            if (seq.getObjectAt(seqPos) is DERInteger)
            {
                version = (DERInteger)seq.getObjectAt(seqPos++);
            }
            else
            {
                version = new DERInteger(0);
            }

            signature  = AlgorithmIdentifier.getInstance(seq.getObjectAt(seqPos++));
            issuer     = X509Name.getInstance(seq.getObjectAt(seqPos++));
            thisUpdate = Time.getInstance(seq.getObjectAt(seqPos++));

            if (seqPos < seq.size() &&
                (seq.getObjectAt(seqPos) is DERUTCTime ||
                 seq.getObjectAt(seqPos) is DERGeneralizedTime ||
                 seq.getObjectAt(seqPos) is Time))
            {
                nextUpdate = Time.getInstance(seq.getObjectAt(seqPos++));
            }

            if (seqPos < seq.size() &&
                !(seq.getObjectAt(seqPos) is DERTaggedObject))
            {
                ASN1Sequence certs = (ASN1Sequence)seq.getObjectAt(seqPos++);
                revokedCertificates = new CRLEntry[certs.size()];

                for (int i = 0; i < revokedCertificates.Length; i++)
                {
                    revokedCertificates[i] = new CRLEntry((ASN1Sequence)certs.getObjectAt(i));
                }
            }

            if (seqPos < seq.size() &&
                seq.getObjectAt(seqPos) is DERTaggedObject)
            {
                crlExtensions = X509Extensions.getInstance(seq.getObjectAt(seqPos++));
            }
        }