/**
         * Constructor from Asn1Sequence
         *
         * the principal will be a list of constructed sets, each containing an (OID, string) pair.
         */
        protected X509Name(
            Asn1Sequence seq)
        {
            this.seq = seq;

            foreach (Asn1Set asn1Set in seq)
            {
                for (int i = 0; i < asn1Set.Count; i++)
                {
                    Asn1Sequence s = Asn1Sequence.GetInstance(asn1Set[i]);

                    if (s.Count != 2)
                    {
                        throw new ArgumentException("badly sized pair");
                    }

                    ordering.Add(DerObjectIdentifier.GetInstance(s[0]));

                    IAsn1Convertible derValue = s[1];
                    if (derValue is IAsn1String)
                    {
                        values.Add(((IAsn1String)derValue).GetString());
                    }
                    else
                    {
                        values.Add("#" + Encoding.ASCII.GetString(Hex.Encode(derValue.ToAsn1Object().GetEncoded())));
                    }

                    added.Add(i != 0);
                }
            }
        }
Esempio n. 2
0
    public Asn1OctetString GetMac()
    {
        if (nextObject == null)
        {
            nextObject = seq.ReadObject();
        }
        IAsn1Convertible asn1Convertible = nextObject;

        nextObject = null;
        return(Asn1OctetString.GetInstance(asn1Convertible.ToAsn1Object()));
    }
Esempio n. 3
0
        static string ExtractPartitionedCrlDistributionPoint(IAsn1Convertible directoryName)
        {
            var ds = (DerSequence) directoryName.ToAsn1Object();

            var partitionedCrlDistributionPoint = "";
            foreach (Asn1Set dset in ds)
            {
                partitionedCrlDistributionPoint = BuildPartitionedCrlDistributionPoint(partitionedCrlDistributionPoint, dset);
            }
            return partitionedCrlDistributionPoint;
        }
Esempio n. 4
0
        private ContentHints(Asn1Sequence seq)
        {
            IAsn1Convertible asn1Convertible = seq[0];

            if (asn1Convertible.ToAsn1Object() is DerUtf8String)
            {
                this.contentDescription = DerUtf8String.GetInstance(asn1Convertible);
                this.contentType        = DerObjectIdentifier.GetInstance(seq[1]);
                return;
            }
            this.contentType = DerObjectIdentifier.GetInstance(seq[0]);
        }
Esempio n. 5
0
        /**
         * constructor
         */
        private ContentHints(
            Asn1Sequence seq)
        {
            IAsn1Convertible field = seq[0];

            if (field.ToAsn1Object() is DerUtf8String)
            {
                contentDescription = DerUtf8String.GetInstance(field);
                contentType        = DerObjectIdentifier.GetInstance(seq[1]);
            }
            else
            {
                contentType = DerObjectIdentifier.GetInstance(seq[0]);
            }
        }
        public AlgorithmIdentifier GetDigestAlgorithm()
        {
            if (nextObject == null)
            {
                nextObject = seq.ReadObject();
            }

            if (nextObject is Asn1TaggedObjectParser)
            {
                AlgorithmIdentifier obj = AlgorithmIdentifier.GetInstance(
                    (Asn1TaggedObject)nextObject.ToAsn1Object(), false);
                nextObject = null;
                return(obj);
            }

            return(null);
        }
Esempio n. 7
0
        internal Asn1EncodableVector ReadVector()
        {
            IAsn1Convertible obj = ReadObject();

            if (null == obj)
            {
                return(new Asn1EncodableVector(0));
            }

            Asn1EncodableVector v = new Asn1EncodableVector();

            do
            {
                v.Add(obj.ToAsn1Object());
            }while ((obj = ReadObject()) != null);
            return(v);
        }
Esempio n. 8
0
        public sealed override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            IAsn1Convertible asn1Convertible = obj as IAsn1Convertible;

            if (asn1Convertible == null)
            {
                return(false);
            }
            Asn1Object asn1Object  = ToAsn1Object();
            Asn1Object asn1Object2 = asn1Convertible.ToAsn1Object();

            return(asn1Object == asn1Object2 || asn1Object.CallAsn1Equals(asn1Object2));
        }
Esempio n. 9
0
        public sealed override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            IAsn1Convertible convertible = obj as IAsn1Convertible;

            if (convertible == null)
            {
                return(false);
            }
            Asn1Object obj2 = this.ToAsn1Object();
            Asn1Object obj3 = convertible.ToAsn1Object();

            return((obj2 == obj3) || obj2.CallAsn1Equals(obj3));
        }
Esempio n. 10
0
        public sealed override bool Equals(
            object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            IAsn1Convertible other = obj as IAsn1Convertible;

            if (other == null)
            {
                return(false);
            }

            Asn1Object o1 = ToAsn1Object();
            Asn1Object o2 = other.ToAsn1Object();

            return(o1 == o2 || o1.CallAsn1Equals(o2));
        }
Esempio n. 11
0
 public DerOctetString(IAsn1Convertible obj)
     : this(obj.ToAsn1Object())
 {
 }
        static string ExtractPartitionedCrlDistributionPoint(IAsn1Convertible directoryName)
        {
            var ds = (DerSequence) directoryName.ToAsn1Object();

            var partitionedCrlDistributionPoint = "";
            foreach (Asn1Set dset in ds)
            {
                partitionedCrlDistributionPoint = BuildPartitionedCrlDistributionPoint(partitionedCrlDistributionPoint, dset);
            }
            return partitionedCrlDistributionPoint;
        }