Пример #1
0
        public DevViewModel GetDevViewModel(string devId)
        {
            DevViewModel vm = new DevViewModel();
            vm.Id = devId;
            vm.ASCLink = GetASCLink(devId);
            vm.MessageLink = GetSigLink(devId);
            vm.FriendlyName = GetFriendlyName(devId);
            string sig = null;
            byte[] pubkey = null;
            try
            {
                var client = new WebClient();
                client.Encoding = Encoding.UTF8;
                sig = client.DownloadString(vm.MessageLink);
                pubkey = client.DownloadData(vm.ASCLink);
            }
            catch
            {
            }
            if(sig == null || pubkey == null)
                return vm;

            string message;
            if(!CryptoHelper.VerifySig(pubkey, sig, out message))
                return vm;
            vm.Load(message);
            return vm;
        }
Пример #2
0
        public void CanCheckSig()
        {
            var pubkey = File.ReadAllBytes("../../Data/nico.asc");
            var sig = File.ReadAllText("../../Data/signature.sig");
            string txt = null;
            var result = CryptoHelper.VerifySig(pubkey, sig, out txt);
            DevViewModel dev = new DevViewModel();
            dev.Load(txt);
            Assert.True(dev.Opinions.Count == 2);
            Assert.True(result);

            pubkey = File.ReadAllBytes("../../Data/nico.pgp");
            Assert.True(CryptoHelper.VerifySig(pubkey, sig, out txt));

            Assert.True(CryptoHelper.VerifySig(CryptoHelper.ToAsc(pubkey), sig, out txt));
        }