Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001, 2003 Pekka Riikonen
+ Copyright (C) 1997 - 2004 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
void silc_client_private_message(SilcClient client,
SilcSocketConnection sock,
SilcPacketContext *packet);
+void silc_client_private_message_key(SilcClient client,
+ SilcSocketConnection sock,
+ SilcPacketContext *packet);
void silc_client_connection_auth_request(SilcClient client,
SilcSocketConnection sock,
SilcPacketContext *packet);
if (key_len > packet->buffer->len)
goto out;
- /* Now take the key in use */
- if (!silc_client_add_private_message_key(client, conn, clients[0],
- cipher, hmac, key, key_len,
- FALSE, TRUE))
- goto out;
-
- /* Print some info for application */
- client->internal->ops->say(
- client, conn, SILC_CLIENT_MESSAGE_AUDIT,
- "Received private message key from %s%s%s %s%s%s",
- clients[0]->nickname,
- clients[0]->server ? "@" : "",
- clients[0]->server ? clients[0]->server : "",
- clients[0]->username ? "(" : "",
- clients[0]->username ? clients[0]->username : "",
- clients[0]->username ? ")" : "");
+ /* Mark that we are responder */
+ clients[0]->prv_resp = TRUE;
out:
silc_free(cipher);
silc_packet_context_free(packet);
}
-/* Processes incoming Private Message Key payload. The libary always
- accepts the key and takes it into use. */
+/* Processes incoming Private Message Key payload to indicate that the
+ sender whishes to set up a static private message key. */
void silc_client_private_message_key(SilcClient client,
SilcSocketConnection sock,
return TRUE;
}
-/* Sends private message key payload to the remote client indicated by
- the `client_entry'. If the `force_send' is TRUE the packet is sent
- immediately. Returns FALSE if error occurs, TRUE otherwise. The
- application should call this function after setting the key to the
- client.
-
- Note that the key sent using this function is sent to the remote client
- through the SILC network. The packet is protected using normal session
- keys. */
+/* Sends private message key indicator. The sender of this packet is
+ going to be the initiator, if and when, the users set up a static
+ private message key (not Key Agreement). */
-bool silc_client_send_private_message_key(SilcClient client,
- SilcClientConnection conn,
- SilcClientEntry client_entry,
- bool force_send)
+bool silc_client_send_private_message_key_request(SilcClient client,
+ SilcClientConnection conn,
+ SilcClientEntry client_entry)
{
SilcSocketConnection sock;
SilcBuffer buffer;
if (!client_entry->send_key || !client_entry->key)
return FALSE;
- SILC_LOG_DEBUG(("Sending private message key"));
+ SILC_LOG_DEBUG(("Sending private message key indicator"));
cipher = silc_cipher_get_name(client_entry->send_key);
cipher_len = strlen(cipher);
hmac_len = strlen(hmac);
/* Create private message key payload */
- buffer = silc_buffer_alloc(2 + client_entry->key_len);
- silc_buffer_pull_tail(buffer, SILC_BUFFER_END(buffer));
+ buffer = silc_buffer_alloc_size(4 + cipher_len + hmac_len);
silc_buffer_format(buffer,
- SILC_STR_UI_SHORT(client_entry->key_len),
- SILC_STR_UI_XNSTRING(client_entry->key,
- client_entry->key_len),
SILC_STR_UI_SHORT(cipher_len),
SILC_STR_UI_XNSTRING(cipher,
cipher_len),
/* Send the packet */
silc_client_packet_send(client, sock, SILC_PACKET_PRIVATE_MESSAGE_KEY,
client_entry->id, SILC_ID_CLIENT, NULL, NULL,
- buffer->data, buffer->len, force_send);
+ buffer->data, buffer->len, TRUE);
silc_free(buffer);
return TRUE;
SilcEntryStatus status; /* Status mask */
SilcHashTable channels; /* All channels client has joined */
SilcUInt16 resolve_cmd_ident; /* Command identifier when resolving */
- bool generated; /* TRUE if library generated `key' */
- bool valid; /* FALSE if this entry is not valid */
+ unsigned int generated : 1; /* TRUE if library generated `key' */
+ unsigned int valid : 1; /* FALSE if this entry is not valid */
+ unsigned int prv_resp : 1; /* TRUE if private message key indicator
+ has been received (responder). */
/* Application specific data. Application may set here whatever it wants. */
void *context;
SilcClientConnection conn,
SilcUInt32 *key_count);
+/****f* silcclient/SilcClientAPI/silc_client_send_private_message_key_request
+ *
+ * SYNOPSIS
+ *
+ * bool
+ * silc_client_send_private_message_key_request(SilcClient client,
+ * SilcClientConnection conn,
+ * SilcClientEntry client_entry);
+ *
+ * DESCRIPTION
+ *
+ * This function can be used to send an private message key indicator
+ * request to the remote client indicated by 'client_entry'. This can
+ * be used when setting a static or pre-shared private message key.
+ * The sender of this packet is the initiator and must set the 'responder'
+ * argument in silc_client_add_private_message_key function to FALSE.
+ * The receiver of this indicator request must set it to TRUE, if the
+ * receiver decides to set a private message key. By using this
+ * function applications may automate initiator/responder setting in
+ * private message key functions, without asking from user which one is
+ * the initiator and which one is responder.
+ *
+ * NOTES
+ *
+ * The sender of this packet must set the private message key for
+ * 'client_entry' before calling this function. The 'responder'
+ * argument MUST be set to FALSE when setting the key.
+ *
+ ***/
+bool
+silc_client_send_private_message_key_request(SilcClient client,
+ SilcClientConnection conn,
+ SilcClientEntry client_entry);
+
/****f* silcclient/SilcClientAPI/silc_client_free_private_message_keys
*
* SYNOPSIS