and silc_client_get_clients_whois.
Fixed channel message private key setting. Addec current channel
key cipher and HMAC algorithm names to SilcClientEntry.
+Sun May 6 12:43:19 EEST 2007 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added current channel key cipher name and HMAC name to
+ SilcChannelEntry. Fixed channel private key creation.
+ Affected files are lib/silcclient/client_channel.c,
+ client_entry and silcclient_entry.h.
+
+ * Allow formatted nicknames as input to silc_client_get_clients
+ and silc_client_get_clients_whois. Affected file is
+ lib/silcclient/client_entry.c.
+
Thu May 3 18:07:50 EEST 2007 Pekka Riikonen <priikone@silcnet.org>
* Imported libtommath 0.41. Renamed all mp_* functions to
Thu May 3 18:07:50 EEST 2007 Pekka Riikonen <priikone@silcnet.org>
* Imported libtommath 0.41. Renamed all mp_* functions to
if (channel->internal.private_keys) {
if (key) {
/* Use key application specified */
if (channel->internal.private_keys) {
if (key) {
/* Use key application specified */
+ cipher = key->send_key;
hmac = key->hmac;
} else if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY &&
channel->internal.curr_key) {
/* Use current private key */
hmac = key->hmac;
} else if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY &&
channel->internal.curr_key) {
/* Use current private key */
- cipher = channel->internal.curr_key->cipher;
+ cipher = channel->internal.curr_key->send_key;
hmac = channel->internal.curr_key->hmac;
} else if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY &&
!channel->internal.curr_key &&
hmac = channel->internal.curr_key->hmac;
} else if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY &&
!channel->internal.curr_key &&
and private keys are set. */
silc_dlist_start(channel->internal.private_keys);
key = silc_dlist_get(channel->internal.private_keys);
and private keys are set. */
silc_dlist_start(channel->internal.private_keys);
key = silc_dlist_get(channel->internal.private_keys);
+ cipher = key->send_key;
hmac = key->hmac;
/* Use this key as current private key */
hmac = key->hmac;
/* Use this key as current private key */
/* Parse the message payload. This also decrypts the payload */
payload = silc_message_payload_parse(silc_buffer_data(buffer),
silc_buffer_len(buffer),
/* Parse the message payload. This also decrypts the payload */
payload = silc_message_payload_parse(silc_buffer_data(buffer),
silc_buffer_len(buffer),
- FALSE, FALSE, key->cipher,
+ FALSE, FALSE, key->receive_key,
key->hmac, packet->src_id,
packet->src_id_len,
packet->dst_id,
key->hmac, packet->src_id,
packet->src_id_len,
packet->dst_id,
+ channel->cipher = silc_cipher_get_name(channel->internal.send_key);
+ channel->hmac = silc_hmac_get_name(channel->internal.hmac);
+
/* Set HMAC key */
silc_hash_make(silc_hmac_get_hash(channel->internal.hmac), key,
tmp_len, hash);
/* Set HMAC key */
silc_hash_make(silc_hmac_get_hash(channel->internal.hmac), key,
tmp_len, hash);
entry->name = name ? strdup(name) : NULL;
/* Allocate the cipher and set the key */
entry->name = name ? strdup(name) : NULL;
/* Allocate the cipher and set the key */
- if (!silc_cipher_alloc(cipher, &entry->cipher)) {
+ if (!silc_cipher_alloc(cipher, &entry->send_key)) {
+ silc_free(entry);
+ silc_free(entry->name);
+ silc_ske_free_key_material(keymat);
+ return FALSE;
+ }
+ if (!silc_cipher_alloc(cipher, &entry->receive_key)) {
silc_free(entry);
silc_free(entry->name);
silc_free(entry);
silc_free(entry->name);
+ silc_cipher_free(entry->send_key);
silc_ske_free_key_material(keymat);
return FALSE;
}
silc_ske_free_key_material(keymat);
return FALSE;
}
- silc_cipher_set_key(entry->cipher, keymat->send_enc_key,
+ silc_cipher_set_key(entry->send_key, keymat->send_enc_key,
keymat->enc_key_len, TRUE);
keymat->enc_key_len, TRUE);
+ silc_cipher_set_key(entry->receive_key, keymat->send_enc_key,
+ keymat->enc_key_len, FALSE);
/* Generate HMAC key from the channel key data and set it */
if (!silc_hmac_alloc(hmac, NULL, &entry->hmac)) {
silc_free(entry);
silc_free(entry->name);
/* Generate HMAC key from the channel key data and set it */
if (!silc_hmac_alloc(hmac, NULL, &entry->hmac)) {
silc_free(entry);
silc_free(entry->name);
- silc_cipher_free(entry->cipher);
+ silc_cipher_free(entry->send_key);
+ silc_cipher_free(entry->receive_key);
silc_ske_free_key_material(keymat);
return FALSE;
}
silc_ske_free_key_material(keymat);
return FALSE;
}
/* Add to the private keys list */
silc_dlist_add(channel->internal.private_keys, entry);
/* Add to the private keys list */
silc_dlist_add(channel->internal.private_keys, entry);
- if (!channel->internal.curr_key)
+ if (!channel->internal.curr_key) {
channel->internal.curr_key = entry;
channel->internal.curr_key = entry;
+ channel->cipher = silc_cipher_get_name(entry->send_key);
+ channel->hmac = silc_cipher_get_name(entry->send_key);
+ }
/* Free the key material */
silc_ske_free_key_material(keymat);
/* Free the key material */
silc_ske_free_key_material(keymat);
while ((entry = silc_dlist_get(channel->internal.private_keys))) {
silc_dlist_del(channel->internal.private_keys, entry);
silc_free(entry->name);
while ((entry = silc_dlist_get(channel->internal.private_keys))) {
silc_dlist_del(channel->internal.private_keys, entry);
silc_free(entry->name);
- silc_cipher_free(entry->cipher);
+ silc_cipher_free(entry->send_key);
+ silc_cipher_free(entry->receive_key);
silc_hmac_free(entry->hmac);
silc_free(entry);
}
channel->internal.curr_key = NULL;
silc_hmac_free(entry->hmac);
silc_free(entry);
}
channel->internal.curr_key = NULL;
+ channel->cipher = silc_cipher_get_name(channel->internal.send_key);
+ channel->hmac = silc_hmac_get_name(channel->internal.hmac);
silc_dlist_uninit(channel->internal.private_keys);
channel->internal.private_keys = NULL;
silc_dlist_uninit(channel->internal.private_keys);
channel->internal.private_keys = NULL;
if (entry != key)
continue;
if (entry != key)
continue;
- if (channel->internal.curr_key == entry)
+ if (channel->internal.curr_key == entry) {
channel->internal.curr_key = NULL;
channel->internal.curr_key = NULL;
+ channel->cipher = silc_cipher_get_name(channel->internal.send_key);
+ channel->hmac = silc_hmac_get_name(channel->internal.hmac);
+ }
silc_dlist_del(channel->internal.private_keys, entry);
silc_free(entry->name);
silc_dlist_del(channel->internal.private_keys, entry);
silc_free(entry->name);
- silc_cipher_free(entry->cipher);
+ silc_cipher_free(entry->send_key);
+ silc_cipher_free(entry->receive_key);
silc_hmac_free(entry->hmac);
silc_free(entry);
silc_hmac_free(entry->hmac);
silc_free(entry);
if (!channel)
return;
channel->internal.curr_key = key;
if (!channel)
return;
channel->internal.curr_key = key;
+ channel->cipher = silc_cipher_get_name(key->send_key);
+ channel->hmac = silc_hmac_get_name(key->hmac);
}
/***************************** Utility routines *****************************/
}
/***************************** Utility routines *****************************/
silc_ske_map_status(status));
conn->internal->status = SILC_CLIENT_CONN_ERROR_KE;
silc_ske_map_status(status));
conn->internal->status = SILC_CLIENT_CONN_ERROR_KE;
- conn->internal->error = status;
silc_ske_free_rekey_material(rekey);
silc_fsm_next(fsm, silc_client_st_connect_error);
silc_ske_free_rekey_material(rekey);
silc_fsm_next(fsm, silc_client_st_connect_error);
if (!client || !conn || !nickname)
return NULL;
if (!client || !conn || !nickname)
return NULL;
- /* Parse nickname if it is formatted */
+ /* Parse nickname in case it is formatted */
if (!silc_client_nickname_parse(client, conn, (char *)nickname, &parsed))
return NULL;
if (!silc_client_nickname_parse(client, conn, (char *)nickname, &parsed))
return NULL;
void *context)
{
SilcClientGetClientInternal i;
void *context)
{
SilcClientGetClientInternal i;
- char userhost[768 + 1];
+ char nick[128 + 1], serv[256 + 1], userhost[768 + 1], *parsed = NULL;
int len;
SILC_LOG_DEBUG(("Resolve client by %s command",
int len;
SILC_LOG_DEBUG(("Resolve client by %s command",
if (!nickname && !attributes)
return 0;
if (!nickname && !attributes)
return 0;
+ /* Parse server name from the nickname if set */
+ if (silc_parse_userfqdn(nickname, nick, sizeof(nick),
+ serv, sizeof(serv) == 2))
+ server = (const char *)serv;
+ nickname = (const char *)nick;
+
+ /* Parse nickname in case it is formatted */
+ if (silc_client_nickname_parse(client, conn, (char *)nickname, &parsed))
+ nickname = (const char *)parsed;
+
i = silc_calloc(1, sizeof(*i));
i = silc_calloc(1, sizeof(*i));
+ if (!i) {
+ silc_free(parsed);
i->clients = silc_dlist_init();
if (!i->clients) {
i->clients = silc_dlist_init();
if (!i->clients) {
silc_free(i);
return 0;
}
silc_free(i);
return 0;
}
} else if (nickname) {
silc_strncat(userhost, sizeof(userhost) - 1, nickname, strlen(nickname));
}
} else if (nickname) {
silc_strncat(userhost, sizeof(userhost) - 1, nickname, strlen(nickname));
}
/* Send the command */
if (command == SILC_COMMAND_IDENTIFY)
/* Send the command */
if (command == SILC_COMMAND_IDENTIFY)
*/
struct SilcChannelPrivateKeyStruct {
char *name; /* Application given name */
*/
struct SilcChannelPrivateKeyStruct {
char *name; /* Application given name */
- SilcCipher cipher; /* The cipher and key */
+ SilcCipher send_key; /* The cipher and key */
+ SilcCipher receive_key; /* The cipher and key */
SilcHmac hmac; /* The HMAC and hmac key */
};
/***/
SilcHmac hmac; /* The HMAC and hmac key */
};
/***/
- * SilcBool silc_client_del_private_message_key(SilcClient client,
- * SilcClientConnection conn,
- * SilcClientEntry client_entry);
+ * SilcBool
+ * silc_client_del_private_message_key(SilcClient client,
+ * SilcClientConnection conn,
+ * SilcClientEntry client_entry);
SilcHashTable user_list; /* Joined users. Key to hash table is
SilcClientEntry, context is
SilcChannelUser. */
SilcHashTable user_list; /* Joined users. Key to hash table is
SilcClientEntry, context is
SilcChannelUser. */
+ const char *cipher; /* Current channel cipher algorithm*/
+ const char *hmac; /* Current channel HMAC algorithm */
void *context; /* Application specific context */
SilcChannelEntryInternal internal;
void *context; /* Application specific context */
SilcChannelEntryInternal internal;
* and can be accesses locally at a later time. The resolving is done
* with IDENTIFY command. The `server' may be NULL. The server
* associated with the nickname may be in the `nickname' (nick@server).
* and can be accesses locally at a later time. The resolving is done
* with IDENTIFY command. The `server' may be NULL. The server
* associated with the nickname may be in the `nickname' (nick@server).
+ * The `nickname' may also be a formatted nickname in which case the
+ * formatting is ignored and the base nickname is used. If the nickname
+ * is formatted it must be formatted as defined in SilcClientParams.
* Returns 0 on error and the command identifier used with the command
* otherwise.
*
* Returns 0 on error and the command identifier used with the command
* otherwise.
*
* and can be accesses locally at a later time. The resolving is done
* with WHOIS command. The `server' may be NULL. The server
* associated with the nickname may be in the `nickname' (nick@server).
* and can be accesses locally at a later time. The resolving is done
* with WHOIS command. The `server' may be NULL. The server
* associated with the nickname may be in the `nickname' (nick@server).
+ * The `nickname' may also be a formatted nickname in which case the
+ * formatting is ignored and the base nickname is used. If the nickname
+ * is formatted it must be formatted as defined in SilcClientParams.
* Returns 0 on error and the command identifier used with the command
* otherwise.
*
* Returns 0 on error and the command identifier used with the command
* otherwise.
*