+/* Callback that is called by the SKE to indicate that it is safe to
+ continue the execution of the protocol. Is given as argument to the
+ silc_ske_initiator_finish or silc_ske_responder_phase_2 functions.
+ This is called due to the fact that the public key verification
+ process is asynchronous and we must not continue the protocl until
+ the public key has been verified and this callback is called. */
+
+static void silc_client_protocol_ke_continue(SilcSKE ske,
+ void *context)
+{
+ SilcProtocol protocol = (SilcProtocol)context;
+ SilcClientKEInternalContext *ctx =
+ (SilcClientKEInternalContext *)protocol->context;
+ SilcClient client = (SilcClient)ctx->client;
+ SilcClientConnection conn = ctx->sock->user_data;
+
+ SILC_LOG_DEBUG(("Start"));
+
+ if (ske->status != SILC_SKE_STATUS_OK) {
+ /* Call failure client operation */
+ client->internal->ops->failure(client, conn, protocol,
+ (void *)ske->status);
+ protocol->state = SILC_PROTOCOL_STATE_ERROR;
+ silc_protocol_execute(protocol, client->schedule, 0, 0);
+ return;
+ }
+
+ /* Send Ok to the other end. We will end the protocol as server
+ sends Ok to us when we will take the new keys into use. Do this
+ if we are initiator. This is happens when this callback was sent
+ to silc_ske_initiator_finish function. */
+ if (ctx->responder == FALSE) {
+ silc_ske_end(ctx->ske);
+
+ /* End the protocol on the next round */
+ protocol->state = SILC_PROTOCOL_STATE_END;
+ }
+
+ /* Advance protocol state and call the next state if we are responder.
+ This happens when this callback was sent to silc_ske_responder_phase_2
+ function. */
+ if (ctx->responder == TRUE) {
+ protocol->state++;
+ silc_protocol_execute(protocol, client->schedule, 0, 100000);
+ }
+}
+