예제 #1
0
파일: db.cs 프로젝트: RSA-PM/RSA-PM
 void Store(Client.Message msg)
 {
     var idq = conn.Query<long>("select id from inbox order by id desc limit 1", new { });
     long id = idq.Count() == 0 ? 1 : idq.First() + 1;
     var iv = ArrayrXor(inbox_iv, id);
     var buf2 = new byte[msg.unencrypted.Length + 4];
     Array.Copy(BitConverter.GetBytes(GetMsgPrv.id), buf2, 4);
     Array.Copy(msg.unencrypted, 0, buf2, 4, msg.unencrypted.Length);
     conn.Execute("insert into inbox(id, msg) select @id, @msg", new { id = id, msg = enc(buf2, iv) });
 }
예제 #2
0
파일: Program.cs 프로젝트: RSA-PM/RSA-PM
            public void Run()
            {
                RSAParameters serv_pub;
                Shared.LoadKey(@"pub.txt", null, out serv_pub);
                var client = new Client("localhost", 12345, null, 0, serv_pub);

                prv = Utils.openssl_CreatePrvKey();
                pub = Utils.ExtractPublicKey(prv);
                client.RegisterPublicKey(prv, pub);
                var prv2 = prv;
                //prv = null; //for unsigned notes
                var msgid = client.SendMessage(pub, null, "some text to test with", prv, pub);
                client.SendMessage(pub, msgid, "sidohfaodshgadshfsidohfaodshgadshfsidohfaodshgadshfsidohfaodshgadshfsidohfaodshgadshfsidohfaodshgadshfsidohfaodshgadshf", prv, pub);
                prv = prv2;
                client.GetMessage(prv, pub, Store);
                client.UnregisterPublicKey(prv, pub);
            }
예제 #3
0
파일: db.cs 프로젝트: RSA-PM/RSA-PM
        public bool newprv(byte[] prv, string name, Client client)
        {
            foreach (var v in GetPrivateKeys())
            {
                if (prv.ArraysEqual(v.key))
                {
                    return false;//already exist
                }
            }

            var id1 = conn.Query<long>("select id from prvkeys order by id desc limit 1", new { });
            long id = id1.Count() == 0 ? 1 : id1.First() + 1;
            var iv = ArrayrXor(prvkey_iv, id);
            var obj = new { id = id, k = enc(prv, iv), n = enc(name, iv), d = enc(0, iv) };
            client.RegisterPublicKey(prv, Utils.ExtractPublicKey(prv));
            conn.Execute("insert into prvkeys(id, key, name, last_date) select @id, @k, @n, @d", obj);
            prvkeys.Add(new Private_Keys() { id = id, key = prv, name = name, visit_date = 0 });
            return true;
        }