virtual protected void OnKeyNegotiation(KeyNegotiationEventArgs e) { if (KeyNegotiationEventHandler != null) { KeyNegotiationEventHandler(this, e); } }
private void _clientHandler_KeyNegotiationEventHandler(object sender, KeyNegotiationEventArgs e) { Application.Current.Dispatcher.Invoke(new Action(() => { string encryptedKeyAsString = System.Text.Encoding.Unicode.GetString(e.KeyVectorCombo.Item1); string encryptedSaltAsString = System.Text.Encoding.Unicode.GetString(e.KeyVectorCombo.Item2); string plainTextKeyAsString = Cryptography.DecryptData(encryptedKeyAsString); string plainTextSaltAsString = Cryptography.DecryptData(encryptedSaltAsString); byte[] key = System.Text.Encoding.Unicode.GetBytes(plainTextKeyAsString); byte[] salt = System.Text.Encoding.Unicode.GetBytes(plainTextSaltAsString); try { if (this._clientKeyIvDictionary.ContainsKey(e.SenderUsername)) { this._clientKeyIvDictionary.Remove(e.SenderUsername); } this._clientKeyIvDictionary.Add(e.SenderUsername, new Tuple <byte[], byte[]>(key, salt)); } catch { } })); }