Пример #1
0
        public static bool Verify(NetInt64ListSigned int64lst, byte[] cer)
        {
            if (int64lst == null)
            {
                return(false);
            }
            if (int64lst.data == null)
            {
                return(false);
            }
            if (int64lst.data.TimeStampCheck > DateTime.Now.ToUniversalTime().AddMinutes(TimeStampPlusMinus) &&
                int64lst.data.TimeStampCheck < DateTime.Now.ToUniversalTime().AddMinutes(-TimeStampPlusMinus))
            {
                Debug.WriteLine("Timestamp missmatch -+" + TimeStampPlusMinus.ToString() + " minutes");
                return(false);
            }
            string JSON = JsonConvert.SerializeObject(int64lst.data, Formatting.None);

            if (Verify(Encoding.UTF8.GetBytes(JSON), int64lst.Signature, cer) == false)
            {
                Debug.WriteLine("Verify failed");
                return(false);
            }
            return(true);
        }
Пример #2
0
        public static bool Sign(NetInt64ListSigned intlist, string CN)
        {
            if (intlist == null)
            {
                return(false);
            }
            if (intlist.data == null)
            {
                return(false);
            }
            intlist.data.TimeStampCheck = DateTime.Now.ToUniversalTime();
            string JSON = JsonConvert.SerializeObject(intlist.data, Formatting.None);

            intlist.Signature = Sign(Encoding.UTF8.GetBytes(JSON), CN, StoreLocation.LocalMachine);
            if (intlist.Signature == null)
            {
                return(false);
            }
            return(true);
        }