and in protocol.c. This file implements the client-to-client key
agreement as defined by the SILC protocol. */
-#include "clientlibincludes.h"
+#include "silcincludes.h"
+#include "silcclient.h"
#include "client_internal.h"
SILC_TASK_CALLBACK(silc_client_key_agreement_final);
const char *hostname,
const char *bindhost,
int port,
- uint32 timeout_secs,
+ SilcUInt32 timeout_secs,
SilcKeyAgreementCallback completion,
void *context)
{
SilcClientKeyAgreement ke = NULL;
SilcBuffer buffer;
- assert(client_entry);
+ if (!client_entry)
+ return;
- if (client_entry->ke)
+ if (client_entry->ke) {
+ completion(client, conn, client_entry, SILC_KEY_AGREEMENT_ALREADY_STARTED,
+ NULL, context);
return;
+ }
+
+ if (client_entry == conn->local_entry) {
+ completion(client, conn, client_entry, SILC_KEY_AGREEMENT_SELF_DENIED,
+ NULL, context);
+ return;
+ }
/* Create the listener if hostname and port was provided.
* also, use bindhost if it was specified.
completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE,
NULL, context);
silc_free(ke);
-
return;
}
client_entry->id, SILC_ID_CLIENT, NULL, NULL,
buffer->data, buffer->len, FALSE);
silc_buffer_free(buffer);
-
}
static int
SILC_LOG_DEBUG(("Start"));
- assert(client_entry && hostname && port);
+ if (!client_entry)
+ return;
+
+ if (!hostname || !port) {
+ completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE,
+ NULL, context);
+ return;
+ }
+
+ if (client_entry == conn->local_entry) {
+ completion(client, conn, client_entry, SILC_KEY_AGREEMENT_SELF_DENIED,
+ NULL, context);
+ return;
+ }
ke = silc_calloc(1, sizeof(*ke));
ke->client = client;
SILC_LOG_DEBUG(("Start"));
- assert(client_entry);
+ if (!client_entry)
+ return;
+
+ if (client_entry == conn->local_entry) {
+ completion(client, conn, client_entry, SILC_KEY_AGREEMENT_SELF_DENIED,
+ NULL, context);
+ return;
+ }
ke = silc_calloc(1, sizeof(*ke));
ke->client = client;
SilcClientConnection conn,
SilcClientEntry client_entry)
{
- assert(client_entry);
+ if (!client_entry)
+ return;
if (client_entry->ke) {
SilcClientKeyAgreement ke;
silc_client_key_agreement_resolve_cb(SilcClient client,
SilcClientConnection conn,
SilcClientEntry *clients,
- uint32 clients_count,
+ SilcUInt32 clients_count,
void *context)
{
SilcPacketContext *packet = (SilcPacketContext *)context;
return;
silc_client_get_client_by_id_resolve(client, sock->user_data, remote_id,
+ NULL,
silc_client_key_agreement_resolve_cb,
silc_packet_context_dup(packet));
silc_free(remote_id);