Function silc_client_key_exchange
SYNOPSIS
SilcAsyncOperation
silc_client_key_exchange(SilcClient client,
SilcClientConnectionParams *params,
SilcPublicKey public_key,
SilcPrivateKey private_key,
SilcStream stream,
SilcConnectionType conn_type,
SilcClientConnectCallback callback,
void *context);
DESCRIPTION
Starts key exchange protocol and authentication protocol in the
connection indicated by `stream'. This function can be be used to
start SILC session with remote host (usually server) when the caller
has itself created the connection, instead of calling the function
silc_client_connect_to_server or silc_client_connect_to_client. If
one of those functions was used this function must not be called as
in that case the key exchange is performed automatically.
Use this function only if you have created the connection by yourself.
After creating the connection the socket must be wrapped into a
socket stream. See silcsocketstream.h for more information. Note that
the `stream' must have valid remote IP address (and optionally also
hostname) and port set.
The `params' may be provided to provide various connection parameters.
The `public_key' and the `private_key' is your identity used in this
session. The `callback' with `context' will be called after the session
has been set up. It will also be called later when remote host
disconnects. The `conn_type' is the type of session this is going to
be. If the remote is SILC server it is SILC_CONN_SERVER or if it is
SILC client it is SILC_CONN_CLIENT.
Returns SilcAsyncOperation which can be used to cancel the connecting,
or NULL on error. Note that the returned pointer becomes invalid
after the `callback' is called.
EXAMPLE
int sock;
// Create remote connection stream. Resolve hostname and IP also.
sock = create_connection(remote_host, port);
silc_socket_tcp_stream_create(sock, TRUE, FALSE, schedule,
stream_create_cb, app);
// Stream callback delivers our new SilcStream context
void stream_create_cb(SilcSocketStreamStatus status, SilcStream stream,
void *context)
{
...
if (status != SILC_SOCKET_OK)
error(status);
// Start key exchange
silc_client_key_exchange(client, NULL, public_key, private_key,
stream, SILC_CONN_SERVER, connection_cb, app);
...
}
|