Esempio n. 1
0
        public AttributeCertificateInfo(
            ASN1Sequence seq)
        {
            this.version                = DERInteger.getInstance(seq.getObjectAt(0));
            this.holder                 = Holder.getInstance(seq.getObjectAt(1));
            this.issuer                 = AttCertIssuer.getInstance(seq.getObjectAt(2));
            this.signature              = AlgorithmIdentifier.getInstance(seq.getObjectAt(3));
            this.serialNumber           = DERInteger.getInstance(seq.getObjectAt(4));
            this.attrCertValidityPeriod = AttCertValidityPeriod.getInstance(seq.getObjectAt(5));
            this.attributes             = ASN1Sequence.getInstance(seq.getObjectAt(6));

            for (int i = 7; i < seq.size(); i++)
            {
                ASN1Encodable obj = (ASN1Encodable)seq.getObjectAt(i);

                if (obj is DERBitString)
                {
                    this.issuerUniqueID = DERBitString.getInstance(seq.getObjectAt(i));
                }
                else if (obj is ASN1Sequence || obj is X509Extensions)
                {
                    this.extensions = X509Extensions.getInstance(seq.getObjectAt(i));
                }
            }
        }
Esempio n. 2
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;
                }
            }
        }
Esempio n. 3
0
            public CRLEntry(
                ASN1Sequence seq)
            {
                this.seq = seq;

                userCertificate = (DERInteger)seq.getObjectAt(0);
                revocationDate  = Time.getInstance(seq.getObjectAt(1));
                if (seq.size() == 3)
                {
                    crlEntryExtensions = X509Extensions.getInstance(seq.getObjectAt(2));
                }
            }
Esempio n. 4
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++));
            }
        }