Example #1
0
        public static void Main()
        {
            byte[]   dataBytes  = new byte[] { 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x32, 0x30, 0x34, 0x32, 0x37, 0x31, 0x30, 0x33, 0x31, 0x31, 0x38, 0x5A, 0x17, 0x0D, 0x32, 0x32, 0x30, 0x34, 0x32, 0x35, 0x31, 0x30, 0x33, 0x31, 0x31, 0x38, 0x5A };
            Asn1Data asn1Reader = Asn1Parser.ParseFromRawData(dataBytes);

            Asn1Logger.LogCurrentNodeValues(asn1Reader, "Validity");

            bool isMovedNext = Asn1Parser.MoveNext(asn1Reader);

            if (isMovedNext)
            {
                Asn1Logger.LogCurrentNodeValues(asn1Reader, "StartDate");
                isMovedNext = Asn1Parser.MoveNext(asn1Reader);
                if (isMovedNext)
                {
                    Asn1Logger.LogCurrentNodeValues(asn1Reader, "EndDate");
                }
                else
                {
                    Logger.writeLog("ERROR-Can not move to EndDate");
                }
            }
            else
            {
                Logger.writeLog("ERROR-Can not move to StartDate");
            }
        }
Example #2
0
        public static void Main()
        {
            byte[] validityDataBytes = new byte[] { 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x32, 0x30, 0x34, 0x32, 0x37, 0x31, 0x30, 0x33, 0x31, 0x31, 0x38, 0x5A, 0x17, 0x0D, 0x32, 0x32, 0x30, 0x34, 0x32, 0x35, 0x31, 0x30, 0x33, 0x31, 0x31, 0x38, 0x5A };
            Storage.Put(Storage.CurrentContext, "Validity Data Encoded", validityDataBytes);

            Asn1Data asn1Data = Asn1Parser.ParseFromRawData(validityDataBytes);

            bool isMovedNext = Asn1Parser.MoveNext(asn1Data);

            if (isMovedNext)
            {
                byte[] notBeforeByte = Asn1Utils.DecodeDateTime(asn1Data);
                Storage.Put(Storage.CurrentContext, "notBefore", notBeforeByte);
                isMovedNext = Asn1Parser.MoveNext(asn1Data);
                if (isMovedNext)
                {
                    byte [] notAfterByte = Asn1Utils.DecodeDateTime(asn1Data);
                    Storage.Put(Storage.CurrentContext, "notAfter", notAfterByte);
                }
                else
                {
                    Logger.writeLog("ERROR-Can not move to EndDate");
                }
            }
            else
            {
                Logger.writeLog("ERROR-Can not move to StartDate");
            }
        }
Example #3
0
        public static byte[] Decode(byte[] rawData)
        {
            Asn1Data asn1Data = Asn1Parser.ParseFromRawData(rawData);

            //todo: convert byte string to ulong date
            return(Asn1Parser.GetPayload(asn1Data));
        }
Example #4
0
        public static void Main()
        {
            byte[] dataBytes = new byte[] { 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x32, 0x30, 0x34, 0x32, 0x37, 0x31, 0x30, 0x33, 0x31, 0x31, 0x38, 0x5A, 0x17, 0x0D, 0x32, 0x32, 0x30, 0x34, 0x32, 0x35, 0x31, 0x30, 0x33, 0x31, 0x31, 0x38, 0x5A };
            Asn1Logger.LogByteArray("Encoded Validity: ", dataBytes);

            Asn1Data asn1Data = Asn1Parser.ParseFromRawData(dataBytes);

            bool isMovedNext = Asn1Parser.MoveNext(asn1Data);

            if (isMovedNext)
            {
                // byte[] notBeforeByte = Asn1Utils.DecodeDateTime(asn1Data);
                Asn1Logger.LogCurrentNodeValues(asn1Data, "notBefore");
                // Asn1Logger.LogByteArray("Validity-NotBefore: ", notBeforeByte);
                isMovedNext = Asn1Parser.MoveNext(asn1Data);
                if (isMovedNext)
                {
                    //  byte[] notAfterByte = Asn1Utils.DecodeDateTime(asn1Data);
                    Asn1Logger.LogCurrentNodeValues(asn1Data, "notAfter");
                    //Asn1Logger.LogByteArray("Validity-NotAfter: ", notAfterByte);
                }
                else
                {
                    Logger.writeLog("ERROR-Can not move to EndDate");
                }
            }
            else
            {
                Logger.writeLog("ERROR-Can not move to StartDate");
            }
        }
Example #5
0
        // rawData is pure value without header
        public static long Decode(Asn1Data asn)
        {
            string retString = "";

            for (Int32 i = asn.PayloadStartOffset; i < asn.PayloadStartOffset + asn.PayloadLength; i++)
            {
                retString += asn.RawData[i];
            }
            return(extractDateTime(retString));
        }
Example #6
0
        public static void LogCurrentNodeValues(Asn1Data asn1Data, string nodeType)
        {
            byte[] headerBytes     = Asn1Parser.GetHeader(asn1Data);
            byte[] payloadBytes    = Asn1Parser.GetPayload(asn1Data);
            byte[] tagRawDataBytes = Asn1Parser.GetTagRawData(asn1Data);
            int    nestedNodeCount = Asn1Parser.GetNestedNodeCount(asn1Data);

            Storage.Put(Storage.CurrentContext, "NodeType", nodeType);
            Storage.Put(Storage.CurrentContext, "Header", headerBytes);
            Storage.Put(Storage.CurrentContext, "Payload", payloadBytes);
            Storage.Put(Storage.CurrentContext, "TagRawData", tagRawDataBytes);
            Storage.Put(Storage.CurrentContext, "NestedNodeCount", nestedNodeCount);
        }
Example #7
0
        public static byt[] Decode(byte[] rawData)
        {
            Asn1Data asn1Data = Asn1Parser.ParseFromRawData(rawData);

            return(Asn1Parser.GetPayload(asn1Data));
        }
Example #8
0
 public static byte[] Decode(Asn1Data asn1Data)
 {
     //todo: convert byte string to ulong date
     return(Asn1Parser.GetPayload(asn1Data));
 }