diff options
-rw-r--r-- | src/escrow/escrow_api.c | 173 | ||||
-rw-r--r-- | src/escrow/gnunet-escrow.c | 17 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_anastasis.c | 35 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_gns.c | 38 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_plaintext.c | 44 | ||||
-rw-r--r-- | src/include/gnunet_escrow_lib.h | 37 | ||||
-rw-r--r-- | src/include/gnunet_escrow_plugin.h | 38 |
7 files changed, 191 insertions, 191 deletions
diff --git a/src/escrow/escrow_api.c b/src/escrow/escrow_api.c index e35ba3e9e..e48dc28e4 100644 --- a/src/escrow/escrow_api.c +++ b/src/escrow/escrow_api.c | |||
@@ -51,6 +51,30 @@ static int anastasis_initialized; | |||
51 | 51 | ||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Plaintext method string | ||
55 | */ | ||
56 | static const char *plaintext_string = "plaintext"; | ||
57 | |||
58 | |||
59 | /** | ||
60 | * GNS method string | ||
61 | */ | ||
62 | static const char *gns_string = "gns"; | ||
63 | |||
64 | |||
65 | /** | ||
66 | * Anastasis method string | ||
67 | */ | ||
68 | static const char *anastasis_string = "anastasis"; | ||
69 | |||
70 | |||
71 | /** | ||
72 | * None method string | ||
73 | */ | ||
74 | static const char *none_string = "INVALID-METHOD"; | ||
75 | |||
76 | |||
77 | /** | ||
54 | * Pointer to the plaintext plugin API | 78 | * Pointer to the plaintext plugin API |
55 | */ | 79 | */ |
56 | static struct GNUNET_ESCROW_KeyPluginFunctions *plaintext_api; | 80 | static struct GNUNET_ESCROW_KeyPluginFunctions *plaintext_api; |
@@ -414,43 +438,158 @@ GNUNET_ESCROW_get_status (struct GNUNET_ESCROW_Handle *h, | |||
414 | * Deserialize an escrow anchor string (e.g. from command line) into a | 438 | * Deserialize an escrow anchor string (e.g. from command line) into a |
415 | * GNUNET_ESCROW_Anchor struct | 439 | * GNUNET_ESCROW_Anchor struct |
416 | * | 440 | * |
417 | * @param h the handle for the escrow component | ||
418 | * @param anchorString the encoded escrow anchor string | 441 | * @param anchorString the encoded escrow anchor string |
419 | * @param method the escrow method to use | ||
420 | * | 442 | * |
421 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, | 443 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, |
422 | * NULL if we failed to parse the string | 444 | * NULL if we failed to parse the string |
423 | */ | 445 | */ |
424 | struct GNUNET_ESCROW_Anchor * | 446 | struct GNUNET_ESCROW_Anchor * |
425 | GNUNET_ESCROW_anchor_string_to_data (struct GNUNET_ESCROW_Handle *h, | 447 | GNUNET_ESCROW_anchor_string_to_data (const char *anchorString) |
426 | char *anchorString, | ||
427 | enum GNUNET_ESCROW_Key_Escrow_Method method) | ||
428 | { | 448 | { |
429 | const struct GNUNET_ESCROW_KeyPluginFunctions *api; | 449 | struct GNUNET_ESCROW_Anchor *anchor; |
430 | 450 | uint32_t data_size; | |
431 | api = init_plugin (h, method); | 451 | char *anchorStringCopy, *ptr; |
432 | return api->anchor_string_to_data (h, anchorString); | 452 | char *methodString, *egoNameString, *anchorDataString; |
453 | char delimiter[] = ":"; | ||
454 | |||
455 | anchorStringCopy = GNUNET_strdup (anchorString); | ||
456 | anchor = NULL; | ||
457 | |||
458 | /* parse and decode method */ | ||
459 | ptr = strtok (anchorStringCopy, delimiter); | ||
460 | if (NULL == ptr) | ||
461 | goto END; | ||
462 | GNUNET_STRINGS_urldecode (ptr, strlen (ptr), &methodString); | ||
463 | /* parse and decode ego name */ | ||
464 | ptr = strtok (NULL, delimiter); | ||
465 | if (NULL == ptr) | ||
466 | goto END; | ||
467 | GNUNET_STRINGS_urldecode (ptr, strlen (ptr), &egoNameString); | ||
468 | /* parse and decode anchor data */ | ||
469 | ptr = strtok (NULL, delimiter); | ||
470 | if (NULL == ptr) | ||
471 | goto END; | ||
472 | GNUNET_STRINGS_urldecode (ptr, strlen (ptr), &anchorDataString); | ||
473 | /* check if string is over */ | ||
474 | ptr = strtok (NULL, delimiter); | ||
475 | if (NULL != ptr) | ||
476 | goto END; | ||
477 | |||
478 | data_size = strlen (anchorDataString); // data is NOT null-terminated | ||
479 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) | ||
480 | + data_size | ||
481 | + strlen (egoNameString) + 1); | ||
482 | anchor->size = data_size; | ||
483 | anchor->method = GNUNET_ESCROW_method_string_to_number (methodString); | ||
484 | |||
485 | // ptr is now used to fill the anchor | ||
486 | ptr = (char *)&anchor[1]; | ||
487 | strcpy (ptr, anchorDataString); | ||
488 | ptr += data_size; | ||
489 | anchor->egoName = ptr; | ||
490 | strcpy (ptr, egoNameString); | ||
491 | |||
492 | END: | ||
493 | /* free all non-NULL strings */ | ||
494 | if (NULL != anchorStringCopy) | ||
495 | GNUNET_free (anchorStringCopy); | ||
496 | if (NULL != methodString) | ||
497 | GNUNET_free (methodString); | ||
498 | if (NULL != egoNameString) | ||
499 | GNUNET_free (egoNameString); | ||
500 | if (NULL != anchorDataString) | ||
501 | GNUNET_free (anchorDataString); | ||
502 | |||
503 | return anchor; | ||
433 | } | 504 | } |
434 | 505 | ||
435 | 506 | ||
436 | /** | 507 | /** |
437 | * Serialize an escrow anchor (struct GNUNET_ESCROW_Anchor) into a string | 508 | * Serialize an escrow anchor (struct GNUNET_ESCROW_Anchor) into a string |
438 | * | 509 | * |
439 | * @param h the handle for the escrow component | ||
440 | * @param escrowAnchor the escrow anchor struct | 510 | * @param escrowAnchor the escrow anchor struct |
441 | * @param method the escrow method to use | ||
442 | * | 511 | * |
443 | * @return the encoded escrow anchor string | 512 | * @return the encoded escrow anchor string |
444 | */ | 513 | */ |
445 | char * | 514 | char * |
446 | GNUNET_ESCROW_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h, | 515 | GNUNET_ESCROW_anchor_data_to_string (const struct GNUNET_ESCROW_Anchor *escrowAnchor) |
447 | struct GNUNET_ESCROW_Anchor *escrowAnchor, | ||
448 | enum GNUNET_ESCROW_Key_Escrow_Method method) | ||
449 | { | 516 | { |
450 | const struct GNUNET_ESCROW_KeyPluginFunctions *api; | 517 | char *anchorString, *ptr; |
518 | const char *methodString, *egoNameString, *anchorData; | ||
519 | char *methodStringEnc, *egoNameStringEnc, *anchorDataEnc; | ||
520 | |||
521 | methodString = GNUNET_ESCROW_method_number_to_string (escrowAnchor->method); | ||
522 | GNUNET_STRINGS_urlencode (methodString, strlen (methodString), &methodStringEnc); | ||
523 | egoNameString = escrowAnchor->egoName; | ||
524 | GNUNET_STRINGS_urlencode (egoNameString, strlen (egoNameString), &egoNameStringEnc); | ||
525 | anchorData = (const char *)&escrowAnchor[1]; | ||
526 | GNUNET_STRINGS_urlencode (anchorData, escrowAnchor->size, &anchorDataEnc); | ||
527 | |||
528 | anchorString = GNUNET_malloc (strlen (methodStringEnc) + 1 | ||
529 | + strlen (egoNameStringEnc) + 1 | ||
530 | + strlen (anchorDataEnc) | ||
531 | + 1); | ||
532 | |||
533 | ptr = anchorString; | ||
534 | GNUNET_memcpy (ptr, methodStringEnc, strlen (methodStringEnc)); | ||
535 | ptr += strlen (methodStringEnc); | ||
536 | GNUNET_free (methodStringEnc); | ||
537 | *(ptr++) = ':'; | ||
538 | GNUNET_memcpy (ptr, egoNameStringEnc, strlen (egoNameStringEnc)); | ||
539 | ptr += strlen (egoNameStringEnc); | ||
540 | GNUNET_free (egoNameStringEnc); | ||
541 | *(ptr++) = ':'; | ||
542 | GNUNET_memcpy (ptr, anchorDataEnc, strlen (anchorDataEnc)); | ||
543 | ptr += strlen (anchorDataEnc); | ||
544 | GNUNET_free (anchorDataEnc); | ||
545 | *(ptr++) = '\0'; | ||
546 | |||
547 | return anchorString; | ||
548 | } | ||
451 | 549 | ||
452 | api = init_plugin (h, method); | 550 | |
453 | return api->anchor_data_to_string (h, escrowAnchor); | 551 | /** |
552 | * Convert a method name string to the respective enum number | ||
553 | * | ||
554 | * @param methodString the method name string | ||
555 | * | ||
556 | * @return the enum number | ||
557 | */ | ||
558 | enum GNUNET_ESCROW_Key_Escrow_Method | ||
559 | GNUNET_ESCROW_method_string_to_number (const char *methodString) | ||
560 | { | ||
561 | if (!strcmp (plaintext_string, methodString)) | ||
562 | return GNUNET_ESCROW_KEY_PLAINTEXT; | ||
563 | else if (!strcmp (gns_string, methodString)) | ||
564 | return GNUNET_ESCROW_KEY_GNS; | ||
565 | else if (!strcmp (anastasis_string, methodString)) | ||
566 | return GNUNET_ESCROW_KEY_ANASTASIS; | ||
567 | else | ||
568 | return GNUNET_ESCROW_KEY_NONE; | ||
569 | } | ||
570 | |||
571 | |||
572 | /** | ||
573 | * Convert a method enum number to the respective method string | ||
574 | * | ||
575 | * @param method the method enum number | ||
576 | * | ||
577 | * @return the method string | ||
578 | */ | ||
579 | const char * | ||
580 | GNUNET_ESCROW_method_number_to_string (enum GNUNET_ESCROW_Key_Escrow_Method method) | ||
581 | { | ||
582 | switch (method) | ||
583 | { | ||
584 | case GNUNET_ESCROW_KEY_PLAINTEXT: | ||
585 | return plaintext_string; | ||
586 | case GNUNET_ESCROW_KEY_GNS: | ||
587 | return gns_string; | ||
588 | case GNUNET_ESCROW_KEY_ANASTASIS: | ||
589 | return anastasis_string; | ||
590 | default: | ||
591 | return none_string; | ||
592 | } | ||
454 | } | 593 | } |
455 | 594 | ||
456 | 595 | ||
diff --git a/src/escrow/gnunet-escrow.c b/src/escrow/gnunet-escrow.c index 2d6d4d141..e66c43046 100644 --- a/src/escrow/gnunet-escrow.c +++ b/src/escrow/gnunet-escrow.c | |||
@@ -209,9 +209,7 @@ put_cb (void *cls, | |||
209 | } | 209 | } |
210 | else | 210 | else |
211 | { | 211 | { |
212 | anchorString = GNUNET_ESCROW_anchor_data_to_string (escrow_handle, | 212 | anchorString = GNUNET_ESCROW_anchor_data_to_string (escrowAnchor); |
213 | escrowAnchor, | ||
214 | method); | ||
215 | 213 | ||
216 | fprintf (stdout, "Escrow finished! Please keep the following anchor " | 214 | fprintf (stdout, "Escrow finished! Please keep the following anchor " |
217 | "in order to restore the key later!\n%s\n", anchorString); | 215 | "in order to restore the key later!\n%s\n", anchorString); |
@@ -458,13 +456,8 @@ run (void *cls, | |||
458 | } | 456 | } |
459 | 457 | ||
460 | /* determine method */ | 458 | /* determine method */ |
461 | if (!strcmp (plaintext_string, method_name)) | 459 | method = GNUNET_ESCROW_method_string_to_number (method_name); |
462 | method = GNUNET_ESCROW_KEY_PLAINTEXT; | 460 | if (GNUNET_ESCROW_KEY_NONE == method) |
463 | else if (!strcmp (gns_string, method_name)) | ||
464 | method = GNUNET_ESCROW_KEY_GNS; | ||
465 | else if (!strcmp (anastasis_string, method_name)) | ||
466 | method = GNUNET_ESCROW_KEY_ANASTASIS; | ||
467 | else | ||
468 | { | 461 | { |
469 | ret = 1; | 462 | ret = 1; |
470 | fprintf (stderr, _ ("unknown method name!\n")); | 463 | fprintf (stderr, _ ("unknown method name!\n")); |
@@ -476,9 +469,7 @@ run (void *cls, | |||
476 | if (NULL != anchor_string) | 469 | if (NULL != anchor_string) |
477 | { | 470 | { |
478 | /* parse anchor_string according to method */ | 471 | /* parse anchor_string according to method */ |
479 | anchor = GNUNET_ESCROW_anchor_string_to_data (escrow_handle, | 472 | anchor = GNUNET_ESCROW_anchor_string_to_data (anchor_string); |
480 | anchor_string, | ||
481 | method); | ||
482 | if (NULL == anchor) | 473 | if (NULL == anchor) |
483 | { | 474 | { |
484 | ret = 1; | 475 | ret = 1; |
diff --git a/src/escrow/plugin_escrow_anastasis.c b/src/escrow/plugin_escrow_anastasis.c index f4ab4dcbe..0c96d8d8d 100644 --- a/src/escrow/plugin_escrow_anastasis.c +++ b/src/escrow/plugin_escrow_anastasis.c | |||
@@ -153,40 +153,6 @@ anastasis_get_status (struct GNUNET_ESCROW_Handle *h, | |||
153 | 153 | ||
154 | 154 | ||
155 | /** | 155 | /** |
156 | * Deserialize an escrow anchor string into a GNUNET_ESCROW_Anchor struct | ||
157 | * | ||
158 | * @param anchorString the encoded escrow anchor string | ||
159 | * | ||
160 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, | ||
161 | * NULL if we failed to parse the string | ||
162 | */ | ||
163 | struct GNUNET_ESCROW_Anchor * | ||
164 | anastasis_anchor_string_to_data (struct GNUNET_ESCROW_Handle *h, | ||
165 | char *anchorString) | ||
166 | { | ||
167 | return ESCROW_anchor_string_to_data (anchorString, | ||
168 | GNUNET_ESCROW_KEY_ANASTASIS); | ||
169 | } | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Serialize an escrow anchor struct into a string | ||
174 | * | ||
175 | * @param h the handle for the escrow component | ||
176 | * @param escrowAnchor the escrow anchor struct | ||
177 | * | ||
178 | * @return the encoded escrow anchor string | ||
179 | */ | ||
180 | char * | ||
181 | anastasis_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h, | ||
182 | struct GNUNET_ESCROW_Anchor *escrowAnchor) | ||
183 | { | ||
184 | return ESCROW_anchor_data_to_string (escrowAnchor, | ||
185 | GNUNET_ESCROW_KEY_ANASTASIS); | ||
186 | } | ||
187 | |||
188 | |||
189 | /** | ||
190 | * Cancel an Anastasis plugin operation. | 156 | * Cancel an Anastasis plugin operation. |
191 | * | 157 | * |
192 | * @param plugin_op_wrap the plugin operation wrapper containing the operation | 158 | * @param plugin_op_wrap the plugin operation wrapper containing the operation |
@@ -227,7 +193,6 @@ libgnunet_plugin_escrow_anastasis_init (void *cls) | |||
227 | api->verify_key_escrow = &verify_anastasis_key_escrow; | 193 | api->verify_key_escrow = &verify_anastasis_key_escrow; |
228 | api->restore_key = &restore_anastasis_key_escrow; | 194 | api->restore_key = &restore_anastasis_key_escrow; |
229 | api->get_status = &anastasis_get_status; | 195 | api->get_status = &anastasis_get_status; |
230 | api->anchor_string_to_data = &anastasis_anchor_string_to_data; | ||
231 | api->cancel_plugin_operation = &cancel_anastasis_operation; | 196 | api->cancel_plugin_operation = &cancel_anastasis_operation; |
232 | 197 | ||
233 | ph.state = ESCROW_PLUGIN_STATE_INIT; | 198 | ph.state = ESCROW_PLUGIN_STATE_INIT; |
diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c index 121fdc4af..a3a3cc81b 100644 --- a/src/escrow/plugin_escrow_gns.c +++ b/src/escrow/plugin_escrow_gns.c | |||
@@ -1320,7 +1320,7 @@ get_user_secret_from_anchor (const struct GNUNET_ESCROW_Anchor *anchor) | |||
1320 | 1320 | ||
1321 | static void | 1321 | static void |
1322 | restore_private_key (struct ESCROW_PluginOperationWrapper *plugin_op_wrap, | 1322 | restore_private_key (struct ESCROW_PluginOperationWrapper *plugin_op_wrap, |
1323 | struct GNUNET_ESCROW_Anchor *escrowAnchor, | 1323 | struct GNUNET_ESCROW_Anchor *escrowAnchor, // TODO: use escrowAnchor?? |
1324 | PkContinuation cont, | 1324 | PkContinuation cont, |
1325 | void *cont_cls) | 1325 | void *cont_cls) |
1326 | { | 1326 | { |
@@ -1657,40 +1657,6 @@ gns_get_status (struct GNUNET_ESCROW_Handle *h, | |||
1657 | 1657 | ||
1658 | 1658 | ||
1659 | /** | 1659 | /** |
1660 | * Deserialize an escrow anchor string into a GNUNET_ESCROW_Anchor struct | ||
1661 | * | ||
1662 | * @param anchorString the encoded escrow anchor string | ||
1663 | * | ||
1664 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, | ||
1665 | * NULL if we failed to parse the string | ||
1666 | */ | ||
1667 | struct GNUNET_ESCROW_Anchor * | ||
1668 | gns_anchor_string_to_data (struct GNUNET_ESCROW_Handle *h, | ||
1669 | char *anchorString) | ||
1670 | { | ||
1671 | return ESCROW_anchor_string_to_data (anchorString, | ||
1672 | GNUNET_ESCROW_KEY_GNS); | ||
1673 | } | ||
1674 | |||
1675 | |||
1676 | /** | ||
1677 | * Serialize an escrow anchor struct into a string | ||
1678 | * | ||
1679 | * @param h the handle for the escrow component | ||
1680 | * @param escrowAnchor the escrow anchor struct | ||
1681 | * | ||
1682 | * @return the encoded escrow anchor string | ||
1683 | */ | ||
1684 | char * | ||
1685 | gns_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h, | ||
1686 | struct GNUNET_ESCROW_Anchor *escrowAnchor) | ||
1687 | { | ||
1688 | return ESCROW_anchor_data_to_string (escrowAnchor, | ||
1689 | GNUNET_ESCROW_KEY_GNS); | ||
1690 | } | ||
1691 | |||
1692 | |||
1693 | /** | ||
1694 | * Cancel a GNS plugin operation. | 1660 | * Cancel a GNS plugin operation. |
1695 | * | 1661 | * |
1696 | * @param plugin_op_wrap the plugin operation wrapper containing the operation | 1662 | * @param plugin_op_wrap the plugin operation wrapper containing the operation |
@@ -1742,8 +1708,6 @@ libgnunet_plugin_escrow_gns_init (void *cls) | |||
1742 | api->verify_key_escrow = &verify_gns_key_escrow; | 1708 | api->verify_key_escrow = &verify_gns_key_escrow; |
1743 | api->restore_key = &restore_gns_key_escrow; | 1709 | api->restore_key = &restore_gns_key_escrow; |
1744 | api->get_status = &gns_get_status; | 1710 | api->get_status = &gns_get_status; |
1745 | api->anchor_string_to_data = &gns_anchor_string_to_data; | ||
1746 | api->anchor_data_to_string = &gns_anchor_data_to_string; | ||
1747 | api->cancel_plugin_operation = &cancel_gns_operation; | 1711 | api->cancel_plugin_operation = &cancel_gns_operation; |
1748 | 1712 | ||
1749 | ph.state = ESCROW_PLUGIN_STATE_INIT; | 1713 | ph.state = ESCROW_PLUGIN_STATE_INIT; |
diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c index 215c8127e..b26653667 100644 --- a/src/escrow/plugin_escrow_plaintext.c +++ b/src/escrow/plugin_escrow_plaintext.c | |||
@@ -266,8 +266,9 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
266 | } | 266 | } |
267 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); | 267 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); |
268 | pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk); | 268 | pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk); |
269 | verificationResult = strcmp (pkString, | 269 | verificationResult = strncmp (pkString, |
270 | (char *)&escrowAnchor[1]) == 0 ? | 270 | (char *)&escrowAnchor[1], |
271 | escrowAnchor->size) == 0 ? | ||
271 | GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID; | 272 | GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID; |
272 | 273 | ||
273 | w->verificationResult = verificationResult; | 274 | w->verificationResult = verificationResult; |
@@ -408,7 +409,7 @@ restore_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
408 | } | 409 | } |
409 | if (GNUNET_OK != | 410 | if (GNUNET_OK != |
410 | GNUNET_CRYPTO_ecdsa_private_key_from_string ((char *)&anchor[1], | 411 | GNUNET_CRYPTO_ecdsa_private_key_from_string ((char *)&anchor[1], |
411 | strlen ((char *)&anchor[1]), | 412 | anchor->size, |
412 | &pk)) | 413 | &pk)) |
413 | { | 414 | { |
414 | w->ego = NULL; | 415 | w->ego = NULL; |
@@ -445,41 +446,6 @@ plaintext_get_status (struct GNUNET_ESCROW_Handle *h, | |||
445 | 446 | ||
446 | 447 | ||
447 | /** | 448 | /** |
448 | * Deserialize an escrow anchor string into a GNUNET_ESCROW_Anchor struct | ||
449 | * | ||
450 | * @param h the handle for the escrow component | ||
451 | * @param anchorString the encoded escrow anchor string | ||
452 | * | ||
453 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, | ||
454 | * NULL if we failed to parse the string | ||
455 | */ | ||
456 | struct GNUNET_ESCROW_Anchor * | ||
457 | plaintext_anchor_string_to_data (struct GNUNET_ESCROW_Handle *h, | ||
458 | char *anchorString) | ||
459 | { | ||
460 | return ESCROW_anchor_string_to_data (anchorString, | ||
461 | GNUNET_ESCROW_KEY_PLAINTEXT); | ||
462 | } | ||
463 | |||
464 | |||
465 | /** | ||
466 | * Serialize an escrow anchor struct into a string | ||
467 | * | ||
468 | * @param h the handle for the escrow component | ||
469 | * @param escrowAnchor the escrow anchor struct | ||
470 | * | ||
471 | * @return the encoded escrow anchor string | ||
472 | */ | ||
473 | char * | ||
474 | plaintext_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h, | ||
475 | struct GNUNET_ESCROW_Anchor *escrowAnchor) | ||
476 | { | ||
477 | return ESCROW_anchor_data_to_string (escrowAnchor, | ||
478 | GNUNET_ESCROW_KEY_PLAINTEXT); | ||
479 | } | ||
480 | |||
481 | |||
482 | /** | ||
483 | * Cancel a plaintext plugin operation. | 449 | * Cancel a plaintext plugin operation. |
484 | * | 450 | * |
485 | * @param plugin_op_wrap the plugin operation wrapper containing the operation | 451 | * @param plugin_op_wrap the plugin operation wrapper containing the operation |
@@ -537,8 +503,6 @@ libgnunet_plugin_escrow_plaintext_init (void *cls) | |||
537 | api->verify_key_escrow = &verify_plaintext_key_escrow; | 503 | api->verify_key_escrow = &verify_plaintext_key_escrow; |
538 | api->restore_key = &restore_plaintext_key_escrow; | 504 | api->restore_key = &restore_plaintext_key_escrow; |
539 | api->get_status = &plaintext_get_status; | 505 | api->get_status = &plaintext_get_status; |
540 | api->anchor_string_to_data = &plaintext_anchor_string_to_data; | ||
541 | api->anchor_data_to_string = &plaintext_anchor_data_to_string; | ||
542 | api->cancel_plugin_operation = &cancel_plaintext_operation; | 506 | api->cancel_plugin_operation = &cancel_plaintext_operation; |
543 | 507 | ||
544 | ph.state = ESCROW_PLUGIN_STATE_INIT; | 508 | ph.state = ESCROW_PLUGIN_STATE_INIT; |
diff --git a/src/include/gnunet_escrow_lib.h b/src/include/gnunet_escrow_lib.h index dddf5e030..f9135c28e 100644 --- a/src/include/gnunet_escrow_lib.h +++ b/src/include/gnunet_escrow_lib.h | |||
@@ -77,7 +77,7 @@ struct GNUNET_ESCROW_Anchor | |||
77 | /** | 77 | /** |
78 | * The name of the ego that was put in escrow. | 78 | * The name of the ego that was put in escrow. |
79 | */ | 79 | */ |
80 | char *egoName; | 80 | const char *egoName; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * The size of the anchor data. | 83 | * The size of the anchor data. |
@@ -370,33 +370,48 @@ GNUNET_ESCROW_get_status ( | |||
370 | * Deserialize an escrow anchor string (e.g. from command line) into a | 370 | * Deserialize an escrow anchor string (e.g. from command line) into a |
371 | * GNUNET_ESCROW_Anchor struct | 371 | * GNUNET_ESCROW_Anchor struct |
372 | * | 372 | * |
373 | * @param h the handle for the escrow component | ||
374 | * @param anchorString the encoded escrow anchor string | 373 | * @param anchorString the encoded escrow anchor string |
375 | * @param method the escrow method to use | ||
376 | * | 374 | * |
377 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, | 375 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, |
378 | * NULL if we failed to parse the string | 376 | * NULL if we failed to parse the string |
379 | */ | 377 | */ |
380 | struct GNUNET_ESCROW_Anchor * | 378 | struct GNUNET_ESCROW_Anchor * |
381 | GNUNET_ESCROW_anchor_string_to_data ( | 379 | GNUNET_ESCROW_anchor_string_to_data ( |
382 | struct GNUNET_ESCROW_Handle *h, | 380 | const char *anchorString); |
383 | char *anchorString, | ||
384 | enum GNUNET_ESCROW_Key_Escrow_Method method); | ||
385 | 381 | ||
386 | 382 | ||
387 | /** | 383 | /** |
388 | * Serialize an escrow anchor (struct GNUNET_ESCROW_Anchor) into a string | 384 | * Serialize an escrow anchor (struct GNUNET_ESCROW_Anchor) into a string |
389 | * | 385 | * |
390 | * @param h the handle for the escrow component | ||
391 | * @param escrowAnchor the escrow anchor struct | 386 | * @param escrowAnchor the escrow anchor struct |
392 | * @param method the escrow method to use | ||
393 | * | 387 | * |
394 | * @return the encoded escrow anchor string | 388 | * @return the encoded escrow anchor string |
395 | */ | 389 | */ |
396 | char * | 390 | char * |
397 | GNUNET_ESCROW_anchor_data_to_string (struct GNUNET_ESCROW_Handle *h, | 391 | GNUNET_ESCROW_anchor_data_to_string ( |
398 | struct GNUNET_ESCROW_Anchor *escrowAnchor, | 392 | const struct GNUNET_ESCROW_Anchor *escrowAnchor); |
399 | enum GNUNET_ESCROW_Key_Escrow_Method method); | 393 | |
394 | |||
395 | /** | ||
396 | * Convert a method name string to the respective enum number | ||
397 | * | ||
398 | * @param methodString the method name string | ||
399 | * | ||
400 | * @return the enum number | ||
401 | */ | ||
402 | enum GNUNET_ESCROW_Key_Escrow_Method | ||
403 | GNUNET_ESCROW_method_string_to_number (const char *methodString); | ||
404 | |||
405 | |||
406 | /** | ||
407 | * Convert a method enum number to the respective method string | ||
408 | * | ||
409 | * @param method the method enum number | ||
410 | * | ||
411 | * @return the method string | ||
412 | */ | ||
413 | const char * | ||
414 | GNUNET_ESCROW_method_number_to_string (enum GNUNET_ESCROW_Key_Escrow_Method method); | ||
400 | 415 | ||
401 | 416 | ||
402 | /** | 417 | /** |
diff --git a/src/include/gnunet_escrow_plugin.h b/src/include/gnunet_escrow_plugin.h index b8b88ff3f..dbdf6dce6 100644 --- a/src/include/gnunet_escrow_plugin.h +++ b/src/include/gnunet_escrow_plugin.h | |||
@@ -114,34 +114,6 @@ typedef struct GNUNET_ESCROW_Status *(*GNUNET_ESCROW_GetEscrowStatusFunction) ( | |||
114 | 114 | ||
115 | 115 | ||
116 | /** | 116 | /** |
117 | * Function called to deserialize an escrow anchor string into a | ||
118 | * GNUNET_ESCROW_Anchor struct | ||
119 | * | ||
120 | * @param h the handle for the escrow component | ||
121 | * @param anchorString the encoded escrow anchor string | ||
122 | * | ||
123 | * @return the deserialized data packed into a GNUNET_ESCROW_Anchor struct, | ||
124 | * NULL if we failed to parse the string | ||
125 | */ | ||
126 | typedef struct GNUNET_ESCROW_Anchor *(*GNUNET_ESCROW_AnchorStringToDataFunction) ( | ||
127 | struct GNUNET_ESCROW_Handle *h, | ||
128 | char *anchorString); | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Function called to serialize an escrow anchor struct into a string | ||
133 | * | ||
134 | * @param h the handle for the escrow component | ||
135 | * @param escrowAnchor the escrow anchor struct | ||
136 | * | ||
137 | * @return the encoded escrow anchor string | ||
138 | */ | ||
139 | typedef char *(*GNUNET_ESCROW_AnchorDataToStringFunction) ( | ||
140 | struct GNUNET_ESCROW_Handle *h, | ||
141 | struct GNUNET_ESCROW_Anchor *escrowAnchor); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Function called to cancel a plugin operation | 117 | * Function called to cancel a plugin operation |
146 | * | 118 | * |
147 | * @param plugin_op_wrap plugin operation wrapper containing the plugin operation | 119 | * @param plugin_op_wrap plugin operation wrapper containing the plugin operation |
@@ -182,16 +154,6 @@ struct GNUNET_ESCROW_KeyPluginFunctions | |||
182 | GNUNET_ESCROW_GetEscrowStatusFunction get_status; | 154 | GNUNET_ESCROW_GetEscrowStatusFunction get_status; |
183 | 155 | ||
184 | /** | 156 | /** |
185 | * Deserialize anchor string to data | ||
186 | */ | ||
187 | GNUNET_ESCROW_AnchorStringToDataFunction anchor_string_to_data; | ||
188 | |||
189 | /** | ||
190 | * Serialize anchor data to string | ||
191 | */ | ||
192 | GNUNET_ESCROW_AnchorDataToStringFunction anchor_data_to_string; | ||
193 | |||
194 | /** | ||
195 | * Cancel plugin operation | 157 | * Cancel plugin operation |
196 | */ | 158 | */ |
197 | GNUNET_ESCROW_CancelPluginOperationFunction cancel_plugin_operation; | 159 | GNUNET_ESCROW_CancelPluginOperationFunction cancel_plugin_operation; |