Exemplo n.º 1
0
        static void GetTagName(Asn1Data asn1Data, Byte tag)
        {
            asn1Data.TagName = "undefined";

            /*
             * Asn1Type type = ((Asn1Type)(tag & 31));
             * if ((tag & (Byte)Asn1Class.PRIVATE) != 0) {
             *   switch (tag & (Byte)Asn1Class.PRIVATE) {
             *       case (Byte)Asn1Class.CONTEXT_SPECIFIC:
             *           asn1Data.TagName = "CONTEXT SPECIFIC (" + (tag & 31) + ")";
             *           asn1Data.isTaggedConstructed = (tag & (Byte)Asn1Class.CONSTRUCTED) > 0;
             *           break;
             *       case (Byte)Asn1Class.APPLICATION:
             *           asn1Data.TagName = "APPLICATION (" + (tag & 31) + ")";
             *           break;
             *       case (Byte)Asn1Class.PRIVATE:
             *           asn1Data.TagName = "PRIVATE (" + (tag & 31) + ")";
             *           break;
             *       case (Byte)Asn1Class.CONSTRUCTED:
             *           asn1Data.TagName = "CONSTRUCTED (" + (tag & 31) + ")";
             *           break;
             * }
             * } else {
             *   asn1Data.TagName = ((Asn1Type)(tag & 31))+"";
             * }*/
        }
Exemplo n.º 2
0
        static Int64 CalculatePredictLength(Asn1Data asn1Data, Int64 offset)
        {
            if (offset + 1 >= asn1Data.RawData.Length || offset < 0)
            {
                return(Int32.MaxValue);
            }
            if (asn1Data.RawData[offset + 1] < 128)
            {
                return(asn1Data.RawData[offset + 1] + 2);
            }
            Int32 lengthbytes = asn1Data.RawData[offset + 1] - 128;

            // max length can be encoded by using 4 bytes.
            if (lengthbytes > 4)
            {
                return(Int32.MaxValue);
            }
            Int32 ppayloadLength = asn1Data.RawData[offset + 2];

            for (Int64 i = offset + 3; i < offset + 2 + lengthbytes; i++)
            {
                ppayloadLength = (ppayloadLength << 8) | asn1Data.RawData[i];
            }
            // 2 -- transitional + tag
            return(ppayloadLength + lengthbytes + 2);
        }
Exemplo n.º 3
0
 static void CalculateLength(Asn1Data asn1Data)
 {
     if (asn1Data.RawData[asn1Data.Offset + 1] < 128)
     {
         asn1Data.PayloadStartOffset = asn1Data.Offset + 2;
         asn1Data.PayloadLength      = asn1Data.RawData[asn1Data.Offset + 1];
         asn1Data.TagLength          = asn1Data.PayloadLength + 2;
     }
     else
     {
         Int32 lengthbytes = asn1Data.RawData[asn1Data.Offset + 1] - 128;
         // max length can be encoded by using 4 bytes.
         if (lengthbytes > 4)
         {
             Logger.writeLog("ERROR-Data length is too large.");
             // throw new OverflowException("Data length is too large.");
         }
         asn1Data.PayloadStartOffset = asn1Data.Offset + 2 + lengthbytes;
         asn1Data.PayloadLength      = asn1Data.RawData[asn1Data.Offset + 2];
         for (Int32 i = asn1Data.Offset + 3; i < asn1Data.PayloadStartOffset; i++)
         {
             asn1Data.PayloadLength = (asn1Data.PayloadLength << 8) | asn1Data.RawData[i];
         }
         asn1Data.TagLength = asn1Data.PayloadLength + lengthbytes + 2;
     }
 }
