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
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
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* This file includes the Key Agreement packet processing and actual
key agreement routines. This file has nothing to do with the actual
connection key exchange protocol, it is implemented in the client.c
/* This file includes the Key Agreement packet processing and actual
key agreement routines. This file has nothing to do with the actual
connection key exchange protocol, it is implemented in the client.c
(SilcClientKEInternalContext *)protocol->context;
SilcClient client = (SilcClient)ctx->client;
SilcClientKeyAgreement ke = (SilcClientKeyAgreement)ctx->context;
(SilcClientKEInternalContext *)protocol->context;
SilcClient client = (SilcClient)ctx->client;
SilcClientKeyAgreement ke = (SilcClientKeyAgreement)ctx->context;
protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
/* Error occured during protocol */
ke->client_entry->ke = NULL;
protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
/* Error occured during protocol */
ke->client_entry->ke = NULL;
- ke->completion(ke->client, ke->conn, ke->client_entry,
+ ke->completion(ke->client, ke->conn, ke->client_entry,
SILC_KEY_AGREEMENT_ERROR, NULL, ke->context);
silc_ske_free_key_material(ctx->keymat);
goto out;
SILC_KEY_AGREEMENT_ERROR, NULL, ke->context);
silc_ske_free_key_material(ctx->keymat);
goto out;
/* Pass the negotiated key material to the application. The application
is responsible of freeing the key material. */
ke->client_entry->ke = NULL;
/* Pass the negotiated key material to the application. The application
is responsible of freeing the key material. */
ke->client_entry->ke = NULL;
- ke->completion(ke->client, ke->conn, ke->client_entry,
+ ke->completion(ke->client, ke->conn, ke->client_entry,
silc_schedule_task_del(client->schedule, ke->timeout);
silc_client_del_socket(ke->client, ke->sock);
silc_schedule_task_del(client->schedule, ke->timeout);
silc_client_del_socket(ke->client, ke->sock);
sock = silc_net_accept_connection(ke->fd);
if (sock < 0) {
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
sock = silc_net_accept_connection(ke->fd);
if (sock < 0) {
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
- ke->completion(ke->client, ke->conn, ke->client_entry,
+ ke->completion(ke->client, ke->conn, ke->client_entry,
SILC_KEY_AGREEMENT_ERROR, NULL, ke->context);
silc_schedule_task_del_by_fd(client->schedule, ke->fd);
silc_schedule_unset_listen_fd(ke->client->schedule, ke->fd);
SILC_KEY_AGREEMENT_ERROR, NULL, ke->context);
silc_schedule_task_del_by_fd(client->schedule, ke->fd);
silc_schedule_unset_listen_fd(ke->client->schedule, ke->fd);
/* Perform name and address lookups for the remote host. */
silc_net_check_host_by_sock(sock, &newsocket->hostname, &newsocket->ip);
if (!newsocket->hostname && !newsocket->ip) {
/* Perform name and address lookups for the remote host. */
silc_net_check_host_by_sock(sock, &newsocket->hostname, &newsocket->ip);
if (!newsocket->hostname && !newsocket->ip) {
- client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
+ client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
- ke->completion(ke->client, ke->conn, ke->client_entry,
+ ke->completion(ke->client, ke->conn, ke->client_entry,
SILC_KEY_AGREEMENT_ERROR, NULL, ke->context);
silc_schedule_task_del_by_fd(client->schedule, ke->fd);
silc_schedule_unset_listen_fd(ke->client->schedule, ke->fd);
SILC_KEY_AGREEMENT_ERROR, NULL, ke->context);
silc_schedule_task_del_by_fd(client->schedule, ke->fd);
silc_schedule_unset_listen_fd(ke->client->schedule, ke->fd);
/* Prepare the connection for key exchange protocol. We allocate the
protocol but will not start it yet. The connector will be the
/* Prepare the connection for key exchange protocol. We allocate the
protocol but will not start it yet. The connector will be the
- silc_protocol_alloc(SILC_PROTOCOL_CLIENT_KEY_EXCHANGE,
- &newsocket->protocol, proto_ctx,
+ silc_protocol_alloc(SILC_PROTOCOL_CLIENT_KEY_EXCHANGE,
+ &newsocket->protocol, proto_ctx,
and sets that outgoing packets may be sent to this connection as well.
However, this doesn't set the scheduler for outgoing traffic, it
will be set separately by calling SILC_CLIENT_SET_CONNECTION_FOR_OUTPUT,
and sets that outgoing packets may be sent to this connection as well.
However, this doesn't set the scheduler for outgoing traffic, it
will be set separately by calling SILC_CLIENT_SET_CONNECTION_FOR_OUTPUT,
- ke->completion(ke->client, ke->conn, ke->client_entry,
+ ke->completion(ke->client, ke->conn, ke->client_entry,
the same packet including its hostname and port. If the library receives
the reply from the remote client the `key_agreement' client operation
callback will be called to verify whether the user wants to perform the
the same packet including its hostname and port. If the library receives
the reply from the remote client the `key_agreement' client operation
callback will be called to verify whether the user wants to perform the
remote side initiates the key agreement protocol it is not verified
from the user anymore whether the protocol should be executed or not.
By setting the `hostname' and `port' the user gives permission to
remote side initiates the key agreement protocol it is not verified
from the user anymore whether the protocol should be executed or not.
By setting the `hostname' and `port' the user gives permission to
perform the key agreement at all. If the key agreement protocol is
performed the `completion' callback with the `context' will be called.
If remote side decides to ignore the request the `completion' will be
perform the key agreement at all. If the key agreement protocol is
performed the `completion' callback with the `context' will be called.
If remote side decides to ignore the request the `completion' will be
NOTE: If the `hostname' and the `port' was not provided the `completion'
will not be called at all since this does nothing more than sending
NOTE: If the `hostname' and the `port' was not provided the `completion'
will not be called at all since this does nothing more than sending
NOTE: There can be only one active key agreement for one client entry.
Before setting new one, the old one must be finished (it is finished
NOTE: There can be only one active key agreement for one client entry.
Before setting new one, the old one must be finished (it is finished
silc_client_abort_key_agreement must be called. */
void silc_client_send_key_agreement(SilcClient client,
silc_client_abort_key_agreement must be called. */
void silc_client_send_key_agreement(SilcClient client,
/* Create the listener if hostname and port was provided.
* also, use bindhost if it was specified.
*/
/* Create the listener if hostname and port was provided.
* also, use bindhost if it was specified.
*/
- client, conn, SILC_CLIENT_MESSAGE_ERROR,
- "Cannot create listener on %s on port %d: %s",
+ client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "Cannot create listener on %s on port %d: %s",
(bindhost) ? bindhost:hostname, port, strerror(errno));
completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE,
NULL, context);
(bindhost) ? bindhost:hostname, port, strerror(errno));
completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE,
NULL, context);
negotiations. */
silc_schedule_task_add(client->schedule, ke->fd,
silc_client_process_key_agreement,
negotiations. */
silc_schedule_task_add(client->schedule, ke->fd,
silc_client_process_key_agreement,
- (void *)ke, timeout_secs, 0,
+ (void *)ke, timeout_secs, 0,
SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
}
/* Encode the key agreement payload */
SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
}
/* Encode the key agreement payload */
- silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE);
+ silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE,
+ FALSE);
SilcClientConnection conn, int port,
char *host, void *context)
{
SilcClientConnection conn, int port,
char *host, void *context)
{
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Could not connect to client %s: %s",
ctx->host, strerror(opt));
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Could not connect to client %s: %s",
ctx->host, strerror(opt));
- client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
- "Connecting to port %d of client %s resumed",
+ client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
+ "Connecting to port %d of client %s resumed",
- ke->completion(ke->client, ke->conn, ke->client_entry,
+ ke->completion(ke->client, ke->conn, ke->client_entry,
The `hostname' is the remote hostname (or IP address) and the `port'
is the remote port. The `completion' callback with the `context' will
be called after the key agreement protocol.
The `hostname' is the remote hostname (or IP address) and the `port'
is the remote port. The `completion' callback with the `context' will
be called after the key agreement protocol.
NOTE: If the application returns TRUE in the `key_agreement' client
operation the library will automatically start the key agreement. In this
case the application must not call this function. However, application
NOTE: If the application returns TRUE in the `key_agreement' client
operation the library will automatically start the key agreement. In this
case the application must not call this function. However, application
-/* Same as above but application has created already the connection to
- the remote host. The `sock' is the socket to the remote connection.
+/* Same as above but application has created already the connection to
+ the remote host. The `sock' is the socket to the remote connection.
Application can use this function if it does not want the client library
to create the connection. */
Application can use this function if it does not want the client library
to create the connection. */
&protocol, (void *)proto_ctx,
silc_client_key_agreement_final);
ke->sock->protocol = protocol;
/* Register the connection for network input and output. This sets
&protocol, (void *)proto_ctx,
silc_client_key_agreement_final);
ke->sock->protocol = protocol;
/* Register the connection for network input and output. This sets
be set separately by calling SILC_CLIENT_SET_CONNECTION_FOR_OUTPUT,
later when outgoing data is available. */
context = (void *)client;
be set separately by calling SILC_CLIENT_SET_CONNECTION_FOR_OUTPUT,
later when outgoing data is available. */
context = (void *)client;
- been performed the library will automatically unbind the port. The
- `client_entry' is the client to which we sent the key agreement
+ been performed the library will automatically unbind the port. The
+ `client_entry' is the client to which we sent the key agreement
}
silc_schedule_task_del_by_fd(client->schedule, client_entry->ke->fd);
if (client_entry->ke->timeout)
}
silc_schedule_task_del_by_fd(client->schedule, client_entry->ke->fd);
if (client_entry->ke->timeout)
- ke->completion(client, conn, client_entry,
+ ke->completion(client, conn, client_entry,
information who sent us the key agreement packet from the server.
We actually call the key_agreement client operation now. */
information who sent us the key agreement packet from the server.
We actually call the key_agreement client operation now. */
silc_client_key_agreement_resolve_cb(SilcClient client,
SilcClientConnection conn,
SilcClientEntry *clients,
silc_client_key_agreement_resolve_cb(SilcClient client,
SilcClientConnection conn,
SilcClientEntry *clients,
- client, conn, clients[0],
+ client, conn, clients[0],
silc_key_agreement_get_hostname(payload),
silc_key_agreement_get_port(payload),
&completion, &completion_context);
silc_key_agreement_get_hostname(payload),
silc_key_agreement_get_port(payload),
&completion, &completion_context);
/* Received Key Agreement packet from remote client. Process the packet
and resolve the client information from the server before actually
/* Received Key Agreement packet from remote client. Process the packet
and resolve the client information from the server before actually
call the key_agreement client operation and let the user decide
whether we perform the key agreement protocol now or not. */
call the key_agreement client operation and let the user decide
whether we perform the key agreement protocol now or not. */
SILC_ID_CLIENT);
if (!remote_id)
return;
silc_client_get_client_by_id_resolve(client, sock->user_data, remote_id,
SILC_ID_CLIENT);
if (!remote_id)
return;
silc_client_get_client_by_id_resolve(client, sock->user_data, remote_id,
silc_client_key_agreement_resolve_cb,
silc_packet_context_dup(packet));
silc_free(remote_id);
silc_client_key_agreement_resolve_cb,
silc_packet_context_dup(packet));
silc_free(remote_id);