FromOctetString() static private method

static private FromOctetString ( byte enc ) : DerObjectIdentifier
enc byte
return DerObjectIdentifier
Esempio n. 1
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");
            }
        }
Esempio n. 2
0
        internal static Asn1Object CreatePrimitiveDerObject(int tagNo, DefiniteLengthInputStream defIn, byte[][] tmpBuffers)
        {
            if (tagNo == 1)
            {
                return(DerBoolean.FromOctetString(Asn1InputStream.GetBuffer(defIn, tmpBuffers)));
            }
            if (tagNo == 6)
            {
                return(DerObjectIdentifier.FromOctetString(Asn1InputStream.GetBuffer(defIn, tmpBuffers)));
            }
            if (tagNo != 10)
            {
                byte[] array = defIn.ToArray();
                switch (tagNo)
                {
                case 2:
                    return(new DerInteger(array));

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

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

                case 5:
                    return(DerNull.Instance);

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

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

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

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

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

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

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

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

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

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

                case 30:
                    return(new DerBmpString(array));
                }
                throw new IOException("unknown tag " + tagNo + " encountered");
            }
            return(DerEnumerated.FromOctetString(Asn1InputStream.GetBuffer(defIn, tmpBuffers)));
        }
Esempio n. 3
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"));
                }
            }
            }
        }