Exemplo n.º 4
0
        public static Asn1Data FromRawData(Byte[] rawData, Int32 offset)
        {
            Logger.writeLog("(Start)FromRawData - Byte[],Int32");
            if (rawData == null)
            {
                Logger.writeLog("rawData is null");
                // throw new ArgumentNullException("rawData");
            }
            if (rawData.Length < 2)
            {
                Logger.writeLog("ERROR-rawData.Length must be upper than 2");
                //throw new Win32Exception("Invalid Data");
            }

            Logger.writeLog("Constructing asn1Data object");
            Asn1Data asn1Data = new Asn1Data();

            Logger.writeLog("Constructed asn1Data object");
            initMembers(asn1Data);

            Logger.writeLog("Calling Initialize with asn1Data,rawData and offset");
            Initialize(asn1Data, rawData, offset);
            Logger.writeLog("Called Initialize with asn1Data,rawData and offset");
            Logger.writeLog("(End)FromRawData - Byte[],Int32");
            return(asn1Data);
        }
Exemplo n.º 5
0
        public static void initMembers(Asn1Data asn1Data)
        {
            Logger.writeLog("(Start)initMembers");
            asn1Data.excludedTags     = new Map <byte, bool>();
            asn1Data.offsetMap        = new Map <Int64, AsnInternalMap>();
            asn1Data.multiNestedTypes = new Map <byte, bool>();
            asn1Data.tmpHTable        = new Map <byte, bool>();
            Logger.writeLog("(End)initMembers");

            Logger.writeLog("Initializing _excludedTags map");
            asn1Data.excludedTags[0]  = true;
            asn1Data.excludedTags[1]  = true;
            asn1Data.excludedTags[2]  = true;
            asn1Data.excludedTags[5]  = true;
            asn1Data.excludedTags[6]  = true;
            asn1Data.excludedTags[9]  = true;
            asn1Data.excludedTags[10] = true;
            asn1Data.excludedTags[13] = true;
            Logger.writeLog("Initialized _excludedTags map");

            Logger.writeLog("Initializing multiNestedTypes");
            asn1Data.multiNestedTypes[(Byte)Asn1Type.SEQUENCE] = true;
            asn1Data.multiNestedTypes[(Byte)((Byte)Asn1Type.SEQUENCE | (Byte)Asn1Class.CONSTRUCTED)] = true;
            asn1Data.multiNestedTypes[(Byte)Asn1Type.SET] = true;
            asn1Data.multiNestedTypes[(Byte)((Byte)Asn1Type.SET | (Byte)Asn1Class.CONSTRUCTED)] = true;
            Logger.writeLog("Initialized multiNestedTypes");
            Logger.writeLog("Constructing AsnInternalMap object and assigning to asn1Data.currentPosition");
            asn1Data.currentPosition = new AsnInternalMap();
            Logger.writeLog("Constructed AsnInternalMap object and assigning to asn1Data.currentPosition");

            Logger.writeLog("Setting asn1Data._offsetMap[0]");
            asn1Data.offsetMap[0] = asn1Data.currentPosition;
            Logger.writeLog("Finished Setting asn1Data._offsetMap[0]");
        }
Exemplo n.º 6
0
        static PredictResult Predict(Asn1Data asn1Data, Int64 start, Int32 projectedLength, bool assignMap)
        {
            Int64         levelStart    = start;
            Int64         sum           = 0;
            PredictResult predictResult = new PredictResult();

            predictResult.estimatedChildCount = 0;
            do
            {
                if (start < 0 || start >= asn1Data.RawData.Length || asn1Data.RawData[start] == 0)
                {
                    predictResult.result = false;
                    return(predictResult);
                }
                Int64 pl = CalculatePredictLength(asn1Data, start);
                sum += pl;
                if (assignMap && sum <= projectedLength)
                {
                    asn1Data.offsetMap[start] = new AsnInternalMap {
                        LevelStart = levelStart, LevelEnd = projectedLength
                    };
                }
                start += pl;
                predictResult.estimatedChildCount++;
            } while (sum < projectedLength);
            if (sum != projectedLength)
            {
                predictResult.estimatedChildCount = 0;
            }
            predictResult.result = sum == projectedLength;
            return(predictResult);
        }
Exemplo n.º 7
0
        public static Asn1Data ParseFromRawData(byte[] rawData)
        {
            Logger.writeLog("(Start)FromRawData - Byte[]");
            Asn1Data asn1Data = FromRawData(rawData, 0);

            Logger.writeLog("(End)FromRawData - Byte[]");
            return(asn1Data);
        }
