Ejemplo n.º 1
0
        public AuthorityKeyIdentifier(
            ASN1Sequence seq)
        {
            IEnumerator e = seq.getObjects();

            while (e.MoveNext())
            {
                DERTaggedObject o = (DERTaggedObject)e.Current;

                switch ((int)o.getTagNo())
                {
                case 0:
                    this.keyidentifier = ASN1OctetString.getInstance(o, false);
                    break;

                case 1:
                    this.certissuer = GeneralNames.getInstance(o, false);
                    break;

                case 2:
                    this.certserno = DERInteger.getInstance(o, false);
                    break;

                default:
                    throw new ArgumentException("illegal tag");
                }
            }
        }
Ejemplo n.º 2
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));
                }
            }
        }
Ejemplo n.º 3
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;
                }
            }
        }
Ejemplo n.º 4
0
        public ResponseData(
            ASN1Sequence seq)
        {
            int index = 0;

            if (seq.getObjectAt(0) is ASN1TaggedObject)
            {
                ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(0);

                if (o.getTagNo() == 0)
                {
                    this.version = DERInteger.getInstance(
                        (ASN1TaggedObject)seq.getObjectAt(0), true);
                    index++;
                }
                else
                {
                    this.version = null;
                }
            }
            else
            {
                this.version = null;
            }

            this.responderID = ResponderID.getInstance(seq.getObjectAt(index++));
            this.producedAt  = (DERGeneralizedTime)seq.getObjectAt(index++);
            this.responses   = (ASN1Sequence)seq.getObjectAt(index++);

            if (seq.size() > index)
            {
                this.responseExtensions = X509Extensions.getInstance(
                    (ASN1TaggedObject)seq.getObjectAt(index), true);
            }
        }
Ejemplo n.º 5
0
        public CrlID(
            ASN1Sequence seq)
        {
            IEnumerator e = seq.getObjects();

            while (e.MoveNext())
            {
                ASN1TaggedObject o = (ASN1TaggedObject)e.Current;

                switch ((int)o.getTagNo())
                {
                case 0:
                    crlUrl = DERIA5String.getInstance(o, true);
                    break;

                case 1:
                    crlNum = DERInteger.getInstance(o, true);
                    break;

                case 2:
                    crlTime = DERGeneralizedTime.getInstance(o, true);
                    break;

                default:
                    throw new ArgumentException(
                              "unknown tag number: " + o.getTagNo());
                }
            }
        }
Ejemplo n.º 6
0
        public TBSRequest(
            ASN1Sequence seq)
        {
            int index = 0;

            if (seq.getObjectAt(0) is ASN1TaggedObject)
            {
                ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(0);

                if (o.getTagNo() == 0)
                {
                    version = DERInteger.getInstance((ASN1TaggedObject)seq.getObjectAt(0), true);
                    index++;
                }
                else
                {
                    version = new DERInteger(0);
                }
            }
            else
            {
                version = new DERInteger(0);
            }

            if (seq.getObjectAt(index) is ASN1TaggedObject)
            {
                requestorName = GeneralName.getInstance((ASN1TaggedObject)seq.getObjectAt(index++), true);
            }

            requestList = (ASN1Sequence)seq.getObjectAt(index++);

            if (seq.size() == (index + 1))
            {
                requestExtensions = X509Extensions.getInstance((ASN1TaggedObject)seq.getObjectAt(index), true);
            }
        }
Ejemplo n.º 7
0
        public GeneralSubtree(
            ASN1Sequence seq)
        {
            _base = GeneralName.getInstance(seq.getObjectAt(0));

            switch (seq.size())
            {
            case 1:
                break;

            case 2:
                ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(1);
                switch ((int)o.getTagNo())
                {
                case 0:
                    minimum = DERInteger.getInstance(o, false);
                    break;

                case 1:
                    maximum = DERInteger.getInstance(o, false);
                    break;

                default:
                    throw new ArgumentException("Bad tag number: " + o.getTagNo());
                }
                break;

            case 3:
                minimum = DERInteger.getInstance((ASN1TaggedObject)seq.getObjectAt(1), false);
                maximum = DERInteger.getInstance((ASN1TaggedObject)seq.getObjectAt(2), false);
                break;

            default:
                throw new ArgumentException("Bad sequence size: " + seq.size());
            }
        }