Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var masterKeyForm = new MasterKey();

            masterKeyForm.ShowDialog();
            GetMasterKey(masterKeyForm.Result);


            if (File.Exists("RSAKey.bin"))
            {
                var serialize = Encoding.UTF8.GetString(AES.Decrypt(File.ReadAllBytes("RSAKey.bin"), masterAESKey, masterAESIV));
                keyPair = new RSAKeyPair(
                    Serializer.DeserializeKey(serialize.Split('$')[0])
                    );
                generateRSAButton.Enabled   = false;
                getSessionKeyButton.Enabled = true;
            }
            else
            {
                generateRSAButton.Enabled   = true;
                getSessionKeyButton.Enabled = false;
            }

            loginRejected.Visible = false;
            toggleLoginForm(false);
        }
Beispiel #2
0
        private void generateRSAButton_Click(object sender, EventArgs e)
        {
            getSessionKeyButton.Enabled = true;
            generateRSAButton.Enabled   = false;

            keyPair = new RSAKeyPair();
            var serialized       = Serializer.SerializeKey(keyPair.privateKey) + "$";
            var keyPairEncrypted = AES.Encrypt(Encoding.UTF8.GetBytes(serialized), masterAESKey, masterAESIV);

            File.WriteAllBytes("RSAKey.bin", keyPairEncrypted);
        }
Beispiel #3
0
 public Connection(TcpClient client, RSAKeyPair keys)
 {
     this.keys   = keys;
     this.client = client;
 }