Exemplo n.º 8
0
 public static Byte[] GetHeader(Asn1Data asn1Data)
 {
     return(Neo.SmartContract.Framework.Helper.Range(asn1Data.RawData, asn1Data.Offset, asn1Data.PayloadStartOffset - asn1Data.Offset));
     //return asn1Data.RawData.Take(asn1Data.PayloadStartOffset - asn1Data.Offset);
     //Byte[] newArray = new Byte[asn1Data.PayloadStartOffset - asn1Data.Offset];
     // Array.Copy(asn1Data.RawData, 0, newArray, asn1Data.Offset, asn1Data.PayloadStartOffset - asn1Data.Offset);
     // return newArray;
     // return asn1Data.RawData.Skip(asn1Data.Offset).Take(asn1Data.PayloadStartOffset - asn1Data.Offset).ToArray();
 }
Exemplo n.º 9
0
 public static Int32 BuildOffsetMap(Asn1Data asn1Data)
 {
     Reset(asn1Data);
     do
     {
     } while (MoveNext(asn1Data));
     Reset(asn1Data);
     return(1);//asn1Data._offsetMap.Keys.Size();
 }
Exemplo n.º 10
0
 public static Boolean MoveNextCurrentLevel(Asn1Data asn1Data)
 {
     if (asn1Data.NextCurrentLevelOffset == 0)
     {
         return(false);
     }
     asn1Data.currentPosition = asn1Data.offsetMap[asn1Data.NextCurrentLevelOffset];
     Initialize(asn1Data, null, asn1Data.NextCurrentLevelOffset);
     return(true);
 }
Exemplo n.º 11
0
 public static Boolean MoveNext(Asn1Data asn1Data)
 {
     if (asn1Data.NextOffset == 0)
     {
         return(false);
     }
     //projectedIterationSize = _offsetMap[NextOffset];
     asn1Data.currentPosition = asn1Data.offsetMap[asn1Data.NextOffset];
     Initialize(asn1Data, null, asn1Data.NextOffset);
     return(true);
 }
Exemplo n.º 12
0
        public static long DecodeUTCTime(Byte[] rawData)
        {
            if (rawData == null)
            {
                Logger.writeLog("ERROR-raw data is null");
                return(-1);
            }
            Asn1Data asn1Data = Asn1Parser.ParseFromRawData(rawData);

            return((new Asn1UtcTime(asn)).Value);
        }
Exemplo n.º 13
0
        /*void m_decode(Byte[] rawData) {
         *  asn1Data asn = new asn1Data(rawData);
         *  Init(asn);
         *  tagValue = DateTimeUtils.Decode(asn, out zoneInfo);
         * }*/
        /* protected void Init(asn1Data asn)
         * {
         *   Tag = asn.Tag;
         *   TagName = asn.TagName;
         *   RawData = asn.GetTagRawData();
         * }*/

        public static long Decode(Asn1Data asn1Data)
        {
            if (asn1Data == null)
            {
                throw new ArgumentNullException("asn");
            }
            if (asn1Data.Tag != (Byte)Asn1Type.Generalizedtime)
            {
                //throw new Asn1InvalidTagException("Invalid Type" + tagName);
            }
            return(DateTimeUtils.Decode(asn1Data));
        }
Exemplo n.º 14
0
 public static Boolean MoveToPoisition(Asn1Data asn1Data, Int32 newPosition)
 {
     if (asn1Data.offsetMap == null)
     {
         throw new InvalidOperationException();
     }
     if (asn1Data.offsetMap[newPosition] == null)
     {
         return(false);
     }
     asn1Data.currentPosition = asn1Data.offsetMap[newPosition];
     Initialize(asn1Data, null, newPosition);
     return(true);
 }
