summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-09-02 21:59:37 +0200
committerjospaeth <spaethj@in.tum.de>2020-09-02 21:59:37 +0200
commitc2a7a669d9c014b86d6e046f7d297fc5556d9fd4 (patch)
tree262f3504249e215b327d029fb202543bb7e3ddc6
parent3fd3f3fbc9c2f83b3505d4aafe026817944e73c1 (diff)
ESCROW_get() does not need method (as it is stored in anchor)
-rw-r--r--src/escrow/escrow_api.c8
-rw-r--r--src/escrow/gnunet-escrow.c20
-rw-r--r--src/escrow/plugin_escrow_gns.c12
-rw-r--r--src/escrow/plugin_escrow_plaintext.c12
-rw-r--r--src/include/gnunet_escrow_lib.h2
5 files changed, 37 insertions, 17 deletions
diff --git a/src/escrow/escrow_api.c b/src/escrow/escrow_api.c
index 5d1701405..8cbe889d4 100644
--- a/src/escrow/escrow_api.c
+++ b/src/escrow/escrow_api.c
@@ -133,7 +133,7 @@ init_plugin (const struct GNUNET_ESCROW_Handle *h,
(void *)h->cfg);
return anastasis_api;
case GNUNET_ESCROW_KEY_NONE: // error case
- fprintf (stderr, "incorrect escrow method!");
+ fprintf (stderr, "incorrect escrow method!\n");
return NULL;
}
// should never be reached
@@ -320,7 +320,6 @@ handle_restore_key_result (void *cls)
*
* @param h the handle for the escrow component
* @param anchor the escrow anchor returned by the GNUNET_ESCROW_put method
- * @param method the escrow method to use
* @param cb function to call with the restored ego on completion
* @param cb_cls closure for @a cb
*
@@ -329,7 +328,6 @@ handle_restore_key_result (void *cls)
struct GNUNET_ESCROW_Operation *
GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h,
const struct GNUNET_ESCROW_Anchor *anchor,
- enum GNUNET_ESCROW_Key_Escrow_Method method,
GNUNET_ESCROW_EgoContinuation cb,
void *cb_cls)
{
@@ -339,12 +337,12 @@ GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h,
op = GNUNET_new (struct GNUNET_ESCROW_Operation);
op->h = h;
op->id = get_op_id (h);
- op->method = method;
+ op->method = anchor->method;
op->cb_get = cb;
op->cb_cls = cb_cls;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- api = init_plugin (h, method);
+ api = init_plugin (h, anchor->method);
op->plugin_op_wrap = api->restore_key (h, anchor, &handle_restore_key_result, op->id);
return op;
diff --git a/src/escrow/gnunet-escrow.c b/src/escrow/gnunet-escrow.c
index 2f22fa194..2130b19fc 100644
--- a/src/escrow/gnunet-escrow.c
+++ b/src/escrow/gnunet-escrow.c
@@ -311,7 +311,6 @@ start_process ()
{
escrow_op = GNUNET_ESCROW_get (escrow_handle,
anchor,
- method,
&get_cb,
NULL);
return;
@@ -390,8 +389,8 @@ run (void *cls,
ret = 0;
- /* check if method is set */
- if (NULL == method_name)
+ /* check if method is set (needed for all operations except GET) */
+ if (NULL == method_name && GNUNET_YES != get_flag)
{
ret = 1;
fprintf (stderr, _ ("Escrow method (-m option) is missing\n"));
@@ -457,13 +456,18 @@ run (void *cls,
}
/* determine method */
- method = GNUNET_ESCROW_method_string_to_number (method_name);
- if (GNUNET_ESCROW_KEY_NONE == method)
+ if (NULL != method_name)
{
- ret = 1;
- fprintf (stderr, _ ("unknown method name!\n"));
- return;
+ method = GNUNET_ESCROW_method_string_to_number (method_name);
+ if (GNUNET_ESCROW_KEY_NONE == method)
+ {
+ ret = 1;
+ fprintf (stderr, _ ("unknown method name!\n"));
+ return;
+ }
}
+ else // initialize to error value (should not be used in this case)
+ method = GNUNET_ESCROW_KEY_NONE;
escrow_handle = GNUNET_ESCROW_init (c);
diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c
index cf12602ca..422a3849e 100644
--- a/src/escrow/plugin_escrow_gns.c
+++ b/src/escrow/plugin_escrow_gns.c
@@ -466,6 +466,7 @@ start_cont (void *cls)
struct ESCROW_GnsPluginOperation *p_op;
p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op;
+ p_op->sched_task = NULL;
p_op->cont (p_op->anchor_wrap);
cleanup_plugin_operation (plugin_op_wrap);
@@ -479,6 +480,7 @@ verify_cont (void *cls)
struct ESCROW_GnsPluginOperation *p_op;
p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op;
+ p_op->sched_task = NULL;
p_op->cont (p_op->verify_wrap);
cleanup_plugin_operation (plugin_op_wrap);
@@ -492,6 +494,7 @@ handle_restore_error (void *cls)
struct ESCROW_GnsPluginOperation *p_op;
p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op;
+ p_op->sched_task = NULL;
p_op->cont (p_op->ego_wrap);
cleanup_plugin_operation (plugin_op_wrap);
@@ -1456,10 +1459,17 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h,
p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
return plugin_op_wrap;
}
+ if (GNUNET_ESCROW_KEY_GNS != anchor->method)
+ {
+ w->verificationResult = GNUNET_ESCROW_INVALID;
+ w->emsg = _ ("This anchor was not created using GNS escrow!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
+ return plugin_op_wrap;
+ }
if (0 != strcmp (ego->name, anchor->egoName))
{
w->verificationResult = GNUNET_ESCROW_INVALID;
- w->emsg = _ ("This anchor was not created when putting ego that in escrow!\n");
+ w->emsg = _ ("This anchor was not created when putting that ego in escrow!\n");
p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
return plugin_op_wrap;
}
diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c
index 623504a6b..8e2c2204b 100644
--- a/src/escrow/plugin_escrow_plaintext.c
+++ b/src/escrow/plugin_escrow_plaintext.c
@@ -121,6 +121,7 @@ start_cont (void *cls)
struct ESCROW_PlaintextPluginOperation *p_op;
p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op;
+ p_op->sched_task = NULL;
p_op->cont (p_op->anchor_wrap);
cleanup_plugin_operation (plugin_op_wrap);
@@ -203,6 +204,7 @@ verify_cont (void *cls)
struct ESCROW_PlaintextPluginOperation *p_op;
p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op;
+ p_op->sched_task = NULL;
p_op->cont (p_op->verify_wrap);
cleanup_plugin_operation (plugin_op_wrap);
@@ -257,10 +259,17 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
return plugin_op_wrap;
}
+ if (GNUNET_ESCROW_KEY_PLAINTEXT != anchor->method)
+ {
+ w->verificationResult = GNUNET_ESCROW_INVALID;
+ w->emsg = _ ("This anchor was not created using plaintext escrow!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
+ return plugin_op_wrap;
+ }
if (0 != strcmp (ego->name, anchor->egoName))
{
w->verificationResult = GNUNET_ESCROW_INVALID;
- w->emsg = _ ("This anchor was not created when putting ego that in escrow!\n");
+ w->emsg = _ ("This anchor was not created when putting that ego in escrow!\n");
p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
return plugin_op_wrap;
}
@@ -355,6 +364,7 @@ handle_restore_error (void *cls)
struct ESCROW_PlaintextPluginOperation *p_op;
p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op;
+ p_op->sched_task = NULL;
p_op->cont (p_op->ego_wrap);
cleanup_plugin_operation (plugin_op_wrap);
diff --git a/src/include/gnunet_escrow_lib.h b/src/include/gnunet_escrow_lib.h
index e02906934..64422b1eb 100644
--- a/src/include/gnunet_escrow_lib.h
+++ b/src/include/gnunet_escrow_lib.h
@@ -311,7 +311,6 @@ GNUNET_ESCROW_put (
*
* @param h the handle for the escrow component
* @param anchor the escrow anchor returned by the GNUNET_ESCROW_put method
- * @param method the escrow method to use
* @param cb function to call with the restored ego on completion
* @param cb_cls closure for @a cb
*
@@ -321,7 +320,6 @@ struct GNUNET_ESCROW_Operation *
GNUNET_ESCROW_get (
struct GNUNET_ESCROW_Handle *h,
const struct GNUNET_ESCROW_Anchor *anchor,
- enum GNUNET_ESCROW_Key_Escrow_Method method,
GNUNET_ESCROW_EgoContinuation cb,
void *cb_cls);