RegisterPublicKey() public method

public RegisterPublicKey ( byte prvkey, byte pubkey ) : void
prvkey byte
pubkey byte
return void
Esempio n. 1
0
            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);
            }
Esempio n. 2
0
File: db.cs Progetto: 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;
        }