virtual protected void OnNegotiation(InitiateNegotiationEventArgs e)
 {
     if (NegotiationEventHandler != null)
     {
         NegotiationEventHandler(this, e);
     }
 }
        public void _clientHandler_InitiateNegotiation(object sender, InitiateNegotiationEventArgs e)
        {
            try
            {
                foreach (IMLibrary.Client client in e.ClientList)
                {
                    if (GeneratedClientList.Count(cli => cli.UserName == client.UserName) == 0)
                    {
                        //generate a new key/salt pair with the correct public key and negotiate with the client
                        Tuple <byte[], byte[]> unencryptedKeySaltPair = GenerateUnencryptedKeySaltPair();
                        Tuple <byte[], byte[]> encryptedKeySalePair   = EncryptKeySaltPair(client.PublicKey, unencryptedKeySaltPair);
                        _clientHandler.NegotiateSymmetricKeys(encryptedKeySalePair, client.UserName);

                        if (this._clientKeyIvDictionary.ContainsKey(client.UserName))
                        {
                            this._clientKeyIvDictionary.Remove(client.UserName);
                        }
                        this._clientKeyIvDictionary.Add(client.UserName, unencryptedKeySaltPair);
                    }
                }
            }
            catch
            {
            }
        }