must re-generate the channel key. */
silc_hash_table_list(channels, &htl);
while (silc_hash_table_get(&htl, NULL, (void *)&channel)) {
- silc_server_create_channel_key(server, channel, 0);
+ if (!silc_server_create_channel_key(server, channel, 0))
+ return FALSE;
silc_server_send_channel_key(server, NULL, channel,
server->server_type == SILC_ROUTER ?
FALSE : !server->standalone);
if (keygen && !(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
/* Re-generate channel key */
- silc_server_create_channel_key(server, channel, 0);
+ if (!silc_server_create_channel_key(server, channel, 0))
+ return;
/* Send the channel key to the channel. The key of course is not sent
to the client who was removed from the channel. */
entry->hmac_name = strdup(hmac);
/* Now create the actual key material */
- silc_server_create_channel_key(server, entry,
- silc_cipher_get_key_len(key) / 8);
+ if (!silc_server_create_channel_key(server, entry,
+ silc_cipher_get_key_len(key) / 8)) {
+ silc_free(channel_name);
+ silc_cipher_free(key);
+ silc_hmac_free(newhmac);
+ silc_free(entry->cipher);
+ silc_free(entry->hmac_name);
+ return NULL;
+ }
/* Notify other routers about the new channel. We send the packet
to our primary route. */
}
/* Now create the actual key material */
- silc_server_create_channel_key(server, entry,
- silc_cipher_get_key_len(key) / 8);
+ if (!silc_server_create_channel_key(server, entry,
+ silc_cipher_get_key_len(key) / 8)) {
+ silc_free(channel_name);
+ return NULL;
+ }
/* Notify other routers about the new channel. We send the packet
to our primary route. */
SilcServerChannelRekey rekey = (SilcServerChannelRekey)context;
SilcServer server = (SilcServer)rekey->context;
- silc_server_create_channel_key(server, rekey->channel, rekey->key_len);
+ if (!silc_server_create_channel_key(server, rekey->channel, rekey->key_len))
+ return;
silc_server_send_channel_key(server, NULL, rekey->channel, FALSE);
silc_schedule_task_add(server->schedule, 0,
but also to re-generate new key for channel. If `key_len' is provided
it is the bytes of the key length. */
-void silc_server_create_channel_key(SilcServer server,
- SilcChannelEntry channel,
- uint32 key_len)
+int silc_server_create_channel_key(SilcServer server,
+ SilcChannelEntry channel,
+ uint32 key_len)
{
int i;
unsigned char channel_key[32], hash[32];
if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY) {
SILC_LOG_DEBUG(("Channel has private keys, will not generate new key"));
- return;
+ return TRUE;
}
if (!channel->channel_key)
if (!silc_cipher_alloc("aes-256-cbc", &channel->channel_key))
- return;
+ return FALSE;
if (key_len)
len = key_len;
SILC_TASK_TIMEOUT,
SILC_TASK_PRI_NORMAL);
}
+
+ return TRUE;
}
/* Saves the channel key found in the encoded `key_payload' buffer. This