Exemplo n.º 15
0
        /*void m_decode(Byte[] rawData) {
         *  asn1Data asn = new asn1Data(rawData);
         *  Init(asn);
         *  tagValue = DateTimeUtils.Decode(asn, out zoneInfo);
         * }*/
        /* protected void Init(asn1Data asn)
         * {
         *   Tag = asn.Tag;
         *   TagName = asn.TagName;
         *   RawData = asn.GetTagRawData();
         * }*/

        public static long Decode(Asn1Data asn1Data)
        {
            if (asn1Data == null)
            {
                Logger.writeLog("Invalid asn1 Data - null");
                return(-1);
            }
            if (asn1Data.Tag != (Byte)Asn1Type.Generalizedtime)
            {
                Logger.writeLog("Unsupported Tag");
                return(-1);
            }
            return(DateTimeUtils.Decode(asn1Data));
        }
Exemplo n.º 16
0
 public static Boolean MoveNext(Asn1Data asn1Data)
 {
     Logger.writeLog("MoveNext-1");
     if (asn1Data.NextOffset == 0)
     {
         Logger.writeLog("MoveNext-2");
         return(false);
     }
     //projectedIterationSize = _offsetMap[NextOffset];
     Logger.writeLog("MoveNext-3");
     asn1Data.currentPosition = asn1Data.offsetMap[asn1Data.NextOffset];
     Logger.writeLog("MoveNext-4");
     Initialize(asn1Data, null, asn1Data.NextOffset);
     Logger.writeLog("MoveNext-5");
     return(true);
 }
Exemplo n.º 17
0
        public static long DecodeDateTime(Byte[] rawData)
        {
            Asn1Data asn1Data = Asn1Parser.ParseFromRawData(rawData);

            switch (asn1Data.Tag)
            {
            case (Byte)Asn1Type.UTCTime: return(Asn1UtcTimeParser.Decode(rawData));

            case (Byte)Asn1Type.Generalizedtime: return(DecodeGeneralizedTime(rawData));

            default:
            {
                return(-1);
            }
            }
        }
Exemplo n.º 18
0
        public static byte[] DecodeDateTime(Asn1Data asn1Data)
        {
            switch (asn1Data.Tag)
            {
            case (Byte)Asn1Type.UTCTime:
                return(Asn1UtcTimeParser.Decode(asn1Data));

            case (Byte)Asn1Type.Generalizedtime:
                return(Asn1GeneralizedTimeParser.Decode(asn1Data));

            default:
            {
                //todo: Handle exceptions
                return(null);
            }
            }
        }
Exemplo n.º 19
0
        public static Asn1Data FromRawData(Byte[] rawData, Int32 offset)
        {
            if (rawData == null)
            {
                Logger.writeLog("ERROR-rawData is null");
                return(null);
            }
            if (rawData.Length < 2)
            {
                Logger.writeLog("ERROR-rawData.Length must be upper than 2");
                return(null);
            }
            Asn1Data asn1Data = new Asn1Data();

            InitMemberDefaultValues(asn1Data);
            Initialize(asn1Data, rawData, offset);
            return(asn1Data);
        }
Exemplo n.º 20
0
        static PredictResult Predict(Asn1Data asn1Data, Int64 start, Int32 projectedLength, bool assignMap)
        {
            Logger.writeLog("Predict-1");
            Int64         levelStart    = start;
            Int64         sum           = 0;
            PredictResult predictResult = new PredictResult();

            predictResult.estimatedChildCount = 0;
            Logger.writeLog("Predict-2");
            do
            {
                Logger.writeLog("Predict-3");
                if (start < 0 || start >= asn1Data.RawData.Length || asn1Data.RawData[start] == 0)
                {
                    Logger.writeLog("Predict-4");
                    predictResult.result = false;
                    return(predictResult);
                }
                Logger.writeLog("Predict-5");
                Int64 pl = CalculatePredictLength(asn1Data, start);
                sum += pl;
                Logger.writeLog("Predict-6");
                if (assignMap && sum <= projectedLength)
                {
                    Logger.writeLog("Predict-7");
                    asn1Data.offsetMap[start] = new AsnInternalMap {
                        LevelStart = levelStart, LevelEnd = projectedLength
                    };
                }
                Logger.writeLog("Predict-8");
                start += pl;
                predictResult.estimatedChildCount++;
            } while (sum < projectedLength);
            Logger.writeLog("Predict-9");
            if (sum != projectedLength)
            {
                Logger.writeLog("Predict-10");
                predictResult.estimatedChildCount = 0;
            }
            Logger.writeLog("Predict-11");
            predictResult.result = sum == projectedLength;
            Logger.writeLog("Predict-12");
            return(predictResult);
        }
