aboutsummaryrefslogtreecommitdiff
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)
downloadgnunet-c2a7a669d9c014b86d6e046f7d297fc5556d9fd4.tar.gz
gnunet-c2a7a669d9c014b86d6e046f7d297fc5556d9fd4.zip
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,
133 (void *)h->cfg); 133 (void *)h->cfg);
134 return anastasis_api; 134 return anastasis_api;
135 case GNUNET_ESCROW_KEY_NONE: // error case 135 case GNUNET_ESCROW_KEY_NONE: // error case
136 fprintf (stderr, "incorrect escrow method!"); 136 fprintf (stderr, "incorrect escrow method!\n");
137 return NULL; 137 return NULL;
138 } 138 }
139 // should never be reached 139 // should never be reached
@@ -320,7 +320,6 @@ handle_restore_key_result (void *cls)
320 * 320 *
321 * @param h the handle for the escrow component 321 * @param h the handle for the escrow component
322 * @param anchor the escrow anchor returned by the GNUNET_ESCROW_put method 322 * @param anchor the escrow anchor returned by the GNUNET_ESCROW_put method
323 * @param method the escrow method to use
324 * @param cb function to call with the restored ego on completion 323 * @param cb function to call with the restored ego on completion
325 * @param cb_cls closure for @a cb 324 * @param cb_cls closure for @a cb
326 * 325 *
@@ -329,7 +328,6 @@ handle_restore_key_result (void *cls)
329struct GNUNET_ESCROW_Operation * 328struct GNUNET_ESCROW_Operation *
330GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h, 329GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h,
331 const struct GNUNET_ESCROW_Anchor *anchor, 330 const struct GNUNET_ESCROW_Anchor *anchor,
332 enum GNUNET_ESCROW_Key_Escrow_Method method,
333 GNUNET_ESCROW_EgoContinuation cb, 331 GNUNET_ESCROW_EgoContinuation cb,
334 void *cb_cls) 332 void *cb_cls)
335{ 333{
@@ -339,12 +337,12 @@ GNUNET_ESCROW_get (struct GNUNET_ESCROW_Handle *h,
339 op = GNUNET_new (struct GNUNET_ESCROW_Operation); 337 op = GNUNET_new (struct GNUNET_ESCROW_Operation);
340 op->h = h; 338 op->h = h;
341 op->id = get_op_id (h); 339 op->id = get_op_id (h);
342 op->method = method; 340 op->method = anchor->method;
343 op->cb_get = cb; 341 op->cb_get = cb;
344 op->cb_cls = cb_cls; 342 op->cb_cls = cb_cls;
345 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 343 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
346 344
347 api = init_plugin (h, method); 345 api = init_plugin (h, anchor->method);
348 op->plugin_op_wrap = api->restore_key (h, anchor, &handle_restore_key_result, op->id); 346 op->plugin_op_wrap = api->restore_key (h, anchor, &handle_restore_key_result, op->id);
349 347
350 return op; 348 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 ()
311 { 311 {
312 escrow_op = GNUNET_ESCROW_get (escrow_handle, 312 escrow_op = GNUNET_ESCROW_get (escrow_handle,
313 anchor, 313 anchor,
314 method,
315 &get_cb, 314 &get_cb,
316 NULL); 315 NULL);
317 return; 316 return;
@@ -390,8 +389,8 @@ run (void *cls,
390 389
391 ret = 0; 390 ret = 0;
392 391
393 /* check if method is set */ 392 /* check if method is set (needed for all operations except GET) */
394 if (NULL == method_name) 393 if (NULL == method_name && GNUNET_YES != get_flag)
395 { 394 {
396 ret = 1; 395 ret = 1;
397 fprintf (stderr, _ ("Escrow method (-m option) is missing\n")); 396 fprintf (stderr, _ ("Escrow method (-m option) is missing\n"));
@@ -457,13 +456,18 @@ run (void *cls,
457 } 456 }
458 457
459 /* determine method */ 458 /* determine method */
460 method = GNUNET_ESCROW_method_string_to_number (method_name); 459 if (NULL != method_name)
461 if (GNUNET_ESCROW_KEY_NONE == method)
462 { 460 {
463 ret = 1; 461 method = GNUNET_ESCROW_method_string_to_number (method_name);
464 fprintf (stderr, _ ("unknown method name!\n")); 462 if (GNUNET_ESCROW_KEY_NONE == method)
465 return; 463 {
464 ret = 1;
465 fprintf (stderr, _ ("unknown method name!\n"));
466 return;
467 }
466 } 468 }
469 else // initialize to error value (should not be used in this case)
470 method = GNUNET_ESCROW_KEY_NONE;
467 471
468 escrow_handle = GNUNET_ESCROW_init (c); 472 escrow_handle = GNUNET_ESCROW_init (c);
469 473
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)
466 struct ESCROW_GnsPluginOperation *p_op; 466 struct ESCROW_GnsPluginOperation *p_op;
467 467
468 p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op; 468 p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op;
469 p_op->sched_task = NULL;
469 p_op->cont (p_op->anchor_wrap); 470 p_op->cont (p_op->anchor_wrap);
470 471
471 cleanup_plugin_operation (plugin_op_wrap); 472 cleanup_plugin_operation (plugin_op_wrap);
@@ -479,6 +480,7 @@ verify_cont (void *cls)
479 struct ESCROW_GnsPluginOperation *p_op; 480 struct ESCROW_GnsPluginOperation *p_op;
480 481
481 p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op; 482 p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op;
483 p_op->sched_task = NULL;
482 p_op->cont (p_op->verify_wrap); 484 p_op->cont (p_op->verify_wrap);
483 485
484 cleanup_plugin_operation (plugin_op_wrap); 486 cleanup_plugin_operation (plugin_op_wrap);
@@ -492,6 +494,7 @@ handle_restore_error (void *cls)
492 struct ESCROW_GnsPluginOperation *p_op; 494 struct ESCROW_GnsPluginOperation *p_op;
493 495
494 p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op; 496 p_op = (struct ESCROW_GnsPluginOperation*)plugin_op_wrap->plugin_op;
497 p_op->sched_task = NULL;
495 p_op->cont (p_op->ego_wrap); 498 p_op->cont (p_op->ego_wrap);
496 499
497 cleanup_plugin_operation (plugin_op_wrap); 500 cleanup_plugin_operation (plugin_op_wrap);
@@ -1456,10 +1459,17 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h,
1456 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); 1459 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
1457 return plugin_op_wrap; 1460 return plugin_op_wrap;
1458 } 1461 }
1462 if (GNUNET_ESCROW_KEY_GNS != anchor->method)
1463 {
1464 w->verificationResult = GNUNET_ESCROW_INVALID;
1465 w->emsg = _ ("This anchor was not created using GNS escrow!\n");
1466 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
1467 return plugin_op_wrap;
1468 }
1459 if (0 != strcmp (ego->name, anchor->egoName)) 1469 if (0 != strcmp (ego->name, anchor->egoName))
1460 { 1470 {
1461 w->verificationResult = GNUNET_ESCROW_INVALID; 1471 w->verificationResult = GNUNET_ESCROW_INVALID;
1462 w->emsg = _ ("This anchor was not created when putting ego that in escrow!\n"); 1472 w->emsg = _ ("This anchor was not created when putting that ego in escrow!\n");
1463 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); 1473 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
1464 return plugin_op_wrap; 1474 return plugin_op_wrap;
1465 } 1475 }
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)
121 struct ESCROW_PlaintextPluginOperation *p_op; 121 struct ESCROW_PlaintextPluginOperation *p_op;
122 122
123 p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op; 123 p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op;
124 p_op->sched_task = NULL;
124 p_op->cont (p_op->anchor_wrap); 125 p_op->cont (p_op->anchor_wrap);
125 126
126 cleanup_plugin_operation (plugin_op_wrap); 127 cleanup_plugin_operation (plugin_op_wrap);
@@ -203,6 +204,7 @@ verify_cont (void *cls)
203 struct ESCROW_PlaintextPluginOperation *p_op; 204 struct ESCROW_PlaintextPluginOperation *p_op;
204 205
205 p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op; 206 p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op;
207 p_op->sched_task = NULL;
206 p_op->cont (p_op->verify_wrap); 208 p_op->cont (p_op->verify_wrap);
207 209
208 cleanup_plugin_operation (plugin_op_wrap); 210 cleanup_plugin_operation (plugin_op_wrap);
@@ -257,10 +259,17 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
257 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); 259 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
258 return plugin_op_wrap; 260 return plugin_op_wrap;
259 } 261 }
262 if (GNUNET_ESCROW_KEY_PLAINTEXT != anchor->method)
263 {
264 w->verificationResult = GNUNET_ESCROW_INVALID;
265 w->emsg = _ ("This anchor was not created using plaintext escrow!\n");
266 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
267 return plugin_op_wrap;
268 }
260 if (0 != strcmp (ego->name, anchor->egoName)) 269 if (0 != strcmp (ego->name, anchor->egoName))
261 { 270 {
262 w->verificationResult = GNUNET_ESCROW_INVALID; 271 w->verificationResult = GNUNET_ESCROW_INVALID;
263 w->emsg = _ ("This anchor was not created when putting ego that in escrow!\n"); 272 w->emsg = _ ("This anchor was not created when putting that ego in escrow!\n");
264 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); 273 p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
265 return plugin_op_wrap; 274 return plugin_op_wrap;
266 } 275 }
@@ -355,6 +364,7 @@ handle_restore_error (void *cls)
355 struct ESCROW_PlaintextPluginOperation *p_op; 364 struct ESCROW_PlaintextPluginOperation *p_op;
356 365
357 p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op; 366 p_op = (struct ESCROW_PlaintextPluginOperation*)plugin_op_wrap->plugin_op;
367 p_op->sched_task = NULL;
358 p_op->cont (p_op->ego_wrap); 368 p_op->cont (p_op->ego_wrap);
359 369
360 cleanup_plugin_operation (plugin_op_wrap); 370 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 (
311 * 311 *
312 * @param h the handle for the escrow component 312 * @param h the handle for the escrow component
313 * @param anchor the escrow anchor returned by the GNUNET_ESCROW_put method 313 * @param anchor the escrow anchor returned by the GNUNET_ESCROW_put method
314 * @param method the escrow method to use
315 * @param cb function to call with the restored ego on completion 314 * @param cb function to call with the restored ego on completion
316 * @param cb_cls closure for @a cb 315 * @param cb_cls closure for @a cb
317 * 316 *
@@ -321,7 +320,6 @@ struct GNUNET_ESCROW_Operation *
321GNUNET_ESCROW_get ( 320GNUNET_ESCROW_get (
322 struct GNUNET_ESCROW_Handle *h, 321 struct GNUNET_ESCROW_Handle *h,
323 const struct GNUNET_ESCROW_Anchor *anchor, 322 const struct GNUNET_ESCROW_Anchor *anchor,
324 enum GNUNET_ESCROW_Key_Escrow_Method method,
325 GNUNET_ESCROW_EgoContinuation cb, 323 GNUNET_ESCROW_EgoContinuation cb,
326 void *cb_cls); 324 void *cb_cls);
327 325