Fixed channel MAC key setting in JOIN notify and command reply silc.client.1.1.6 silc.server.1.1.14 silc.toolkit.1.1.8
authorPekka Riikonen <priikone@silcnet.org>
Sat, 25 Oct 2008 13:58:50 +0000 (16:58 +0300)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 25 Oct 2008 13:58:50 +0000 (16:58 +0300)
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.

lib/silcclient/client_notify.c
lib/silcclient/command_reply.c

index 2ccb574c1ac8a384d7fd6a36939e8a0c5b097e52..e855e41294908770b228663fc8bbee824eb79c8f 100644 (file)
@@ -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;
index 29e05e73fe086b419299d922f1e196da594b2cfa..7a7fa2b1028af8507218c5aff3c5a2e5c54391ad 100644 (file)
@@ -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)