Exemplo n.º 21
0
        static void ParseNestedType(Asn1Data asn1Data)
        {
            // processing rules (assuming zero-based bits):
            // if bit 5 is set to "1", or the type is SEQUENCE/SET -- the type is constructed. Unroll nested types.
            // if bit 5 is set to "0", attempt to resolve nested types only for UNIVERSAL tags.
            if (asn1Data.excludedTags.HasKey(asn1Data.Tag) || asn1Data.PayloadLength < 2)
            {
                return;
            }
            Int64 pstart  = asn1Data.PayloadStartOffset;
            Int32 plength = asn1Data.PayloadLength;

            if (asn1Data.Tag == 3)
            {
                pstart  = asn1Data.PayloadStartOffset + 1;
                plength = asn1Data.PayloadLength - 1;
            }

            if (asn1Data.multiNestedTypes.HasKey(asn1Data.Tag) ||
                (asn1Data.Tag & (Byte)Asn1Class.CONSTRUCTED) > 0)
            {
                asn1Data.IsConstructed = true;
                if (!asn1Data.offsetMap.HasKey(pstart))
                {
                    PredictResult predictResult = Predict(asn1Data, pstart, plength, true);
                    asn1Data.childCount = predictResult.estimatedChildCount;
                }
                asn1Data.isTaggedConstructed = false;
                return;
            }
            if (asn1Data.Tag > 0 && asn1Data.Tag < (Byte)Asn1Type.TAG_MASK)
            {
                PredictResult predictResult = Predict(asn1Data, pstart, plength, false);
                asn1Data.childCount    = predictResult.estimatedChildCount;
                asn1Data.IsConstructed = predictResult.result;
                // reiterate again and build map for children
                if (asn1Data.IsConstructed && !asn1Data.offsetMap.HasKey(pstart))
                {
                    PredictResult predictResultOther = Predict(asn1Data, pstart, plength, false);
                    asn1Data.childCount = predictResultOther.estimatedChildCount;
                }
            }
            asn1Data.isTaggedConstructed = false;
        }
Exemplo n.º 22
0
        static void MoveAndExpectTypesWithMoveNext(Asn1Data asn1Data, params Byte[] expectedTypes)
        {
            if (expectedTypes == null)
            {
                throw new ArgumentNullException(nameof(expectedTypes));
            }
            foreach (Byte tag in expectedTypes)
            {
                asn1Data.tmpHTable[tag] = true;
            }
            if (!MoveNext(asn1Data))
            {
                //throw new InvalidDataException("The data is invalid.");
            }

            // if (!asn1Data.tmpHTable.HasKey(asn1Data.Tag))
            {
                // throw new Asn1InvalidTagException();
            }
        }
Exemplo n.º 23
0
        static void MoveAndExpectTypesWithMoveNext(Asn1Data asn1Data, params Byte[] expectedTypes)
        {
            if (expectedTypes == null)
            {
                throw new ArgumentNullException(nameof(expectedTypes));
            }
            foreach (Byte tag in expectedTypes)
            {
                asn1Data.tmpHTable[tag] = true;
            }
            if (!MoveNext(asn1Data))
            {
                Logger.writeLog("ERROR-Data is invalid");
                return;
            }

            if (!asn1Data.tmpHTable.HasKey(asn1Data.Tag))
            {
                Logger.writeLog("ERROR-Invalid Tag");
            }
        }
