Remove channel keys and hamcs after LEAVE command.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 15 Nov 2007 16:32:32 +0000 (16:32 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 15 Nov 2007 16:32:32 +0000 (16:32 +0000)
CHANGES
lib/silcclient/command_reply.c

diff --git a/CHANGES b/CHANGES
index 36a87acd713340abbec7aa021ad3a3388f81dbc5..63bd5cc8e78ba1bf9809b5deef1b12e850a6c584 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,9 @@ Thu Nov 15 18:03:53 EET 2007  Pekka Riikonen <priikone@silcnet.org>
          resolving user and must not save the old key.  Affected file
          is lib/silcclient/command_reply.c.
 
+       * Remove all channel keys and hmacs after giving LEAVE command.
+         Affected file is lib/silcclient/command_reply.c.
+
 Tue Nov 13 18:24:56 EET 2007  Pekka Riikonen <priikone@silcnet.org>
 
        * Added missing channel unreferencing in CMODE, CUMODE,
index 2fec85c6b8da502d97636ec479a49b57de849f7b..910aab545be02edd180c36a8dbc8e3cca64077fb 100644 (file)
@@ -1778,6 +1778,8 @@ SILC_FSM_STATE(silc_client_command_reply_leave)
   SilcCommandPayload payload = state_context;
   SilcArgumentPayload args = silc_command_get_args(payload);
   SilcChannelEntry channel;
+  SilcCipher key;
+  SilcHmac hmac;
   SilcID id;
 
   /* Sanity checks */
@@ -1803,6 +1805,32 @@ SILC_FSM_STATE(silc_client_command_reply_leave)
   /* Notify application */
   silc_client_command_callback(cmd, channel);
 
+  /* Remove old keys and stuff.  The channel may remain even after leaving
+     but we want to remove these always. */
+  if (channel->internal.send_key)
+    silc_cipher_free(channel->internal.send_key);
+  channel->internal.send_key = NULL;
+  if (channel->internal.receive_key)
+    silc_cipher_free(channel->internal.receive_key);
+  channel->internal.receive_key = NULL;
+  if (channel->internal.hmac)
+    silc_hmac_free(channel->internal.hmac);
+  channel->internal.hmac = NULL;
+  if (channel->internal.old_channel_keys) {
+    silc_dlist_start(channel->internal.old_channel_keys);
+    while ((key = silc_dlist_get(channel->internal.old_channel_keys)))
+      silc_cipher_free(key);
+    silc_dlist_uninit(channel->internal.old_channel_keys);
+  }
+  channel->internal.old_channel_keys = NULL;
+  if (channel->internal.old_hmacs) {
+    silc_dlist_start(channel->internal.old_hmacs);
+    while ((hmac = silc_dlist_get(channel->internal.old_hmacs)))
+      silc_hmac_free(hmac);
+    silc_dlist_uninit(channel->internal.old_hmacs);
+  }
+  channel->internal.old_hmacs = NULL;
+
   /* Now delete the channel. */
   silc_client_empty_channel(client, conn, channel);
   silc_client_del_channel(client, conn, channel);