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.
/* 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) {
/* 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;
if (channel->internal.hmac)
silc_hmac_free(channel->internal.hmac);
channel->internal.hmac = newhmac;
silc_client_ref_channel(client, conn, channel);
}
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) {
/* Get the list count */
tmp = silc_argument_get_arg_type(args, 12, &len);
if (!tmp) {
- /* 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)
/* Get channel mode */
tmp = silc_argument_get_arg_type(args, 5, &len);
if (tmp && len == 4)