IsExplicit() public method

public IsExplicit ( ) : bool
return bool
Ejemplo n.º 1
0
        public static Asn1Sequence GetInstance(Asn1TaggedObject obj, bool explicitly)
        {
            //IL_0017: Unknown result type (might be due to invalid IL or missing references)
            //IL_0066: Unknown result type (might be due to invalid IL or missing references)
            Asn1Object @object = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }
                return((Asn1Sequence)@object);
            }
            if (obj.IsExplicit())
            {
                if (obj is BerTaggedObject)
                {
                    return(new BerSequence(@object));
                }
                return(new DerSequence(@object));
            }
            if (@object is Asn1Sequence)
            {
                return((Asn1Sequence)@object);
            }
            throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
        }
Ejemplo n.º 2
0
        public static Asn1Set GetInstance(Asn1TaggedObject obj, bool explicitly)
        {
            Asn1Object @object = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }
                return((Asn1Set)@object);
            }
            if (obj.IsExplicit())
            {
                return(new DerSet(@object));
            }
            if (@object is Asn1Set)
            {
                return((Asn1Set)@object);
            }
            if (@object is Asn1Sequence)
            {
                Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
                Asn1Sequence        asn1Sequence        = (Asn1Sequence)@object;
                foreach (Asn1Encodable item in asn1Sequence)
                {
                    asn1EncodableVector.Add(item);
                }
                return(new DerSet(asn1EncodableVector, needsSorting: false));
            }
            throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj");
        }
Ejemplo n.º 3
0
        public static Asn1Sequence GetInstance(Asn1TaggedObject obj, bool explicitly)
        {
            Asn1Object @object = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }
                return((Asn1Sequence)@object);
            }
            else if (obj.IsExplicit())
            {
                if (obj is BerTaggedObject)
                {
                    return(new BerSequence(@object));
                }
                return(new DerSequence(@object));
            }
            else
            {
                if (@object is Asn1Sequence)
                {
                    return((Asn1Sequence)@object);
                }
                throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj");
            }
        }
Ejemplo n.º 4
0
        public static Asn1Sequence GetInstance(Asn1TaggedObject obj, bool explicitly)
        {
            Asn1Object obj2 = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }
                return((Asn1Sequence)obj2);
            }
            if (obj.IsExplicit())
            {
                if (obj is BerTaggedObject)
                {
                    return(new BerSequence(obj2));
                }
                return(new DerSequence(obj2));
            }
            if (!(obj2 is Asn1Sequence))
            {
                throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
            }
            return((Asn1Sequence)obj2);
        }
Ejemplo n.º 5
0
        /**
         * Return an ASN1 set from a tagged object. There is a special
         * case here, if an object appears to have been explicitly tagged on
         * reading but we were expecting it to be implicitly tagged in the
         * normal course of events it indicates that we lost the surrounding
         * set - so we need to add it back (this will happen if the tagged
         * object is a sequence that contains other sequences). If you are
         * dealing with implicitly tagged sets you really <b>should</b>
         * be using this method.
         *
         * @param obj the tagged object.
         * @param explicitly true if the object is meant to be explicitly tagged
         *          false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *          be converted.
         */
        public static Asn1Set GetInstance(
            Asn1TaggedObject obj,
            bool explicitly)
        {
            Asn1Object inner = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }

                return((Asn1Set)inner);
            }

            //
            // constructed object which appears to be explicitly tagged
            // and it's really implicit means we have to add the
            // surrounding sequence.
            //
            if (obj.IsExplicit())
            {
                return(new DerSet(inner));
            }

            if (inner is Asn1Set)
            {
                return((Asn1Set)inner);
            }

            //
            // in this case the parser returns a sequence, convert it
            // into a set.
            //
            if (inner is Asn1Sequence)
            {
                Asn1EncodableVector v = new Asn1EncodableVector();
                Asn1Sequence        s = (Asn1Sequence)inner;

                foreach (Asn1Encodable ae in s)
                {
                    v.Add(ae);
                }

                // TODO Should be able to construct set directly from sequence?
                return(new DerSet(v, false));
            }

            throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj");
        }
Ejemplo n.º 6
0
        public static Asn1Set GetInstance(Asn1TaggedObject obj, bool explicitly)
        {
            //IL_0017: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
            Asn1Object @object = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }
                return((Asn1Set)@object);
            }
            if (obj.IsExplicit())
            {
                return(new DerSet(@object));
            }
            if (@object is Asn1Set)
            {
                return((Asn1Set)@object);
            }
            if (@object is Asn1Sequence)
            {
                Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
                Asn1Sequence        asn1Sequence        = (Asn1Sequence)@object;
                {
                    global::System.Collections.IEnumerator enumerator = asn1Sequence.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                            asn1EncodableVector.Add(asn1Encodable);
                        }
                    }
                    finally
                    {
                        global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
                return(new DerSet(asn1EncodableVector, needsSorting: false));
            }
            throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
        }
Ejemplo n.º 7
0
        /**
         * Return an ASN1 set from a tagged object. There is a special
         * case here, if an object appears to have been explicitly tagged on
         * reading but we were expecting it to be implicitly tagged in the
         * normal course of events it indicates that we lost the surrounding
         * set - so we need to add it back (this will happen if the tagged
         * object is a sequence that contains other sequences). If you are
         * dealing with implicitly tagged sets you really <b>should</b>
         * be using this method.
         *
         * @param obj the tagged object.
         * @param explicitly true if the object is meant to be explicitly tagged
         *          false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *          be converted.
         */
        public static Asn1Set GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
			Asn1Object inner = obj.GetObject();

			if (explicitly)
            {
                if (!obj.IsExplicit())
                    throw new ArgumentException("object implicit - explicit expected.");

				return (Asn1Set) inner;
            }

			//
            // constructed object which appears to be explicitly tagged
            // and it's really implicit means we have to add the
            // surrounding sequence.
            //
            if (obj.IsExplicit())
            {
                return new DerSet(inner);
            }

			if (inner is Asn1Set)
            {
                return (Asn1Set) inner;
            }

            //
            // in this case the parser returns a sequence, convert it
            // into a set.
            //
			if (inner is Asn1Sequence)
            {
				Asn1EncodableVector v = new Asn1EncodableVector();
				Asn1Sequence s = (Asn1Sequence) inner;

				foreach (Asn1Encodable ae in s)
				{
                    v.Add(ae);
                }

				// TODO Should be able to construct set directly from sequence?
				return new DerSet(v, false);
            }

			throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj");
		}
