From 1c09fd9efa3ce06b980b8e493644a7d271c52747 Mon Sep 17 00:00:00 2001 From: jospaeth Date: Mon, 3 Aug 2020 11:58:50 +0200 Subject: major restructuring of the escrow component refine the several layers (CLI, API, plugins) and enable async execution --- src/escrow/plugin_escrow_gns.c | 67 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 13 deletions(-) (limited to 'src/escrow/plugin_escrow_gns.c') diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c index f77ef30d6..278ceff5b 100644 --- a/src/escrow/plugin_escrow_gns.c +++ b/src/escrow/plugin_escrow_gns.c @@ -44,7 +44,7 @@ static struct GNUNET_IDENTITY_Handle *identity_handle; /** * Handle for the plugin instance */ -struct EscrowPluginHandle ph; +struct ESCROW_PluginHandle ph; /** @@ -53,21 +53,28 @@ struct EscrowPluginHandle ph; * @param h the handle for the escrow component * @param ego the identity ego containing the private key * @param cb the function called upon completion + * + * @return plugin operation wrapper */ -void +struct ESCROW_PluginOperationWrapper * start_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, const struct GNUNET_IDENTITY_Ego *ego, - GNUNET_ESCROW_AnchorContinuation cb) + GNUNET_SCHEDULER_TaskCallback cb) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; sss_Keyshare keyshares; struct GNUNET_ESCROW_Anchor *anchor; int anchorDataSize; + struct GNUNET_ESCROW_Plugin_AnchorContinuationWrapper *w; + + w = GNUNET_new (struct GNUNET_ESCROW_Plugin_AnchorContinuationWrapper); + w->h = h; if (NULL == ego) { - cb (h, NULL); - return; + w->escrowAnchor = NULL; + GNUNET_SCHEDULER_add_now (cb, w); + return NULL; // TODO! } pk = GNUNET_IDENTITY_ego_get_private_key (ego); @@ -85,7 +92,9 @@ start_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, // TODO: implement anchorDataSize = 0; // TODO! anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize); - cb (h, anchor); + w->escrowAnchor = anchor; + GNUNET_SCHEDULER_add_now (cb, w); + return NULL; // TODO! } @@ -100,7 +109,7 @@ renew_gns_key_escrow (struct GNUNET_ESCROW_Operation *op, struct GNUNET_ESCROW_Anchor *escrowAnchor) { // TODO: implement - op->cb_renew (op->cb_cls, NULL); + op->cb_renew (NULL); } @@ -111,15 +120,24 @@ renew_gns_key_escrow (struct GNUNET_ESCROW_Operation *op, * @param ego the identity ego containing the private key * @param escrowAnchor the escrow anchor needed to restore the key * @param cb the function called upon completion + * + * @return plugin operation wrapper */ -void +struct ESCROW_PluginOperationWrapper * verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_ESCROW_Anchor *escrowAnchor, - GNUNET_ESCROW_VerifyContinuation cb) + GNUNET_SCHEDULER_TaskCallback cb) { + struct GNUNET_ESCROW_Plugin_VerifyContinuationWrapper *w; + + w = GNUNET_new (struct GNUNET_ESCROW_Plugin_VerifyContinuationWrapper); + w->h = h; + // TODO: implement - cb (h, GNUNET_ESCROW_INVALID); + w->verificationResult = GNUNET_ESCROW_INVALID; + GNUNET_SCHEDULER_add_now (cb, w); + return NULL; } @@ -130,15 +148,24 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, * @param escrowAnchor the escrow anchor needed to restore the key * @param egoName the name of the ego to restore * @param cb the function called upon completion + * + * @return plugin operation wrapper */ -void +struct ESCROW_PluginOperationWrapper * restore_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, struct GNUNET_ESCROW_Anchor *escrowAnchor, char *egoName, - GNUNET_ESCROW_EgoContinuation cb) + GNUNET_SCHEDULER_TaskCallback cb) { + struct GNUNET_ESCROW_Plugin_EgoContinuationWrapper *w; + + w = GNUNET_new (struct GNUNET_ESCROW_Plugin_EgoContinuationWrapper); + w->h = h; + // TODO: implement - cb (h, NULL); + w->ego = NULL; + GNUNET_SCHEDULER_add_now (cb, w); + return NULL; } @@ -184,6 +211,19 @@ gns_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h, } +/** + * Cancel a GNS plugin operation. + * + * @param plugin_op_wrap the plugin operation wrapper containing the operation + */ +void +cancel_gns_operation (struct ESCROW_PluginOperationWrapper *plugin_op_wrap) +{ + // TODO: implement + return; +} + + /** * IdentityInitContinuation for the GNS plugin */ @@ -213,6 +253,7 @@ libgnunet_plugin_escrow_gns_init (void *cls) api->verify_key_escrow = &verify_gns_key_escrow; api->restore_key = &restore_gns_key_escrow; api->anchor_string_to_data = &gns_anchor_string_to_data; + api->cancel_plugin_operation = &cancel_gns_operation; ph.id_init_cont = &gns_cont_init; -- cgit v1.2.3