channel key receiving and setting, and channel private key handling
routines. */
-#include "clientlibincludes.h"
+#include "silcincludes.h"
+#include "silcclient.h"
#include "client_internal.h"
/* Sends packet to the `channel'. Packet to channel is always encrypted
SilcChannelPrivateKey key,
SilcMessageFlags flags,
unsigned char *data,
- uint32 data_len,
+ SilcUInt32 data_len,
int force_send)
{
int i;
SilcCipher cipher;
SilcHmac hmac;
unsigned char *id_string;
- uint32 iv_len;
+ SilcUInt32 iv_len;
int block_len;
SILC_LOG_DEBUG(("Sending packet to channel"));
static void silc_client_channel_message_cb(SilcClient client,
SilcClientConnection conn,
SilcClientEntry *clients,
- uint32 clients_count,
+ SilcUInt32 clients_count,
void *context)
{
SilcChannelClientResolve res = (SilcChannelClientResolve)context;
if (!channel)
goto out;
+ /* If this client is not on channel, add it there since it clearly
+ is there. */
+ if (!silc_client_on_channel(channel, clients[0])) {
+ SilcChannelUser chu = silc_calloc(1, sizeof(*chu));
+ chu->client = clients[0];
+ chu->channel = channel;
+ silc_hash_table_add(channel->user_list, clients[0], chu);
+ silc_hash_table_add(clients[0]->channels, channel, chu);
+ }
+
message = silc_channel_message_get_data(res->payload, NULL);
/* Pass the message to application */
we will use the old key in decryption. If that fails too then we
cannot do more and will drop the packet. */
if (!payload) {
- SILC_LOG_ERROR(("decr failed"));
if (!channel->old_channel_key) {
- SILC_LOG_ERROR(("no old key"));
goto out;
}
channel->old_channel_key,
channel->old_hmac);
if (!payload) {
- SILC_LOG_ERROR(("old decr failed"));
goto out;
}
}
SilcChannelEntry channel)
{
unsigned char *id_string, *key, *cipher, *hmac, hash[32];
- uint32 tmp_len;
+ SilcUInt32 tmp_len;
SilcChannelID *id;
SilcChannelKeyPayload payload;
key = silc_channel_key_get_key(payload, &tmp_len);
cipher = silc_channel_key_get_cipher(payload, NULL);
channel->key_len = tmp_len * 8;
- channel->key = silc_calloc(tmp_len, sizeof(*channel->key));
- memcpy(channel->key, key, tmp_len);
+ channel->key = silc_memdup(key, tmp_len);
if (!silc_cipher_alloc(cipher, &channel->channel_key)) {
client->internal->ops->say(
char *cipher,
char *hmac,
unsigned char *key,
- uint32 key_len)
+ SilcUInt32 key_len)
{
SilcChannelPrivateKey entry;
unsigned char hash[32];
/* Save the key */
entry = silc_calloc(1, sizeof(*entry));
- entry->key = silc_calloc(keymat->enc_key_len / 8, sizeof(*entry->key));
- memcpy(entry->key, keymat->send_enc_key, keymat->enc_key_len / 8);
+ entry->key = silc_memdup(keymat->send_enc_key, keymat->enc_key_len / 8);
entry->key_len = keymat->enc_key_len / 8;
/* Allocate the cipher and set the key*/
silc_client_list_channel_private_keys(SilcClient client,
SilcClientConnection conn,
SilcChannelEntry channel,
- uint32 *key_count)
+ SilcUInt32 *key_count)
{
SilcChannelPrivateKey *keys = NULL, entry;
- uint32 count = 0;
+ SilcUInt32 count = 0;
if (!channel->private_keys)
return NULL;
/* Frees the SilcChannelPrivateKey array. */
void silc_client_free_channel_private_keys(SilcChannelPrivateKey *keys,
- uint32 key_count)
+ SilcUInt32 key_count)
{
silc_free(keys);
}