5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2006 - 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
21 #include "silcclient.h"
22 #include "client_internal.h"
24 /************************ Static utility functions **************************/
26 /* Callback called after connected to remote host */
28 static void silc_client_connect_callback(SilcNetStatus status,
29 SilcStream stream, void *context)
31 SilcFSMThread fsm = context;
32 SilcClientConnection conn = silc_fsm_get_context(fsm);
33 SilcClient client = conn->client;
35 conn->internal->op = NULL;
36 if (conn->internal->verbose) {
40 case SILC_NET_UNKNOWN_IP:
41 client->internal->ops->say(
42 client, conn, SILC_CLIENT_MESSAGE_ERROR,
43 "Could not connect to host %s: unknown IP address",
46 case SILC_NET_UNKNOWN_HOST:
47 client->internal->ops->say(
48 client, conn, SILC_CLIENT_MESSAGE_ERROR,
49 "Could not connect to host %s: unknown host name",
52 case SILC_NET_HOST_UNREACHABLE:
53 client->internal->ops->say(
54 client, conn, SILC_CLIENT_MESSAGE_ERROR,
55 "Could not connect to host %s: network unreachable",
58 case SILC_NET_CONNECTION_REFUSED:
59 client->internal->ops->say(
60 client, conn, SILC_CLIENT_MESSAGE_ERROR,
61 "Could not connect to host %s: connection refused",
64 case SILC_NET_CONNECTION_TIMEOUT:
65 client->internal->ops->say(
66 client, conn, SILC_CLIENT_MESSAGE_ERROR,
67 "Could not connect to host %s: connection timeout",
71 client->internal->ops->say(
72 client, conn, SILC_CLIENT_MESSAGE_ERROR,
73 "Could not connect to host %s",
79 if (status != SILC_NET_OK) {
80 /* Notify application of failure */
81 SILC_LOG_DEBUG(("Connecting failed"));
82 conn->internal->status = SILC_CLIENT_CONN_ERROR;
83 silc_fsm_next(fsm, silc_client_st_connect_error);
84 SILC_FSM_CALL_CONTINUE(fsm);
88 /* Connection created successfully */
89 SILC_LOG_DEBUG(("Connected"));
90 conn->stream = (void *)stream;
91 SILC_FSM_CALL_CONTINUE(fsm);
94 /* Called after application has verified remote host's public key */
96 static void silc_client_ke_verify_key_cb(SilcBool success, void *context)
98 SilcVerifyKeyContext verify = context;
100 SILC_LOG_DEBUG(("Start"));
102 /* Call the completion callback back to the SKE */
103 verify->completion(verify->ske, success ? SILC_SKE_STATUS_OK :
104 SILC_SKE_STATUS_UNSUPPORTED_PUBLIC_KEY,
105 verify->completion_context);
110 /* Verify remote host's public key */
112 static void silc_client_ke_verify_key(SilcSKE ske,
113 SilcPublicKey public_key,
115 SilcSKEVerifyCbCompletion completion,
116 void *completion_context)
118 SilcFSMThread fsm = context;
119 SilcClientConnection conn = silc_fsm_get_context(fsm);
120 SilcClient client = conn->client;
121 SilcVerifyKeyContext verify;
123 /* If we provided repository for SKE and we got here the key was not
124 found from the repository. */
125 if (conn->internal->params.repository &&
126 !conn->internal->params.verify_notfound) {
127 completion(ske, SILC_SKE_STATUS_UNSUPPORTED_PUBLIC_KEY,
132 SILC_LOG_DEBUG(("Verify remote public key"));
134 verify = silc_calloc(1, sizeof(*verify));
136 completion(ske, SILC_SKE_STATUS_UNSUPPORTED_PUBLIC_KEY,
141 verify->completion = completion;
142 verify->completion_context = completion_context;
144 /* Verify public key in application */
145 client->internal->ops->verify_public_key(client, conn,
146 conn->type, public_key,
147 silc_client_ke_verify_key_cb,
151 /* Key exchange protocol completion callback */
153 static void silc_client_ke_completion(SilcSKE ske,
154 SilcSKEStatus status,
155 SilcSKESecurityProperties prop,
156 SilcSKEKeyMaterial keymat,
157 SilcSKERekeyMaterial rekey,
160 SilcFSMThread fsm = context;
161 SilcClientConnection conn = silc_fsm_get_context(fsm);
162 SilcClient client = conn->client;
163 SilcCipher send_key, receive_key;
164 SilcHmac hmac_send, hmac_receive;
166 conn->internal->op = NULL;
167 if (status != SILC_SKE_STATUS_OK) {
168 /* Key exchange failed */
169 SILC_LOG_DEBUG(("Error during key exchange with %s: %s (%d)",
170 conn->remote_host, silc_ske_map_status(status), status));
172 if (conn->internal->verbose)
173 client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
174 "Error during key exchange with %s: %s",
176 silc_ske_map_status(status));
178 conn->internal->status = SILC_CLIENT_CONN_ERROR_KE;
179 conn->internal->error = status;
180 silc_ske_free_rekey_material(rekey);
182 silc_fsm_next(fsm, silc_client_st_connect_error);
183 SILC_FSM_CALL_CONTINUE(fsm);
187 SILC_LOG_DEBUG(("Setting keys into use"));
189 /* Allocate the cipher and HMAC contexts */
190 if (!silc_ske_set_keys(ske, keymat, prop, &send_key, &receive_key,
191 &hmac_send, &hmac_receive, &conn->internal->hash)) {
192 /* Error setting keys */
193 SILC_LOG_DEBUG(("Could not set keys into use"));
195 if (conn->internal->verbose)
196 client->internal->ops->say(
197 client, conn, SILC_CLIENT_MESSAGE_ERROR,
198 "Error during key exchange with %s: cannot use keys",
201 conn->internal->status = SILC_CLIENT_CONN_ERROR_KE;
202 silc_ske_free_rekey_material(rekey);
204 silc_fsm_next(fsm, silc_client_st_connect_error);
205 SILC_FSM_CALL_CONTINUE(fsm);
209 /* Set the keys into the packet stream. After this call packets will be
210 encrypted with these keys. */
211 if (!silc_packet_set_keys(conn->stream, send_key, receive_key, hmac_send,
212 hmac_receive, FALSE)) {
213 /* Error setting keys */
214 SILC_LOG_DEBUG(("Could not set keys into use"));
216 if (conn->internal->verbose)
217 client->internal->ops->say(
218 client, conn, SILC_CLIENT_MESSAGE_ERROR,
219 "Error during key exchange with %s: cannot use keys",
222 conn->internal->status = SILC_CLIENT_CONN_ERROR_KE;
223 silc_ske_free_rekey_material(rekey);
225 silc_fsm_next(fsm, silc_client_st_connect_error);
226 SILC_FSM_CALL_CONTINUE(fsm);
230 conn->internal->rekey = rekey;
232 SILC_LOG_DEBUG(("Key Exchange completed"));
234 /* Key exchange done */
235 SILC_FSM_CALL_CONTINUE_SYNC(fsm);
238 /* Rekey protocol completion callback */
240 static void silc_client_rekey_completion(SilcSKE ske,
241 SilcSKEStatus status,
242 SilcSKESecurityProperties prop,
243 SilcSKEKeyMaterial keymat,
244 SilcSKERekeyMaterial rekey,
247 SilcFSMThread fsm = context;
248 SilcClientConnection conn = silc_fsm_get_context(fsm);
249 SilcClient client = conn->client;
251 conn->internal->op = NULL;
252 if (status != SILC_SKE_STATUS_OK) {
254 SILC_LOG_DEBUG(("Error during rekey with %s: %s (%d)",
255 conn->remote_host, silc_ske_map_status(status), status));
257 if (conn->internal->verbose)
258 client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
259 "Error during rekey with %s: %s",
261 silc_ske_map_status(status));
263 silc_fsm_finish(fsm);
267 silc_ske_free_rekey_material(conn->internal->rekey);
268 conn->internal->rekey = rekey;
270 silc_ske_free(conn->internal->ske);
271 conn->internal->ske = NULL;
273 SILC_LOG_DEBUG(("Rekey completed conn %p", conn));
276 silc_fsm_finish(fsm);
279 /* Callback called by application to return authentication data */
281 static void silc_client_connect_auth_method(SilcAuthMethod auth_meth,
282 void *auth, SilcUInt32 auth_len,
285 SilcFSMThread fsm = context;
286 SilcClientConnection conn = silc_fsm_get_context(fsm);
288 conn->internal->params.auth_method = auth_meth;
289 conn->internal->params.auth = auth;
290 conn->internal->params.auth_len = auth_len;
292 SILC_FSM_CALL_CONTINUE(fsm);
295 /* Connection authentication completion callback */
297 static void silc_client_connect_auth_completion(SilcConnAuth connauth,
301 SilcFSMThread fsm = context;
302 SilcClientConnection conn = silc_fsm_get_context(fsm);
303 SilcClient client = conn->client;
305 conn->internal->op = NULL;
306 silc_connauth_free(connauth);
309 if (conn->internal->verbose)
310 client->internal->ops->say(
311 client, conn, SILC_CLIENT_MESSAGE_ERROR,
312 "Authentication failed");
314 conn->internal->status = SILC_CLIENT_CONN_ERROR_AUTH;
315 conn->internal->error = SILC_STATUS_ERR_AUTH_FAILED;
316 silc_fsm_next(fsm, silc_client_st_connect_error);
319 SILC_FSM_CALL_CONTINUE(fsm);
322 /********************** CONNECTION_AUTH_REQUEST packet **********************/
324 /* Received connection authentication request packet. We get the
325 required authentication method here. */
327 SILC_FSM_STATE(silc_client_connect_auth_request)
329 SilcClientConnection conn = fsm_context;
330 SilcPacket packet = state_context;
331 SilcUInt16 conn_type, auth_meth;
333 if (!conn->internal->auth_request) {
334 silc_packet_free(packet);
335 return SILC_FSM_FINISH;
338 /* Parse the payload */
339 if (silc_buffer_unformat(&packet->buffer,
340 SILC_STR_UI_SHORT(&conn_type),
341 SILC_STR_UI_SHORT(&auth_meth),
343 auth_meth = SILC_AUTH_NONE;
345 silc_packet_free(packet);
347 SILC_LOG_DEBUG(("Resolved authentication method: %s",
348 (auth_meth == SILC_AUTH_NONE ? "none" :
349 auth_meth == SILC_AUTH_PASSWORD ? "passphrase" :
351 conn->internal->params.auth_method = auth_meth;
353 /* Continue authentication */
354 silc_fsm_continue_sync(&conn->internal->event_thread);
355 return SILC_FSM_FINISH;
358 /*************************** Connect remote host ****************************/
360 /* Connection timeout callback */
362 SILC_TASK_CALLBACK(silc_client_connect_timeout)
364 SilcClientConnection conn = context;
366 SILC_LOG_DEBUG(("Connection timeout"));
368 conn->internal->status = SILC_CLIENT_CONN_ERROR_TIMEOUT;
369 conn->internal->error = SILC_STATUS_ERR_TIMEDOUT;
371 silc_fsm_next(&conn->internal->event_thread, silc_client_st_connect_error);
372 silc_fsm_continue_sync(&conn->internal->event_thread);
375 /* Creates a connection to remote host */
377 SILC_FSM_STATE(silc_client_st_connect)
379 SilcClientConnection conn = fsm_context;
381 SILC_LOG_DEBUG(("Connecting to %s:%d", conn->remote_host,
385 silc_fsm_next(fsm, silc_client_st_connect_set_stream);
387 /* Add connection timeout */
388 if (conn->internal->params.timeout_secs)
389 silc_schedule_task_add_timeout(conn->internal->schedule,
390 silc_client_connect_timeout, conn,
391 conn->internal->params.timeout_secs, 0);
393 if (conn->internal->params.udp) {
396 if (!conn->internal->params.local_ip) {
397 /** IP address not given */
398 SILC_LOG_ERROR(("Local UDP IP address not specified"));
399 conn->internal->status = SILC_CLIENT_CONN_ERROR;
400 silc_fsm_next(fsm, silc_client_st_connect_error);
401 return SILC_FSM_CONTINUE;
405 stream = silc_net_udp_connect(conn->internal->params.bind_ip ?
406 conn->internal->params.bind_ip :
407 conn->internal->params.local_ip,
408 conn->internal->params.local_port,
409 conn->remote_host, conn->remote_port,
410 conn->internal->schedule);
412 SILC_FSM_CALL(silc_client_connect_callback(stream ? SILC_NET_OK :
413 SILC_NET_HOST_UNREACHABLE,
417 SILC_FSM_CALL(conn->internal->op = silc_net_tcp_connect(
418 NULL, conn->remote_host,
420 conn->internal->schedule,
421 silc_client_connect_callback, fsm));
425 /* Sets the new connection stream into use and creates packet stream */
427 SILC_FSM_STATE(silc_client_st_connect_set_stream)
429 SilcClientConnection conn = fsm_context;
430 SilcClient client = conn->client;
432 if (conn->internal->disconnected) {
434 silc_fsm_next(fsm, silc_client_st_connect_error);
435 return SILC_FSM_CONTINUE;
438 /* Create packet stream */
439 conn->stream = silc_packet_stream_create(client->internal->packet_engine,
440 conn->internal->schedule,
441 (SilcStream)conn->stream);
443 /** Cannot create packet stream */
444 SILC_LOG_DEBUG(("Could not create packet stream"));
445 conn->internal->status = SILC_CLIENT_CONN_ERROR;
446 silc_fsm_next(fsm, silc_client_st_connect_error);
447 return SILC_FSM_CONTINUE;
450 silc_packet_set_context(conn->stream, conn);
452 /** Start key exchange */
453 silc_fsm_next(fsm, silc_client_st_connect_key_exchange);
454 return SILC_FSM_CONTINUE;
457 /* Starts key exchange protocol with remote host */
459 SILC_FSM_STATE(silc_client_st_connect_key_exchange)
461 SilcClientConnection conn = fsm_context;
462 SilcClient client = conn->client;
463 SilcSKEParamsStruct params;
465 SILC_LOG_DEBUG(("Starting key exchange protocol"));
468 conn->internal->ske =
469 silc_ske_alloc(client->rng, conn->internal->schedule,
470 conn->internal->params.repository,
471 conn->public_key, conn->private_key, fsm);
472 if (!conn->internal->ske) {
474 conn->internal->status = SILC_CLIENT_CONN_ERROR_KE;
475 silc_fsm_next(fsm, silc_client_st_connect_error);
476 return SILC_FSM_CONTINUE;
479 /* Set SKE callbacks */
480 silc_ske_set_callbacks(conn->internal->ske, silc_client_ke_verify_key,
481 silc_client_ke_completion, fsm);
483 /* Set up key exchange parameters */
484 params.version = client->internal->silc_client_version;
485 params.timeout_secs = conn->internal->params.timeout_secs;
486 params.flags = SILC_SKE_SP_FLAG_MUTUAL;
487 if (conn->internal->params.pfs)
488 params.flags |= SILC_SKE_SP_FLAG_PFS;
489 if (conn->internal->params.udp) {
490 params.flags |= SILC_SKE_SP_FLAG_IV_INCLUDED;
491 params.session_port = conn->internal->params.local_port;
494 if (conn->internal->params.no_authentication)
495 /** Run key exchange (no auth) */
496 silc_fsm_next(fsm, silc_client_st_connected);
497 else if (conn->internal->params.udp)
498 /** Run key exchange (UDP)*/
499 silc_fsm_next(fsm, silc_client_st_connect_setup_udp);
501 /** Run key exchange (TCP) */
502 silc_fsm_next(fsm, silc_client_st_connect_auth_resolve);
504 SILC_FSM_CALL(conn->internal->op = silc_ske_initiator(conn->internal->ske,
509 /* For UDP/IP connections, set up the UDP session after successful key
512 SILC_FSM_STATE(silc_client_st_connect_setup_udp)
514 SilcClientConnection conn = fsm_context;
515 SilcStream stream, old;
516 SilcSKESecurityProperties prop;
518 SILC_LOG_DEBUG(("Setup UDP SILC session"));
520 if (conn->internal->disconnected) {
522 silc_fsm_next(fsm, silc_client_st_connect_error);
523 return SILC_FSM_CONTINUE;
526 /* Create new UDP stream */
527 prop = silc_ske_get_security_properties(conn->internal->ske);
528 stream = silc_net_udp_connect(conn->internal->params.local_ip,
529 conn->internal->params.local_port,
530 conn->remote_host, prop->remote_port,
531 conn->internal->schedule);
533 /** Cannot create UDP stream */
534 conn->internal->status = SILC_CLIENT_CONN_ERROR;
535 silc_fsm_next(fsm, silc_client_st_connect_error);
536 return SILC_FSM_CONTINUE;
539 /* Set the new stream to packet stream */
540 old = silc_packet_stream_get_stream(conn->stream);
541 silc_packet_stream_set_stream(conn->stream, stream);
542 silc_packet_stream_set_iv_included(conn->stream);
543 silc_packet_set_sid(conn->stream, 0);
545 /* Delete the old stream */
546 silc_stream_destroy(old);
548 /** Start authentication */
549 silc_fsm_next(fsm, silc_client_st_connect_auth_resolve);
550 return SILC_FSM_CONTINUE;
553 /* Resolved authentication method to be used in authentication protocol */
555 SILC_FSM_STATE(silc_client_st_connect_auth_resolve)
557 SilcClientConnection conn = fsm_context;
559 SILC_LOG_DEBUG(("Resolve authentication method"));
561 if (conn->internal->disconnected) {
563 silc_fsm_next(fsm, silc_client_st_connect_error);
564 return SILC_FSM_CONTINUE;
567 /* If authentication method and data is set, use them */
568 if (conn->internal->params.auth_set) {
569 /** Got authentication data */
570 silc_fsm_next(fsm, silc_client_st_connect_auth_start);
571 return SILC_FSM_CONTINUE;
574 /* Send connection authentication request packet */
575 silc_packet_send_va(conn->stream,
576 SILC_PACKET_CONNECTION_AUTH_REQUEST, 0,
577 SILC_STR_UI_SHORT(SILC_CONN_CLIENT),
578 SILC_STR_UI_SHORT(SILC_AUTH_NONE),
581 /** Wait for authentication method */
582 conn->internal->auth_request = TRUE;
583 conn->internal->params.auth_method = SILC_AUTH_NONE;
584 silc_fsm_next_later(fsm, silc_client_st_connect_auth_data, 2, 0);
585 return SILC_FSM_WAIT;
588 /* Get authentication data to be used in authentication protocol */
590 SILC_FSM_STATE(silc_client_st_connect_auth_data)
592 SilcClientConnection conn = fsm_context;
593 SilcClient client = conn->client;
595 SILC_LOG_DEBUG(("Get authentication data"));
597 if (conn->internal->disconnected) {
599 silc_fsm_next(fsm, silc_client_st_connect_error);
600 return SILC_FSM_CONTINUE;
603 conn->internal->auth_request = FALSE;
605 /** Get authentication data */
606 silc_fsm_next(fsm, silc_client_st_connect_auth_start);
607 SILC_FSM_CALL(client->internal->ops->get_auth_method(
611 conn->internal->params.auth_method,
612 silc_client_connect_auth_method, fsm));
615 /* Start connection authentication with remote host */
617 SILC_FSM_STATE(silc_client_st_connect_auth_start)
619 SilcClientConnection conn = fsm_context;
620 SilcConnAuth connauth;
622 SILC_LOG_DEBUG(("Starting connection authentication protocol"));
624 if (conn->internal->disconnected) {
626 silc_fsm_next(fsm, silc_client_st_connect_error);
627 return SILC_FSM_CONTINUE;
630 /* We always use the same key for connection authentication and SKE */
631 if (conn->internal->params.auth_method == SILC_AUTH_PUBLIC_KEY)
632 conn->internal->params.auth = conn->private_key;
634 /* Allocate connection authentication protocol */
635 connauth = silc_connauth_alloc(conn->internal->schedule,
637 conn->internal->params.rekey_secs);
640 conn->internal->status = SILC_CLIENT_CONN_ERROR_AUTH;
641 conn->internal->error = SILC_STATUS_ERR_AUTH_FAILED;
642 silc_fsm_next(fsm, silc_client_st_connect_error);
643 return SILC_FSM_CONTINUE;
646 /** Start connection authentication */
647 silc_fsm_next(fsm, silc_client_st_connected);
648 SILC_FSM_CALL(conn->internal->op = silc_connauth_initiator(
649 connauth, SILC_CONN_CLIENT,
650 conn->internal->params.auth_method,
651 conn->internal->params.auth,
652 conn->internal->params.auth_len,
653 silc_client_connect_auth_completion,
657 /* Connection fully established */
659 SILC_FSM_STATE(silc_client_st_connected)
661 SilcClientConnection conn = fsm_context;
662 SilcClient client = conn->client;
664 /* Get SILC protocol version remote supports */
665 silc_ske_parse_version(conn->internal->ske, &conn->internal->remote_version,
666 NULL, NULL, NULL, NULL);
668 silc_ske_free(conn->internal->ske);
669 conn->internal->ske = NULL;
671 if (conn->internal->disconnected) {
673 silc_fsm_next(fsm, silc_client_st_connect_error);
674 return SILC_FSM_CONTINUE;
677 SILC_LOG_DEBUG(("Connection established"));
679 /* Install rekey timer */
680 if (conn->type != SILC_CONN_CLIENT)
681 silc_schedule_task_add_timeout(conn->internal->schedule,
682 silc_client_rekey_timer, conn,
683 conn->internal->params.rekey_secs, 0);
685 /* If we connected to server, now register to network. */
686 if (conn->type == SILC_CONN_SERVER &&
687 !conn->internal->params.no_authentication) {
689 /* If detach data is provided, resume the session. */
690 if (conn->internal->params.detach_data &&
691 conn->internal->params.detach_data_len) {
692 /** Resume detached session */
693 silc_fsm_next(fsm, silc_client_st_resume);
695 /** Register to network */
696 silc_fsm_next(fsm, silc_client_st_register);
699 return SILC_FSM_CONTINUE;
702 silc_schedule_task_del_by_all(conn->internal->schedule, 0,
703 silc_client_connect_timeout, conn);
705 /* Call connection callback */
706 conn->callback(client, conn, SILC_CLIENT_CONN_SUCCESS, 0, NULL,
707 conn->callback_context);
709 silc_async_free(conn->internal->cop);
710 conn->internal->cop = NULL;
712 return SILC_FSM_FINISH;
715 /* Error during connecting */
717 SILC_FSM_STATE(silc_client_st_connect_error)
719 SilcClientConnection conn = fsm_context;
721 if (conn->internal->ske) {
722 silc_ske_free(conn->internal->ske);
723 conn->internal->ske = NULL;
726 /* Signal to close connection */
727 if (!conn->internal->disconnected) {
728 conn->internal->disconnected = TRUE;
729 SILC_FSM_EVENT_SIGNAL(&conn->internal->wait_event);
732 silc_schedule_task_del_by_all(conn->internal->schedule, 0,
733 silc_client_connect_timeout, conn);
735 return SILC_FSM_FINISH;
738 /****************************** Connect rekey *******************************/
740 /* Connection rekey timer callback */
742 SILC_TASK_CALLBACK(silc_client_rekey_timer)
744 SilcClientConnection conn = context;
746 /* Signal to start rekey */
747 if (!silc_fsm_is_started(&conn->internal->event_thread)) {
748 conn->internal->rekey_responder = FALSE;
749 conn->internal->rekeying = TRUE;
750 SILC_FSM_EVENT_SIGNAL(&conn->internal->wait_event);
753 /* Reinstall rekey timer */
754 silc_schedule_task_add_timeout(conn->internal->schedule,
755 silc_client_rekey_timer, conn,
756 conn->internal->params.rekey_secs, 0);
761 SILC_FSM_STATE(silc_client_st_rekey)
763 SilcClientConnection conn = fsm_context;
764 SilcClient client = conn->client;
766 SILC_LOG_DEBUG(("Rekey conn %p", conn));
768 if (conn->internal->disconnected)
769 return SILC_FSM_FINISH;
772 conn->internal->ske =
773 silc_ske_alloc(client->rng, conn->internal->schedule,
774 conn->internal->params.repository,
775 conn->public_key, conn->private_key, fsm);
776 if (!conn->internal->ske)
777 return SILC_FSM_FINISH;
779 /* Set SKE callbacks */
780 silc_ske_set_callbacks(conn->internal->ske, NULL,
781 silc_client_rekey_completion, fsm);
784 if (!conn->internal->rekey_responder)
785 SILC_FSM_CALL(conn->internal->op = silc_ske_rekey_initiator(
788 conn->internal->rekey));
790 SILC_FSM_CALL(conn->internal->op = silc_ske_rekey_responder(
793 conn->internal->rekey));