public IssuerAndSerialNumber(
     X509Name	name,
     DerInteger	certSerialNumber)
 {
     this.name = name;
     this.certSerialNumber = certSerialNumber;
 }
 public IssuerAndSerialNumber(
     X509Name	name,
     BigInteger	certSerialNumber)
 {
     this.name = name;
     this.certSerialNumber = new DerInteger(certSerialNumber);
 }
        public ResponderID(
            X509Name id)
        {
            if (id == null)
                throw new ArgumentNullException("id");

            this.id = id;
        }
        private IssuerAndSerialNumber(
            Asn1Sequence seq)
        {
            if (seq.Count != 2)
                throw new ArgumentException("Wrong number of elements in sequence", "seq");

            this.name = X509Name.GetInstance(seq[0]);
            this.certSerialNumber = DerInteger.GetInstance(seq[1]);
        }
        private ServiceLocator(
            Asn1Sequence seq)
        {
            this.issuer = X509Name.GetInstance(seq[0]);

            if (seq.Count > 1)
            {
                this.locator = seq[1].ToAsn1Object();
            }
        }
        public ServiceLocator(
            X509Name	issuer,
            Asn1Object	locator)
        {
            if (issuer == null)
                throw new ArgumentNullException("issuer");

            this.issuer = issuer;
            this.locator = locator;
        }
        public CertificationRequestInfo(
            X509Name				subject,
            SubjectPublicKeyInfo	pkInfo,
            Asn1Set					attributes)
        {
            this.subject = subject;
            this.subjectPKInfo = pkInfo;
            this.attributes = attributes;

            if (subject == null || version == null || subjectPKInfo == null)
            {
                throw new ArgumentException(
                    "Not all mandatory fields set in CertificationRequestInfo generator.");
            }
        }
        private CrlIdentifier(
            Asn1Sequence seq)
        {
            if (seq == null)
                throw new ArgumentNullException("seq");
            if (seq.Count < 2 || seq.Count > 3)
                throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");

            this.crlIssuer = X509Name.GetInstance(seq[0]);
            this.crlIssuedTime = DerUtcTime.GetInstance(seq[1]);

            if (seq.Count > 2)
            {
                this.crlNumber = DerInteger.GetInstance(seq[2]);
            }
        }
        public CrlIdentifier(
            X509Name	crlIssuer,
            DateTime	crlIssuedTime,
            BigInteger	crlNumber)
        {
            if (crlIssuer == null)
                throw new ArgumentNullException("crlIssuer");

            this.crlIssuer = crlIssuer;
            this.crlIssuedTime = new DerUtcTime(crlIssuedTime);

            if (crlNumber != null)
            {
                this.crlNumber = new DerInteger(crlNumber);
            }
        }
        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");
                }
            }
        }
        private CertificationRequestInfo(
            Asn1Sequence seq)
        {
            version = (DerInteger) seq[0];

            subject = X509Name.GetInstance(seq[1]);
            subjectPKInfo = SubjectPublicKeyInfo.GetInstance(seq[2]);

            //
            // some CertificationRequestInfo objects seem to treat this field
            // as optional.
            //
            if (seq.Count > 3)
            {
                DerTaggedObject tagobj = (DerTaggedObject) seq[3];
                attributes = Asn1Set.GetInstance(tagobj, false);
            }

            if (subject == null || version == null || subjectPKInfo == null)
            {
                throw new ArgumentException(
                    "Not all mandatory fields set in CertificationRequestInfo generator.");
            }
        }
 public virtual CertTemplateBuilder SetIssuer(X509Name name)
 {
     issuer = name;
     return this;
 }
 public CrlIdentifier(
     X509Name	crlIssuer,
     DateTime	crlIssuedTime)
     : this(crlIssuer, crlIssuedTime, null)
 {
 }
 public ServiceLocator(
     X509Name	issuer)
     : this(issuer, null)
 {
 }
 public void SetIssuer(
     X509Name issuer)
 {
     this.issuer = issuer;
 }
 public virtual CertTemplateBuilder SetSubject(X509Name name)
 {
     subject = name;
     return this;
 }
 public void SetSubject(
     X509Name subject)
 {
     this.subject = subject;
 }
        /// <param name="other">The X509Name object to test equivalency against.</param>
        /// <param name="inOrder">If true, the order of elements must be the same,
        /// as well as the values associated with each element.</param>
        public bool Equivalent(
            X509Name	other,
            bool		inOrder)
        {
            if (!inOrder)
                return this.Equivalent(other);

            if (other == null)
                return false;

            if (other == this)
                return true;

            int orderingSize = ordering.Count;

            if (orderingSize != other.ordering.Count)
                return false;

            for (int i = 0; i < orderingSize; i++)
            {
                DerObjectIdentifier oid = (DerObjectIdentifier) ordering[i];
                DerObjectIdentifier oOid = (DerObjectIdentifier) other.ordering[i];

                if (!oid.Equals(oOid))
                    return false;

                string val = (string) values[i];
                string oVal = (string) other.values[i];

                if (!equivalentStrings(val, oVal))
                    return false;
            }

            return true;
        }
        /**
         * test for equivalence - note: case is ignored.
         */
        public bool Equivalent(
            X509Name other)
        {
            if (other == null)
                return false;

            if (other == this)
                return true;

            int orderingSize = ordering.Count;

            if (orderingSize != other.ordering.Count)
            {
                return false;
            }

            bool[] indexes = new bool[orderingSize];
            int start, end, delta;

            if (ordering[0].Equals(other.ordering[0]))   // guess forward
            {
                start = 0;
                end = orderingSize;
                delta = 1;
            }
            else  // guess reversed - most common problem
            {
                start = orderingSize - 1;
                end = -1;
                delta = -1;
            }

            for (int i = start; i != end; i += delta)
            {
                bool found = false;
                DerObjectIdentifier  oid = (DerObjectIdentifier)ordering[i];
                string value = (string)values[i];

                for (int j = 0; j < orderingSize; j++)
                {
                    if (indexes[j])
                    {
                        continue;
                    }

                    DerObjectIdentifier oOid = (DerObjectIdentifier)other.ordering[j];

                    if (oid.Equals(oOid))
                    {
                        string oValue = (string)other.values[j];

                        if (equivalentStrings(value, oValue))
                        {
                            indexes[j] = true;
                            found      = true;
                            break;
                        }
                    }
                }

                if (!found)
                {
                    return false;
                }
            }

            return true;
        }
        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]);
            }
        }