Ejemplo n.º 8
0
        public static Asn1Set GetInstance(Asn1TaggedObject obj, bool explicitly)
        {
            Asn1Object obj2 = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }
                return((Asn1Set)obj2);
            }
            if (obj.IsExplicit())
            {
                return(new DerSet(obj2));
            }
            if (obj2 is Asn1Set)
            {
                return((Asn1Set)obj2);
            }
            if (!(obj2 is Asn1Sequence))
            {
                throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
            }
            Asn1EncodableVector v          = new Asn1EncodableVector(Array.Empty <Asn1Encodable>());
            IEnumerator         enumerator = ((Asn1Sequence)obj2).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    Asn1Encodable   current = (Asn1Encodable)enumerator.Current;
                    Asn1Encodable[] objs    = new Asn1Encodable[] { current };
                    v.Add(objs);
                }
            }
            finally
            {
                if (enumerator is IDisposable disposable)
                {
                    IDisposable disposable;
                    disposable.Dispose();
                }
            }
            return(new DerSet(v, false));
        }
Ejemplo n.º 9
0
        /**
         * Return an ASN1 sequence from a tagged object. There is a special
         * case here, if an object appears to have been explicitly tagged on
         * reading but we were expecting it to be implicitly tagged in the
         * normal course of events it indicates that we lost the surrounding
         * sequence - so we need to add it back (this will happen if the tagged
         * object is a sequence that contains other sequences). If you are
         * dealing with implicitly tagged sequences you really <b>should</b>
         * be using this method.
         *
         * @param obj the tagged object.
         * @param explicitly true if the object is meant to be explicitly tagged,
         *          false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *          be converted.
         */
        public static Asn1Sequence GetInstance(
            Asn1TaggedObject obj,
            bool explicitly)
        {
            Asn1Object inner = obj.GetObject();

            if (explicitly)
            {
                if (!obj.IsExplicit())
                {
                    throw new ArgumentException("object implicit - explicit expected.");
                }

                return((Asn1Sequence)inner);
            }

            //
            // constructed object which appears to be explicitly tagged
            // when it should be implicit means we have to add the
            // surrounding sequence.
            //
            if (obj.IsExplicit())
            {
                if (obj is BerTaggedObject)
                {
                    return(new BerSequence(inner));
                }

                return(new DerSequence(inner));
            }

            if (inner is Asn1Sequence)
            {
                return((Asn1Sequence)inner);
            }

            throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
        }
Ejemplo n.º 10
0
        internal static bool IsConstructed(bool isExplicit, Asn1Object obj)
        {
            if (isExplicit || obj is Asn1Sequence || obj is Asn1Set)
            {
                return(true);
            }
            Asn1TaggedObject asn1TaggedObject = obj as Asn1TaggedObject;

            if (asn1TaggedObject == null)
            {
                return(false);
            }
            return(IsConstructed(asn1TaggedObject.IsExplicit(), asn1TaggedObject.GetObject()));
        }
Ejemplo n.º 11
0
        internal static bool IsConstructed(bool isExplicit, Asn1Object obj)
        {
            if ((isExplicit || (obj is Asn1Sequence)) || (obj is Asn1Set))
            {
                return(true);
            }
            Asn1TaggedObject obj2 = obj as Asn1TaggedObject;

            if (obj2 == null)
            {
                return(false);
            }
            return(IsConstructed(obj2.IsExplicit(), obj2.GetObject()));
        }
Ejemplo n.º 12
0
		/**
         * Return an ASN1 sequence from a tagged object. There is a special
         * case here, if an object appears to have been explicitly tagged on
         * reading but we were expecting it to be implicitly tagged in the
         * normal course of events it indicates that we lost the surrounding
         * sequence - so we need to add it back (this will happen if the tagged
         * object is a sequence that contains other sequences). If you are
         * dealing with implicitly tagged sequences you really <b>should</b>
         * be using this method.
         *
         * @param obj the tagged object.
         * @param explicitly true if the object is meant to be explicitly tagged,
         *          false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *          be converted.
         */
        public static Asn1Sequence GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
			Asn1Object inner = obj.GetObject();

			if (explicitly)
            {
                if (!obj.IsExplicit())
                    throw new ArgumentException("object implicit - explicit expected.");

				return (Asn1Sequence) inner;
            }

			//
            // constructed object which appears to be explicitly tagged
            // when it should be implicit means we have to add the
            // surrounding sequence.
            //
            if (obj.IsExplicit())
            {
                if (obj is BerTaggedObject)
                {
                    return new BerSequence(inner);
                }

				return new DerSequence(inner);
            }

			if (inner is Asn1Sequence)
            {
                return (Asn1Sequence) inner;
            }

			throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj");
		}
Ejemplo n.º 13
0
        private KekRecipientInfo GetKekInfo(
			Asn1TaggedObject o)
        {
            // For compatibility with erroneous version, we don't always pass 'false' here
            return KekRecipientInfo.GetInstance(o, o.IsExplicit());
        }