From: Pekka Riikonen Date: Sat, 25 Oct 2008 13:58:50 +0000 (+0300) Subject: Fixed channel MAC key setting in JOIN notify and command reply X-Git-Tag: silc.server.1.1.14^0 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=711fe01f210030b40ce0aeceb1c18526632ba5b8 Fixed channel MAC key setting in JOIN notify and command reply In JOIN notify when MAC algo changes wrong key was set to the new MAC. In JOIN command reply in backup router the channel key may not be set in command reply because backup reiceives also CHANNEL_KEY packet from router and hence clients receive it too, but new MAC context was still allocated in the command reply, hence using empty MAC without key with channel messages. --- diff --git a/lib/silcclient/client_notify.c b/lib/silcclient/client_notify.c index 2ccb574c..e855e412 100644 --- a/lib/silcclient/client_notify.c +++ b/lib/silcclient/client_notify.c @@ -918,9 +918,7 @@ SILC_FSM_STATE(silc_client_notify_cmode_change) /* Get HMAC key from the old HMAC context, and update it to the new one */ tmp = (unsigned char *)silc_hmac_get_key(channel->internal.hmac, &tmp_len); if (tmp) { - silc_hash_make(silc_hmac_get_hash(newhmac), tmp, tmp_len, hash); - silc_hmac_set_key(newhmac, hash, - silc_hash_len(silc_hmac_get_hash(newhmac))); + silc_hmac_set_key(newhmac, tmp, tmp_len); if (channel->internal.hmac) silc_hmac_free(channel->internal.hmac); channel->internal.hmac = newhmac; diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index 29e05e73..7a7fa2b1 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -1172,6 +1172,17 @@ SILC_FSM_STATE(silc_client_command_reply_join) silc_client_ref_channel(client, conn, channel); } + /* Get hmac */ + hmac = silc_argument_get_arg_type(args, 11, NULL); + if (hmac && !silc_hmac_is_supported(hmac)) { + if (cmd->verbose) + SAY(client, conn, SILC_CLIENT_MESSAGE_COMMAND_ERROR, + "Cannot join channel: Unsupported HMAC `%s'", hmac); + ERROR_CALLBACK(SILC_STATUS_ERR_UNKNOWN_ALGORITHM); + silc_rwlock_unlock(channel->internal.lock); + goto out; + } + /* Get the list count */ tmp = silc_argument_get_arg_type(args, 12, &len); if (!tmp) { @@ -1245,19 +1256,6 @@ SILC_FSM_STATE(silc_client_command_reply_join) } } - /* Get hmac */ - hmac = silc_argument_get_arg_type(args, 11, NULL); - if (hmac) { - if (!silc_hmac_alloc(hmac, NULL, &channel->internal.hmac)) { - if (cmd->verbose) - SAY(client, conn, SILC_CLIENT_MESSAGE_COMMAND_ERROR, - "Cannot join channel: Unsupported HMAC `%s'", hmac); - ERROR_CALLBACK(SILC_STATUS_ERR_UNKNOWN_ALGORITHM); - silc_rwlock_unlock(channel->internal.lock); - goto out; - } - } - /* Get channel mode */ tmp = silc_argument_get_arg_type(args, 5, &len); if (tmp && len == 4)