Exemplo n.º 24
0
        static Int64 CalculatePredictLength(Asn1Data asn1Data, Int64 offset)
        {
            Logger.writeLog("CalculatePredictLength-1");
            if (offset + 1 >= asn1Data.RawData.Length || offset < 0)
            {
                Logger.writeLog("CalculatePredictLength-2");
                return(Int32.MaxValue);
            }
            Logger.writeLog("CalculatePredictLength-3");
            if (asn1Data.RawData[offset + 1] < 128)
            {
                Logger.writeLog("CalculatePredictLength-4");
                return(asn1Data.RawData[offset + 1] + 2);
            }
            Logger.writeLog("CalculatePredictLength-5");
            Int32 lengthbytes = asn1Data.RawData[offset + 1] - 128;

            Logger.writeLog("CalculatePredictLength-6");
            // max length can be encoded by using 4 bytes.
            if (lengthbytes > 4)
            {
                Logger.writeLog("CalculatePredictLength-7");
                return(Int32.MaxValue);
            }
            Logger.writeLog("CalculatePredictLength-8");
            Int32 ppayloadLength = asn1Data.RawData[offset + 2];

            Logger.writeLog("CalculatePredictLength-9");
            for (Int64 i = offset + 3; i < offset + 2 + lengthbytes; i++)
            {
                Logger.writeLog("CalculatePredictLength-10");
                ppayloadLength = (ppayloadLength << 8) | asn1Data.RawData[i];
            }
            Logger.writeLog("CalculatePredictLength-11");
            // 2 -- transitional + tag
            return(ppayloadLength + lengthbytes + 2);
        }
Exemplo n.º 25
0
        static Boolean MoveAndExpectTypesWithMoveNextCurrentLevel(Asn1Data asn1Data, params Byte[] expectedTypes)
        {
            if (expectedTypes == null)
            {
                return(false);
            }

            foreach (Byte tag in expectedTypes)
            {
                asn1Data.tmpHTable[tag] = true;
            }
            if (!MoveNextCurrentLevel(asn1Data))
            {
                return(false);
            }

            if (!asn1Data.tmpHTable.HasKey(asn1Data.Tag))
            {
                Logger.writeLog("Not Found Value");
                return(false);
                //throw new Asn1InvalidTagException();
            }
            return(true);
        }
Exemplo n.º 26
0
        static void InitMemberDefaultValues(Asn1Data asn1Data)
        {
            asn1Data.excludedTags     = new Map <byte, bool>();
            asn1Data.offsetMap        = new Map <Int64, AsnInternalMap>();
            asn1Data.multiNestedTypes = new Map <byte, bool>();
            asn1Data.tmpHTable        = new Map <byte, bool>();

            asn1Data.excludedTags[0]  = true;
            asn1Data.excludedTags[1]  = true;
            asn1Data.excludedTags[2]  = true;
            asn1Data.excludedTags[5]  = true;
            asn1Data.excludedTags[6]  = true;
            asn1Data.excludedTags[9]  = true;
            asn1Data.excludedTags[10] = true;
            asn1Data.excludedTags[13] = true;

            asn1Data.multiNestedTypes[(Byte)Asn1Type.SEQUENCE] = true;
            asn1Data.multiNestedTypes[(Byte)((Byte)Asn1Type.SEQUENCE | (Byte)Asn1Class.CONSTRUCTED)] = true;
            asn1Data.multiNestedTypes[(Byte)Asn1Type.SET] = true;
            asn1Data.multiNestedTypes[(Byte)((Byte)Asn1Type.SET | (Byte)Asn1Class.CONSTRUCTED)] = true;
            asn1Data.currentPosition = new AsnInternalMap();

            asn1Data.offsetMap[0] = asn1Data.currentPosition;
        }
Exemplo n.º 27
0
        static String DecodeUtcTime(Asn1Data asn1Data)
        {
            DateTime dt = Asn1UtcTime.Decode(asn);

            return(dt.ToShortDateString() + " " + dt.ToShortTimeString());
        }
