From 64c849a860a28942c45268d27e4f1296c0e9a5f9 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 15 Nov 2007 16:33:01 +0000 Subject: [PATCH] Removed channel keys and hmacs after LEAVE command. --- CHANGES.TOOLKIT | 3 +++ lib/silcclient/command_reply.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CHANGES.TOOLKIT b/CHANGES.TOOLKIT index bd514cef..6af09f12 100644 --- a/CHANGES.TOOLKIT +++ b/CHANGES.TOOLKIT @@ -18,6 +18,9 @@ Thu Nov 15 16:45:48 EET 2007 Pekka Riikonen 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 * Added missing channel unreferencing in CMODE, CUMODE, diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index cf2743af..bf80d064 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -1814,6 +1814,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 */ @@ -1839,6 +1841,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); -- 2.24.0