public SingleResponse(
            Asn1Sequence seq)
        {
            this.certID = CertID.GetInstance(seq[0]);
            this.certStatus = CertStatus.GetInstance(seq[1]);
            this.thisUpdate = (DerGeneralizedTime)seq[2];

            if (seq.Count > 4)
            {
                this.nextUpdate = DerGeneralizedTime.GetInstance(
                    (Asn1TaggedObject) seq[3], true);
                this.singleExtensions = X509Extensions.GetInstance(
                    (Asn1TaggedObject) seq[4], true);
            }
            else if (seq.Count > 3)
            {
                Asn1TaggedObject o = (Asn1TaggedObject) seq[3];

                if (o.TagNo == 0)
                {
                    this.nextUpdate = DerGeneralizedTime.GetInstance(o, true);
                }
                else
                {
                    this.singleExtensions = X509Extensions.GetInstance(o, true);
                }
            }
        }
예제 #2
0
        private RevDetails(Asn1Sequence seq)
        {
            certDetails = CertTemplate.GetInstance(seq[0]);

            if  (seq.Count > 1)
            {
                crlEntryDetails = X509Extensions.GetInstance(seq[1]);
            }
        }
예제 #3
0
        public Request(
            CertID			reqCert,
            X509Extensions	singleRequestExtensions)
        {
            if (reqCert == null)
                throw new ArgumentNullException("reqCert");

            this.reqCert = reqCert;
            this.singleRequestExtensions = singleRequestExtensions;
        }
예제 #4
0
        private Request(
            Asn1Sequence seq)
        {
            reqCert = CertID.GetInstance(seq[0]);

            if (seq.Count == 2)
            {
                singleRequestExtensions = X509Extensions.GetInstance(
                    (Asn1TaggedObject)seq[1], true);
            }
        }
 public SingleResponse(
     CertID              certID,
     CertStatus          certStatus,
     DerGeneralizedTime  thisUpdate,
     DerGeneralizedTime  nextUpdate,
     X509Extensions      singleExtensions)
 {
     this.certID = certID;
     this.certStatus = certStatus;
     this.thisUpdate = thisUpdate;
     this.nextUpdate = nextUpdate;
     this.singleExtensions = singleExtensions;
 }
예제 #6
0
        public TimeStampReq(
            MessageImprint		messageImprint,
            DerObjectIdentifier	tsaPolicy,
            DerInteger			nonce,
            DerBoolean			certReq,
            X509Extensions		extensions)
        {
            // default
            this.version = new DerInteger(1);

            this.messageImprint = messageImprint;
            this.tsaPolicy = tsaPolicy;
            this.nonce = nonce;
            this.certReq = certReq;
            this.extensions = extensions;
        }
예제 #7
0
        private CertTemplate(Asn1Sequence seq)
        {
            this.seq = seq;

            foreach (Asn1TaggedObject tObj in seq)
            {
                switch (tObj.TagNo)
                {
                case 0:
                    version = DerInteger.GetInstance(tObj, false);
                    break;
                case 1:
                    serialNumber = DerInteger.GetInstance(tObj, false);
                    break;
                case 2:
                    signingAlg = AlgorithmIdentifier.GetInstance(tObj, false);
                    break;
                case 3:
                    issuer = X509Name.GetInstance(tObj, true); // CHOICE
                    break;
                case 4:
                    validity = OptionalValidity.GetInstance(Asn1Sequence.GetInstance(tObj, false));
                    break;
                case 5:
                    subject = X509Name.GetInstance(tObj, true); // CHOICE
                    break;
                case 6:
                    publicKey = SubjectPublicKeyInfo.GetInstance(tObj, false);
                    break;
                case 7:
                    issuerUID = DerBitString.GetInstance(tObj, false);
                    break;
                case 8:
                    subjectUID = DerBitString.GetInstance(tObj, false);
                    break;
                case 9:
                    extensions = X509Extensions.GetInstance(tObj, false);
                    break;
                default:
                    throw new ArgumentException("unknown tag: " + tObj.TagNo, "seq");
                }
            }
        }
예제 #8
0
        private TimeStampReq(
            Asn1Sequence seq)
        {
            int nbObjects = seq.Count;
            int seqStart = 0;

            // version
            version = DerInteger.GetInstance(seq[seqStart++]);

            // messageImprint
            messageImprint = MessageImprint.GetInstance(seq[seqStart++]);

            for (int opt = seqStart; opt < nbObjects; opt++)
            {
                // tsaPolicy
                if (seq[opt] is DerObjectIdentifier)
                {
                    tsaPolicy = DerObjectIdentifier.GetInstance(seq[opt]);
                }
                // nonce
                else if (seq[opt] is DerInteger)
                {
                    nonce = DerInteger.GetInstance(seq[opt]);
                }
                // certReq
                else if (seq[opt] is DerBoolean)
                {
                    certReq = DerBoolean.GetInstance(seq[opt]);
                }
                // extensions
                else if (seq[opt] is Asn1TaggedObject)
                {
                    Asn1TaggedObject tagged = (Asn1TaggedObject) seq[opt];
                    if (tagged.TagNo == 0)
                    {
                        extensions = X509Extensions.GetInstance(tagged, false);
                    }
                }
            }
        }
 public void SetExtensions(
     X509Extensions extensions)
 {
     this.extensions = extensions;
 }
        public void AddCrlEntry(DerInteger userCertificate, Time revocationDate, X509Extensions extensions)
        {
            Asn1EncodableVector v = new Asn1EncodableVector(
                userCertificate, revocationDate);

            if (extensions != null)
            {
                v.Add(extensions);
            }

            AddCrlEntry(new DerSequence(v));
        }
 public virtual CertTemplateBuilder SetExtensions(X509Extensions extens)
 {
     extensions = extens;
     return this;
 }
예제 #12
0
        public bool Equivalent(
            X509Extensions other)
        {
            if (extensions.Count != other.extensions.Count)
                return false;

            foreach (DerObjectIdentifier oid in extensions.Keys)
            {
                if (!extensions[oid].Equals(other.extensions[oid]))
                    return false;
            }

            return true;
        }
예제 #13
0
 public RevDetails(CertTemplate certDetails, X509Extensions crlEntryDetails)
 {
     this.crlEntryDetails = crlEntryDetails;
 }
        public void SetExtensions(
            X509Extensions extensions)
        {
            this.extensions = extensions;

            if (extensions != null)
            {
                X509Extension altName = extensions.GetExtension(X509Extensions.SubjectAlternativeName);

                if (altName != null && altName.IsCritical)
                {
                    altNamePresentAndCritical = true;
                }
            }
        }
예제 #15
0
        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))
            {
                revokedCertificates = Asn1Sequence.GetInstance(seq[seqPos++]);
            }

            if (seqPos < seq.Count
                && seq[seqPos] is DerTaggedObject)
            {
                crlExtensions = X509Extensions.GetInstance(seq[seqPos]);
            }
        }