static void silc_server_accept_completed(SilcSKE ske, SilcSKEStatus status, SilcSKESecurityProperties prop, SilcSKEKeyMaterial keymat, SilcSKERekeyMaterial rekey, void *context) { SilcServerAccept ac = context; ac->status = status; ac->prop = prop; ac->keymat = keymat; ac->rekey = rekey; /* Continue synchronously to take keys into use immediately */ SILC_FSM_CALL_CONTINUE_SYNC(&ac->t); }
static void silc_client_connect_auth_completion(SilcConnAuth connauth, SilcBool success, void *context) { SilcFSMThread fsm = context; SilcClientConnection conn = silc_fsm_get_context(fsm); SilcClient client = conn->client; conn->internal->op = NULL; silc_connauth_free(connauth); if (!success) { if (conn->internal->verbose) client->internal->ops->say( client, conn, SILC_CLIENT_MESSAGE_ERROR, "Authentication failed"); conn->internal->status = SILC_CLIENT_CONN_ERROR_AUTH; conn->internal->error = SILC_STATUS_ERR_AUTH_FAILED; silc_fsm_next(fsm, silc_client_st_connect_error); } SILC_FSM_CALL_CONTINUE_SYNC(fsm); }
static void silc_client_ke_completion(SilcSKE ske, SilcSKEStatus status, SilcSKESecurityProperties prop, SilcSKEKeyMaterial keymat, SilcSKERekeyMaterial rekey, void *context) { SilcFSMThread fsm = context; SilcClientConnection conn = silc_fsm_get_context(fsm); SilcClient client = conn->client; SilcCipher send_key, receive_key; SilcHmac hmac_send, hmac_receive; conn->internal->op = NULL; if (status != SILC_SKE_STATUS_OK) { /* Key exchange failed */ SILC_LOG_DEBUG(("Error during key exchange with %s: %s (%d)", conn->remote_host, silc_ske_map_status(status), status)); if (conn->internal->verbose) client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR, "Error during key exchange with %s: %s", conn->remote_host, silc_ske_map_status(status)); conn->internal->status = SILC_CLIENT_CONN_ERROR_KE; silc_ske_free_rekey_material(rekey); silc_fsm_next(fsm, silc_client_st_connect_error); SILC_FSM_CALL_CONTINUE_SYNC(fsm); return; } SILC_LOG_DEBUG(("Setting keys into use")); /* Allocate the cipher and HMAC contexts */ if (!silc_ske_set_keys(ske, keymat, prop, &send_key, &receive_key, &hmac_send, &hmac_receive, &conn->internal->hash)) { /* Error setting keys */ SILC_LOG_DEBUG(("Could not set keys into use")); if (conn->internal->verbose) client->internal->ops->say( client, conn, SILC_CLIENT_MESSAGE_ERROR, "Error during key exchange with %s: cannot use keys", conn->remote_host); conn->internal->status = SILC_CLIENT_CONN_ERROR_KE; silc_ske_free_rekey_material(rekey); silc_fsm_next(fsm, silc_client_st_connect_error); SILC_FSM_CALL_CONTINUE_SYNC(fsm); return; } /* Set the keys into the packet stream. After this call packets will be encrypted with these keys. */ if (!silc_packet_set_keys(conn->stream, send_key, receive_key, hmac_send, hmac_receive, FALSE)) { /* Error setting keys */ SILC_LOG_DEBUG(("Could not set keys into use")); if (conn->internal->verbose) client->internal->ops->say( client, conn, SILC_CLIENT_MESSAGE_ERROR, "Error during key exchange with %s: cannot use keys", conn->remote_host); conn->internal->status = SILC_CLIENT_CONN_ERROR_KE; silc_ske_free_rekey_material(rekey); silc_fsm_next(fsm, silc_client_st_connect_error); SILC_FSM_CALL_CONTINUE_SYNC(fsm); return; } conn->internal->rekey = rekey; SILC_LOG_DEBUG(("Key Exchange completed")); /* Key exchange done */ SILC_FSM_CALL_CONTINUE_SYNC(fsm); }