Exemplo n.º 28
0
        public static bool Initialize(Asn1Data asn1Data, Byte[] raw, Int32 pOffset)
        {
            asn1Data.IsConstructed = false;
            if (raw != null)
            {
                asn1Data.RawData = raw;
            }
            asn1Data.Offset = pOffset;
            asn1Data.Tag    = asn1Data.RawData[asn1Data.Offset];
            CalculateLength(asn1Data);
            // strip possible unnecessary bytes
            if (raw != null && asn1Data.TagLength != asn1Data.RawData.Length)
            {
                asn1Data.RawData = raw.Take(asn1Data.TagLength);
            }
            GetTagName(asn1Data, asn1Data.Tag);
            // 0 Tag is reserved for BER and is not available in DER
            if (asn1Data.Tag == 0)
            {
                Logger.writeLog("ERROR-Invalid tag");
                return(false);
                //throw new Asn1InvalidTagException(asn1Data.Offset);
            }
            Logger.writeLog("Initialize-11");
            if (asn1Data.PayloadLength == 0)
            {
                Logger.writeLog("Initialize-12");
                int rawDataLength      = asn1Data.RawData.Length;
                int offsetAndTagLength = asn1Data.Offset + asn1Data.TagLength;
                if (offsetAndTagLength == rawDataLength)
                {
                    Logger.writeLog("Initialize-13");
                    asn1Data.NextOffset = 0;
                }
                else
                {
                    Logger.writeLog("Initialize-14");
                    asn1Data.NextOffset = offsetAndTagLength;
                }

                Logger.writeLog("Initialize-15");
                // TODO check this
                if (asn1Data.currentPosition.LevelEnd == 0 ||
                    asn1Data.Offset - asn1Data.currentPosition.LevelStart + asn1Data.TagLength == asn1Data.currentPosition.LevelEnd)
                {
                    Logger.writeLog("Initialize-16");
                    asn1Data.NextCurrentLevelOffset = 0;
                }
                else
                {
                    Logger.writeLog("Initialize-17");
                    asn1Data.NextCurrentLevelOffset = asn1Data.NextOffset;
                }
                Logger.writeLog("Initialize-18");
                //NextCurrentLevelOffset = NextOffset;
                return;
            }

            Logger.writeLog("Initialize-19");
            ParseNestedType(asn1Data);
            Logger.writeLog("Initialize-20");
            if (asn1Data.Offset - asn1Data.currentPosition.LevelStart + asn1Data.TagLength < asn1Data.currentPosition.LevelEnd)
            {
                Logger.writeLog("Initialize-21");
                asn1Data.NextCurrentLevelOffset = asn1Data.Offset + asn1Data.TagLength;
            }
            else
            {
                Logger.writeLog("Initialize-21");
                asn1Data.NextCurrentLevelOffset = 0;
            }

            if (asn1Data.IsConstructed)
            {
                Logger.writeLog("Initialize-23");
                if (asn1Data.Tag == 3)
                {
                    Logger.writeLog("Initialize-24");
                    asn1Data.NextOffset = asn1Data.PayloadStartOffset + 1;
                }
                else
                {
                    Logger.writeLog("Initialize-25");
                    asn1Data.NextOffset = asn1Data.PayloadStartOffset;
                }
            }
            else
            {
                Logger.writeLog("Initialize-26");
                if (asn1Data.Offset + asn1Data.TagLength < asn1Data.RawData.Length)
                {
                    Logger.writeLog("Initialize-27");
                    asn1Data.NextOffset = asn1Data.Offset + asn1Data.TagLength;
                }
                else
                {
                    Logger.writeLog("Initialize-28");
                    asn1Data.NextOffset = 0;
                }
            }
        }
Exemplo n.º 29
0
 static void Init(Asn1Data asn1Data, Asn1GeneralizedTime asn1GeneralizedTime)
 {
     asn1GeneralizedTime.Tag     = asn1Data.Tag;
     asn1GeneralizedTime.TagName = asn1Data.TagName;
     asn1GeneralizedTime.RawData = Asn1Parser.GetTagRawData(asn1Data);
 }
Exemplo n.º 30
0
 static Asn1Data Decode(Asn1Data asn1Data, Asn1GeneralizedTime asn1GeneralizedTime)
 {
     Init(asn1Data, asn1GeneralizedTime);
     asn1GeneralizedTime.tagValue = DateTimeUtils.Decode(asn1Data);
     return(asn1Data);
 }