FromAsn1Octets() статический приватный Метод

static private FromAsn1Octets ( byte octets ) : DerBitString
octets byte
Результат DerBitString
Пример #1
0
        public static DerBitString GetInstance(Asn1TaggedObject obj, bool isExplicit)
        {
            Asn1Object @object = obj.GetObject();

            if (isExplicit || @object is DerBitString)
            {
                return(DerBitString.GetInstance(@object));
            }
            return(DerBitString.FromAsn1Octets(((Asn1OctetString)@object).GetOctets()));
        }
Пример #2
0
        internal static Asn1Object CreatePrimitiveDerObject(
            int tagNo,
            DefiniteLengthInputStream defIn,
            byte[][]                    tmpBuffers)
        {
            switch (tagNo)
            {
            case Asn1Tags.Boolean:
                return(DerBoolean.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            case Asn1Tags.Enumerated:
                return(DerEnumerated.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            case Asn1Tags.ObjectIdentifier:
                return(DerObjectIdentifier.FromOctetString(GetBuffer(defIn, tmpBuffers)));
            }

            byte[] bytes = defIn.ToArray();

            switch (tagNo)
            {
            case Asn1Tags.BitString:
                return(DerBitString.FromAsn1Octets(bytes));

            case Asn1Tags.BmpString:
                return(new DerBmpString(bytes));

            case Asn1Tags.GeneralizedTime:
                return(new DerGeneralizedTime(bytes));

            case Asn1Tags.GeneralString:
                return(new DerGeneralString(bytes));

            case Asn1Tags.IA5String:
                return(new DerIA5String(bytes));

            case Asn1Tags.Integer:
                return(new DerInteger(bytes));

            case Asn1Tags.Null:
                return(DerNull.Instance);      // actual content is ignored (enforce 0 length?)

            case Asn1Tags.NumericString:
                return(new DerNumericString(bytes));

            case Asn1Tags.OctetString:
                return(new DerOctetString(bytes));

            case Asn1Tags.PrintableString:
                return(new DerPrintableString(bytes));

            case Asn1Tags.T61String:
                return(new DerT61String(bytes));

            case Asn1Tags.UniversalString:
                return(new DerUniversalString(bytes));

            case Asn1Tags.UtcTime:
                return(new DerUtcTime(bytes));

            case Asn1Tags.Utf8String:
                return(new DerUtf8String(bytes));

            case Asn1Tags.VisibleString:
                return(new DerVisibleString(bytes));

            default:
                throw new IOException("unknown tag " + tagNo + " encountered");
            }
        }
        internal static Asn1Object CreatePrimitiveDerObject(
            int tagNo,
            byte[]  bytes)
        {
            switch (tagNo)
            {
            case Asn1Tags.BitString:
                return(DerBitString.FromAsn1Octets(bytes));

            case Asn1Tags.BmpString:
                return(new DerBmpString(bytes));

            case Asn1Tags.Boolean:
                return(new DerBoolean(bytes));

            case Asn1Tags.Enumerated:
                return(new DerEnumerated(bytes));

            case Asn1Tags.GeneralizedTime:
                return(new DerGeneralizedTime(bytes));

            case Asn1Tags.GeneralString:
                return(new DerGeneralString(bytes));

            case Asn1Tags.IA5String:
                return(new DerIA5String(bytes));

            case Asn1Tags.Integer:
                return(new DerInteger(bytes));

            case Asn1Tags.Null:
                return(DerNull.Instance);                          // actual content is ignored (enforce 0 length?)

            case Asn1Tags.NumericString:
                return(new DerNumericString(bytes));

            case Asn1Tags.ObjectIdentifier:
                return(new DerObjectIdentifier(bytes));

            case Asn1Tags.OctetString:
                return(new DerOctetString(bytes));

            case Asn1Tags.PrintableString:
                return(new DerPrintableString(bytes));

            case Asn1Tags.T61String:
                return(new DerT61String(bytes));

            case Asn1Tags.UniversalString:
                return(new DerUniversalString(bytes));

            case Asn1Tags.UtcTime:
                return(new DerUtcTime(bytes));

            case Asn1Tags.Utf8String:
                return(new DerUtf8String(bytes));

            case Asn1Tags.VisibleString:
                return(new DerVisibleString(bytes));

            default:
                return(new DerUnknownTag(false, tagNo, bytes));
            }
        }
Пример #4
0
        internal static Asn1Object CreatePrimitiveDerObject(int tagNo, DefiniteLengthInputStream defIn, byte[][] tmpBuffers)
        {
            if (tagNo != 1)
            {
                if (tagNo == 10)
                {
                    return(DerEnumerated.FromOctetString(GetBuffer(defIn, tmpBuffers)));
                }
                if (tagNo == 6)
                {
                    return(DerObjectIdentifier.FromOctetString(GetBuffer(defIn, tmpBuffers)));
                }
            }
            else
            {
                return(DerBoolean.FromOctetString(GetBuffer(defIn, tmpBuffers)));
            }
            byte[] str = defIn.ToArray();
            switch (tagNo)
            {
            case 0x12:
                return(new DerNumericString(str));

            case 0x13:
                return(new DerPrintableString(str));

            case 20:
                return(new DerT61String(str));

            case 0x15:
                return(new DerVideotexString(str));

            case 0x16:
                return(new DerIA5String(str));

            case 0x17:
                return(new DerUtcTime(str));

            case 0x18:
                return(new DerGeneralizedTime(str));

            case 0x19:
                return(new DerGraphicString(str));

            case 0x1a:
                return(new DerVisibleString(str));

            case 0x1b:
                return(new DerGeneralString(str));

            case 0x1c:
                return(new DerUniversalString(str));

            case 30:
                return(new DerBmpString(str));

            case 2:
                return(new DerInteger(str));

            case 3:
                return(DerBitString.FromAsn1Octets(str));

            case 4:
                return(new DerOctetString(str));

            case 5:
                return(DerNull.Instance);

            case 12:
                return(new DerUtf8String(str));
            }
            throw new IOException("unknown tag " + tagNo + " encountered");
        }
Пример #5
0
        internal static Asn1Object CreatePrimitiveDerObject(int tagNo, DefiniteLengthInputStream defIn, byte[][] tmpBuffers)
        {
            //IL_014a: Unknown result type (might be due to invalid IL or missing references)
            switch (tagNo)
            {
            case 1:
                return(DerBoolean.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            case 10:
                return(DerEnumerated.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            case 6:
                return(DerObjectIdentifier.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            default:
            {
                byte[] array = defIn.ToArray();
                switch (tagNo)
                {
                case 3:
                    return(DerBitString.FromAsn1Octets(array));

                case 30:
                    return(new DerBmpString(array));

                case 24:
                    return(new DerGeneralizedTime(array));

                case 27:
                    return(new DerGeneralString(array));

                case 25:
                    return(new DerGraphicString(array));

                case 22:
                    return(new DerIA5String(array));

                case 2:
                    return(new DerInteger(array));

                case 5:
                    return(DerNull.Instance);

                case 18:
                    return(new DerNumericString(array));

                case 4:
                    return(new DerOctetString(array));

                case 19:
                    return(new DerPrintableString(array));

                case 20:
                    return(new DerT61String(array));

                case 28:
                    return(new DerUniversalString(array));

                case 23:
                    return(new DerUtcTime(array));

                case 12:
                    return(new DerUtf8String(array));

                case 21:
                    return(new DerVideotexString(array));

                case 26:
                    return(new DerVisibleString(array));

                default:
                    throw new IOException(string.Concat((object)"unknown tag ", (object)tagNo, (object)" encountered"));
                }
            }
            }
        }
Пример #6
0
        internal static Asn1Object CreatePrimitiveDerObject(int tagNo, DefiniteLengthInputStream defIn, byte[][] tmpBuffers)
        {
            switch (tagNo)
            {
            case 1:
                return(DerBoolean.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            case 10:
                return(DerEnumerated.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            case 6:
                return(DerObjectIdentifier.FromOctetString(GetBuffer(defIn, tmpBuffers)));

            default:
            {
                byte[] array = defIn.ToArray();
                switch (tagNo)
                {
                case 3:
                    return(DerBitString.FromAsn1Octets(array));

                case 30:
                    return(new DerBmpString(array));

                case 24:
                    return(new DerGeneralizedTime(array));

                case 27:
                    return(new DerGeneralString(array));

                case 22:
                    return(new DerIA5String(array));

                case 2:
                    return(new DerInteger(array));

                case 5:
                    return(DerNull.Instance);

                case 18:
                    return(new DerNumericString(array));

                case 4:
                    return(new DerOctetString(array));

                case 19:
                    return(new DerPrintableString(array));

                case 20:
                    return(new DerT61String(array));

                case 28:
                    return(new DerUniversalString(array));

                case 23:
                    return(new DerUtcTime(array));

                case 12:
                    return(new DerUtf8String(array));

                case 26:
                    return(new DerVisibleString(array));

                default:
                    throw new IOException("unknown tag " + tagNo + " encountered");
                }
            }
            }
        }