diff options
-rw-r--r-- | src/escrow/escrow_plugin_helper.c | 35 | ||||
-rw-r--r-- | src/escrow/escrow_plugin_helper.h | 18 | ||||
-rw-r--r-- | src/escrow/gnunet-escrow.c | 13 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_gns.c | 139 | ||||
-rw-r--r-- | src/escrow/plugin_escrow_plaintext.c | 196 | ||||
-rw-r--r-- | src/include/gnunet_escrow_plugin.h | 1 |
6 files changed, 326 insertions, 76 deletions
diff --git a/src/escrow/escrow_plugin_helper.c b/src/escrow/escrow_plugin_helper.c index ca45b6837..7192123d9 100644 --- a/src/escrow/escrow_plugin_helper.c +++ b/src/escrow/escrow_plugin_helper.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_identity_service.h" | 30 | #include "gnunet_identity_service.h" |
31 | #include "gnunet_escrow_plugin.h" | 31 | #include "gnunet_escrow_plugin.h" |
32 | #include "escrow.h" | ||
32 | 33 | ||
33 | 34 | ||
34 | /** | 35 | /** |
@@ -180,6 +181,40 @@ ESCROW_cleanup_ego_list (struct ESCROW_PluginHandle *ph) | |||
180 | } | 181 | } |
181 | 182 | ||
182 | 183 | ||
184 | /** | ||
185 | * Build an anchor struct. | ||
186 | * | ||
187 | * @param method escrow method | ||
188 | * @param egoName name of the ego | ||
189 | * @param data anchor data | ||
190 | * @param data_size size of the anchor data | ||
191 | * | ||
192 | * @return a new anchor struct | ||
193 | */ | ||
194 | struct GNUNET_ESCROW_Anchor * | ||
195 | ESCROW_build_anchor (enum GNUNET_ESCROW_Key_Escrow_Method method, | ||
196 | const char *egoName, | ||
197 | void *data, | ||
198 | uint32_t data_size) | ||
199 | { | ||
200 | struct GNUNET_ESCROW_Anchor *anchor; | ||
201 | char *ptr; | ||
202 | |||
203 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) | ||
204 | + data_size | ||
205 | + strlen (egoName) + 1); | ||
206 | anchor->method = method; | ||
207 | anchor->size = data_size; | ||
208 | ptr = (char *)&anchor[1]; | ||
209 | GNUNET_memcpy (ptr, data, data_size); | ||
210 | ptr += data_size; | ||
211 | anchor->egoName = ptr; | ||
212 | strcpy (ptr, egoName); | ||
213 | |||
214 | return anchor; | ||
215 | } | ||
216 | |||
217 | |||
183 | static char * | 218 | static char * |
184 | string_to_upper (const char *str) | 219 | string_to_upper (const char *str) |
185 | { | 220 | { |
diff --git a/src/escrow/escrow_plugin_helper.h b/src/escrow/escrow_plugin_helper.h index b7764edd5..d911800e6 100644 --- a/src/escrow/escrow_plugin_helper.h +++ b/src/escrow/escrow_plugin_helper.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_identity_service.h" | 30 | #include "gnunet_identity_service.h" |
31 | #include "gnunet_escrow_plugin.h" | 31 | #include "gnunet_escrow_plugin.h" |
32 | #include "escrow.h" | ||
32 | 33 | ||
33 | 34 | ||
34 | /** | 35 | /** |
@@ -82,6 +83,23 @@ ESCROW_cleanup_ego_list (struct ESCROW_PluginHandle *ph); | |||
82 | 83 | ||
83 | 84 | ||
84 | /** | 85 | /** |
86 | * Build an anchor struct. | ||
87 | * | ||
88 | * @param method escrow method | ||
89 | * @param egoName name of the ego | ||
90 | * @param data anchor data | ||
91 | * @param data_size size of the anchor data | ||
92 | * | ||
93 | * @return a new anchor struct | ||
94 | */ | ||
95 | struct GNUNET_ESCROW_Anchor * | ||
96 | ESCROW_build_anchor (enum GNUNET_ESCROW_Key_Escrow_Method method, | ||
97 | const char *egoName, | ||
98 | void *data, | ||
99 | uint32_t data_size); | ||
100 | |||
101 | |||
102 | /** | ||
85 | * Update the status of an escrow in the configuration after a VERIFY operation. | 103 | * Update the status of an escrow in the configuration after a VERIFY operation. |
86 | * | 104 | * |
87 | * @param h handle for the escrow component | 105 | * @param h handle for the escrow component |
diff --git a/src/escrow/gnunet-escrow.c b/src/escrow/gnunet-escrow.c index c3ca3aa9e..ad34dd8f3 100644 --- a/src/escrow/gnunet-escrow.c +++ b/src/escrow/gnunet-escrow.c | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_escrow_lib.h" | 30 | #include "gnunet_escrow_lib.h" |
31 | #include "../identity/identity.h" | ||
32 | 31 | ||
33 | /** | 32 | /** |
34 | * return value | 33 | * return value |
@@ -211,6 +210,9 @@ verify_cb (void *cls, | |||
211 | { | 210 | { |
212 | escrow_op = NULL; | 211 | escrow_op = NULL; |
213 | 212 | ||
213 | if (NULL != emsg) | ||
214 | fprintf (stderr, "%s", emsg); | ||
215 | |||
214 | switch (verificationResult) | 216 | switch (verificationResult) |
215 | { | 217 | { |
216 | case GNUNET_ESCROW_VALID: | 218 | case GNUNET_ESCROW_VALID: |
@@ -226,8 +228,7 @@ verify_cb (void *cls, | |||
226 | break; | 228 | break; |
227 | default: | 229 | default: |
228 | ret = 1; | 230 | ret = 1; |
229 | if (NULL != emsg) | 231 | fprintf (stderr, "invalid verificationResult"); |
230 | fprintf (stderr, "invalid verificationResult: %s", emsg); | ||
231 | } | 232 | } |
232 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 233 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
233 | } | 234 | } |
@@ -247,7 +248,7 @@ get_cb (void *cls, | |||
247 | fprintf (stderr, "Escrow failed: %s", emsg); | 248 | fprintf (stderr, "Escrow failed: %s", emsg); |
248 | } | 249 | } |
249 | else | 250 | else |
250 | fprintf (stdout, "Identity %s could successfully be restored!\n", ego->name); | 251 | fprintf (stdout, "Identity %s could successfully be restored!\n", anchor->egoName); |
251 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 252 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
252 | } | 253 | } |
253 | 254 | ||
@@ -315,10 +316,10 @@ start_process () | |||
315 | method); | 316 | method); |
316 | 317 | ||
317 | if (GNUNET_ESCROW_KEY_NONE == escrow_status->last_method) | 318 | if (GNUNET_ESCROW_KEY_NONE == escrow_status->last_method) |
318 | fprintf (stdout, "No escrow has been performed for identity %s!\n", ego->name); | 319 | fprintf (stdout, "No escrow has been performed for identity %s!\n", status_ego); |
319 | else | 320 | else |
320 | { | 321 | { |
321 | fprintf (stdout, "Escrow STATUS information for identity %s\n", ego->name); | 322 | fprintf (stdout, "Escrow STATUS information for identity %s\n", status_ego); |
322 | fprintf (stdout, "=======================================================\n"); | 323 | fprintf (stdout, "=======================================================\n"); |
323 | if (0 == escrow_status->last_successful_verification_time.abs_value_us) | 324 | if (0 == escrow_status->last_successful_verification_time.abs_value_us) |
324 | fprintf (stdout, "No successful verification! Please VERIFY now.\n"); | 325 | fprintf (stdout, "No successful verification! Please VERIFY now.\n"); |
diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c index 908c7bb44..6889d1dd0 100644 --- a/src/escrow/plugin_escrow_gns.c +++ b/src/escrow/plugin_escrow_gns.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "gnunet_namestore_service.h" | 32 | #include "gnunet_namestore_service.h" |
33 | #include "gnunet_gns_service.h" | 33 | #include "gnunet_gns_service.h" |
34 | #include "gnunet_gnsrecord_lib.h" | 34 | #include "gnunet_gnsrecord_lib.h" |
35 | #include "../identity/identity.h" | 35 | #include "escrow.h" |
36 | #include <sss.h> | 36 | #include <sss.h> |
37 | #include <inttypes.h> | 37 | #include <inttypes.h> |
38 | 38 | ||
@@ -287,6 +287,11 @@ struct ESCROW_GnsPluginOperation | |||
287 | struct GNUNET_IDENTITY_Ego *ego; | 287 | struct GNUNET_IDENTITY_Ego *ego; |
288 | 288 | ||
289 | /** | 289 | /** |
290 | * The anchor | ||
291 | */ | ||
292 | const struct GNUNET_ESCROW_Anchor *anchor; | ||
293 | |||
294 | /** | ||
290 | * The name of the ego | 295 | * The name of the ego |
291 | */ | 296 | */ |
292 | char *egoName; | 297 | char *egoName; |
@@ -526,21 +531,15 @@ keyshare_distribution_finished (void *cls) | |||
526 | { | 531 | { |
527 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls; | 532 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls; |
528 | struct ESCROW_GnsPluginOperation *p_op; | 533 | struct ESCROW_GnsPluginOperation *p_op; |
529 | struct GNUNET_ESCROW_Anchor *anchor; | ||
530 | int anchorDataSize; | ||
531 | 534 | ||
532 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All keyshares distributed\n"); | 535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All keyshares distributed\n"); |
533 | 536 | ||
534 | p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op; | 537 | p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op; |
535 | 538 | ||
536 | anchorDataSize = strlen(p_op->userSecret) + 1; | 539 | p_op->anchor_wrap->anchor = ESCROW_build_anchor (GNUNET_ESCROW_KEY_GNS, |
537 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize); | 540 | p_op->egoName, |
538 | anchor->method = GNUNET_ESCROW_KEY_GNS; | 541 | p_op->userSecret, |
539 | anchor->egoName = GNUNET_strdup (p_op->ego->name); | 542 | strlen (p_op->userSecret)); |
540 | anchor->size = anchorDataSize; | ||
541 | GNUNET_memcpy (&anchor[1], p_op->userSecret, anchorDataSize); | ||
542 | |||
543 | p_op->anchor_wrap->anchor = anchor; | ||
544 | 543 | ||
545 | /* update escrow status, i.e. set the last escrow method */ | 544 | /* update escrow status, i.e. set the last escrow method */ |
546 | ESCROW_update_escrow_status_put (p_op->h, p_op->ego, "gns"); | 545 | ESCROW_update_escrow_status_put (p_op->h, p_op->ego, "gns"); |
@@ -803,7 +802,7 @@ escrow_id_exists (const char *name, | |||
803 | { | 802 | { |
804 | if (0 == strcmp (name, curr->identifier)) | 803 | if (0 == strcmp (name, curr->identifier)) |
805 | { | 804 | { |
806 | if (0 == memcmp (&curr->ego->pk, | 805 | if (0 == memcmp (GNUNET_IDENTITY_ego_get_private_key (curr->ego), |
807 | pk, | 806 | pk, |
808 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 807 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) |
809 | return GNUNET_YES; | 808 | return GNUNET_YES; |
@@ -1034,6 +1033,9 @@ continue_start (void *cls) | |||
1034 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls; | 1033 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls; |
1035 | struct ESCROW_GnsPluginOperation *p_op; | 1034 | struct ESCROW_GnsPluginOperation *p_op; |
1036 | struct GNUNET_TIME_Relative delay; | 1035 | struct GNUNET_TIME_Relative delay; |
1036 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub; | ||
1037 | struct EgoEntry *ego_entry; | ||
1038 | char *pub_keystring; | ||
1037 | 1039 | ||
1038 | p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op; | 1040 | p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op; |
1039 | 1041 | ||
@@ -1044,12 +1046,34 @@ continue_start (void *cls) | |||
1044 | return; | 1046 | return; |
1045 | } | 1047 | } |
1046 | 1048 | ||
1049 | GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub); | ||
1050 | pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub); | ||
1051 | for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | ||
1052 | if (0 == strcmp (pub_keystring, ego_entry->keystring)) | ||
1053 | break; | ||
1054 | |||
1055 | GNUNET_free (pub_keystring); | ||
1056 | if (NULL == ego_entry) | ||
1057 | { | ||
1058 | p_op->anchor_wrap->anchor = NULL; | ||
1059 | p_op->anchor_wrap->emsg = _ ("Identity was not found in plugin!\n"); | ||
1060 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); | ||
1061 | return; | ||
1062 | } | ||
1063 | |||
1064 | p_op->egoName = GNUNET_strdup (ego_entry->identifier); | ||
1065 | |||
1047 | /* load config */ | 1066 | /* load config */ |
1048 | if (GNUNET_OK != load_keyshare_config (plugin_op_wrap)) | 1067 | if (GNUNET_OK != load_keyshare_config (plugin_op_wrap)) |
1068 | { | ||
1069 | p_op->anchor_wrap->anchor = NULL; | ||
1070 | p_op->anchor_wrap->emsg = _ ("Failed to load keyshare configuration parameters!\n"); | ||
1071 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); | ||
1049 | return; | 1072 | return; |
1073 | } | ||
1050 | 1074 | ||
1051 | /* create the escrow identities */ | 1075 | /* create the escrow identities */ |
1052 | create_escrow_identities (plugin_op_wrap, p_op->ego->name); | 1076 | create_escrow_identities (plugin_op_wrap, p_op->egoName); |
1053 | 1077 | ||
1054 | /* operation continues in escrow_ids_finished | 1078 | /* operation continues in escrow_ids_finished |
1055 | after all escrow identities are created */ | 1079 | after all escrow identities are created */ |
@@ -1431,6 +1455,66 @@ verify_restored_pk (void *cls, | |||
1431 | } | 1455 | } |
1432 | 1456 | ||
1433 | 1457 | ||
1458 | static void | ||
1459 | continue_verify (void *cls) | ||
1460 | { | ||
1461 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls; | ||
1462 | struct ESCROW_GnsPluginOperation *p_op; | ||
1463 | struct GNUNET_TIME_Relative delay; | ||
1464 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub; | ||
1465 | struct EgoEntry *ego_entry; | ||
1466 | char *pub_keystring; | ||
1467 | |||
1468 | p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op; | ||
1469 | |||
1470 | if (ESCROW_PLUGIN_STATE_POST_INIT != ph.state) | ||
1471 | { | ||
1472 | delay.rel_value_us = 100 * GNUNET_TIME_relative_get_millisecond_().rel_value_us; | ||
1473 | GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap); | ||
1474 | return; | ||
1475 | } | ||
1476 | |||
1477 | GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub); | ||
1478 | pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub); | ||
1479 | for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | ||
1480 | if (0 == strcmp (pub_keystring, ego_entry->keystring)) | ||
1481 | break; | ||
1482 | |||
1483 | GNUNET_free (pub_keystring); | ||
1484 | if (NULL == ego_entry) | ||
1485 | { | ||
1486 | p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID; | ||
1487 | p_op->verify_wrap->emsg = _ ("Identity was not found in plugin!\n"); | ||
1488 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | ||
1489 | return; | ||
1490 | } | ||
1491 | |||
1492 | p_op->egoName = GNUNET_strdup (ego_entry->identifier); | ||
1493 | |||
1494 | if (0 != strcmp (p_op->egoName, p_op->anchor->egoName)) | ||
1495 | { | ||
1496 | p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID; | ||
1497 | p_op->verify_wrap->emsg = _ ("This anchor was not created when putting that ego in escrow!\n"); | ||
1498 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | ||
1499 | return; | ||
1500 | } | ||
1501 | |||
1502 | /* load config */ | ||
1503 | if (GNUNET_OK != load_keyshare_config (plugin_op_wrap)) | ||
1504 | { | ||
1505 | p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID; | ||
1506 | p_op->verify_wrap->emsg = _ ("Failed to load keyshare configuration parameters!\n"); | ||
1507 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | ||
1508 | return; | ||
1509 | } | ||
1510 | |||
1511 | restore_private_key (plugin_op_wrap, | ||
1512 | p_op->anchor, | ||
1513 | &verify_restored_pk, | ||
1514 | plugin_op_wrap); | ||
1515 | } | ||
1516 | |||
1517 | |||
1434 | /** | 1518 | /** |
1435 | * Verify the GNS escrow of the key | 1519 | * Verify the GNS escrow of the key |
1436 | * | 1520 | * |
@@ -1452,6 +1536,7 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
1452 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap; | 1536 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap; |
1453 | struct ESCROW_GnsPluginOperation *p_op; | 1537 | struct ESCROW_GnsPluginOperation *p_op; |
1454 | struct ESCROW_Plugin_VerifyContinuationWrapper *w; | 1538 | struct ESCROW_Plugin_VerifyContinuationWrapper *w; |
1539 | struct GNUNET_TIME_Relative delay; | ||
1455 | 1540 | ||
1456 | // create a new GNS plugin operation (in a wrapper) and insert it into the DLL | 1541 | // create a new GNS plugin operation (in a wrapper) and insert it into the DLL |
1457 | plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper); | 1542 | plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper); |
@@ -1464,7 +1549,7 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
1464 | p_op->h = h; | 1549 | p_op->h = h; |
1465 | p_op->cont = cb; | 1550 | p_op->cont = cb; |
1466 | p_op->ego = ego; | 1551 | p_op->ego = ego; |
1467 | p_op->egoName = GNUNET_strdup (ego->name); | 1552 | p_op->anchor = anchor; |
1468 | 1553 | ||
1469 | w = GNUNET_new (struct ESCROW_Plugin_VerifyContinuationWrapper); | 1554 | w = GNUNET_new (struct ESCROW_Plugin_VerifyContinuationWrapper); |
1470 | w->h = h; | 1555 | w->h = h; |
@@ -1485,22 +1570,16 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
1485 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | 1570 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); |
1486 | return plugin_op_wrap; | 1571 | return plugin_op_wrap; |
1487 | } | 1572 | } |
1488 | if (0 != strcmp (ego->name, anchor->egoName)) | 1573 | |
1574 | if (ESCROW_PLUGIN_STATE_POST_INIT == ph.state) | ||
1489 | { | 1575 | { |
1490 | w->verificationResult = GNUNET_ESCROW_INVALID; | 1576 | continue_verify (plugin_op_wrap); |
1491 | w->emsg = _ ("This anchor was not created when putting that ego in escrow!\n"); | 1577 | } |
1492 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | 1578 | else |
1493 | return plugin_op_wrap; | 1579 | { |
1580 | delay.rel_value_us = 200 * GNUNET_TIME_relative_get_millisecond_().rel_value_us; | ||
1581 | GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap); | ||
1494 | } | 1582 | } |
1495 | |||
1496 | /* load config */ | ||
1497 | if (GNUNET_OK != load_keyshare_config (plugin_op_wrap)) | ||
1498 | return plugin_op_wrap; | ||
1499 | |||
1500 | restore_private_key (plugin_op_wrap, | ||
1501 | anchor, | ||
1502 | &verify_restored_pk, | ||
1503 | plugin_op_wrap); | ||
1504 | 1583 | ||
1505 | return plugin_op_wrap; | 1584 | return plugin_op_wrap; |
1506 | } | 1585 | } |
@@ -1513,7 +1592,8 @@ ego_created (struct GNUNET_IDENTITY_Ego *ego) | |||
1513 | struct ESCROW_GnsPluginOperation *curr_p_op; | 1592 | struct ESCROW_GnsPluginOperation *curr_p_op; |
1514 | char *ego_pk_string, *curr_pk_string; | 1593 | char *ego_pk_string, *curr_pk_string; |
1515 | 1594 | ||
1516 | ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string (&ego->pk); | 1595 | ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string ( |
1596 | GNUNET_IDENTITY_ego_get_private_key (ego)); | ||
1517 | 1597 | ||
1518 | for (curr = ph.plugin_op_head; NULL != curr; curr = curr->next) | 1598 | for (curr = ph.plugin_op_head; NULL != curr; curr = curr->next) |
1519 | { | 1599 | { |
@@ -1626,6 +1706,7 @@ restore_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
1626 | // set cont here (has to be scheduled from the IDENTITY service when it finished) | 1706 | // set cont here (has to be scheduled from the IDENTITY service when it finished) |
1627 | p_op->cont = cb; | 1707 | p_op->cont = cb; |
1628 | p_op->egoName = GNUNET_strdup (anchor->egoName); | 1708 | p_op->egoName = GNUNET_strdup (anchor->egoName); |
1709 | p_op->anchor = anchor; | ||
1629 | 1710 | ||
1630 | w = GNUNET_new (struct ESCROW_Plugin_EgoContinuationWrapper); | 1711 | w = GNUNET_new (struct ESCROW_Plugin_EgoContinuationWrapper); |
1631 | w->h = h; | 1712 | w->h = h; |
diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c index 39f605262..86f49955f 100644 --- a/src/escrow/plugin_escrow_plaintext.c +++ b/src/escrow/plugin_escrow_plaintext.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "gnunet_escrow_plugin.h" | 29 | #include "gnunet_escrow_plugin.h" |
30 | #include "escrow_plugin_helper.h" | 30 | #include "escrow_plugin_helper.h" |
31 | #include "gnunet_identity_service.h" | 31 | #include "gnunet_identity_service.h" |
32 | #include "../identity/identity.h" | ||
33 | #include "escrow.h" | 32 | #include "escrow.h" |
34 | #include <inttypes.h> | 33 | #include <inttypes.h> |
35 | 34 | ||
@@ -57,6 +56,21 @@ struct ESCROW_PlaintextPluginOperation | |||
57 | struct GNUNET_CRYPTO_EcdsaPrivateKey pk; | 56 | struct GNUNET_CRYPTO_EcdsaPrivateKey pk; |
58 | 57 | ||
59 | /** | 58 | /** |
59 | * The ego | ||
60 | */ | ||
61 | struct GNUNET_IDENTITY_Ego *ego; | ||
62 | |||
63 | /** | ||
64 | * The anchor | ||
65 | */ | ||
66 | const struct GNUNET_ESCROW_Anchor *anchor; | ||
67 | |||
68 | /** | ||
69 | * Name of the ego | ||
70 | */ | ||
71 | char *egoName; | ||
72 | |||
73 | /** | ||
60 | * Continuation for a plugin operation (e.g. used for restore, as this | 74 | * Continuation for a plugin operation (e.g. used for restore, as this |
61 | * callback has to be called from the IDENTITY service after finishing) | 75 | * callback has to be called from the IDENTITY service after finishing) |
62 | */ | 76 | */ |
@@ -109,6 +123,8 @@ cleanup_plugin_operation (struct ESCROW_PluginOperationWrapper *plugin_op_wrap) | |||
109 | GNUNET_free (p_op->ego_wrap); | 123 | GNUNET_free (p_op->ego_wrap); |
110 | if (NULL != p_op->verify_wrap) | 124 | if (NULL != p_op->verify_wrap) |
111 | GNUNET_free (p_op->verify_wrap); | 125 | GNUNET_free (p_op->verify_wrap); |
126 | if (NULL != p_op->egoName) | ||
127 | GNUNET_free (p_op->egoName); | ||
112 | GNUNET_free (p_op); | 128 | GNUNET_free (p_op); |
113 | GNUNET_free (plugin_op_wrap); | 129 | GNUNET_free (plugin_op_wrap); |
114 | } | 130 | } |
@@ -128,6 +144,59 @@ start_cont (void *cls) | |||
128 | } | 144 | } |
129 | 145 | ||
130 | 146 | ||
147 | static void | ||
148 | continue_start (void *cls) | ||
149 | { | ||
150 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls; | ||
151 | struct ESCROW_PlaintextPluginOperation *p_op; | ||
152 | struct GNUNET_TIME_Relative delay; | ||
153 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub; | ||
154 | struct EgoEntry *ego_entry; | ||
155 | char *pub_keystring; | ||
156 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | ||
157 | char *pkString; | ||
158 | |||
159 | p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op; | ||
160 | |||
161 | if (ESCROW_PLUGIN_STATE_POST_INIT != ph.state) | ||
162 | { | ||
163 | delay.rel_value_us = 100 * GNUNET_TIME_relative_get_millisecond_().rel_value_us; | ||
164 | GNUNET_SCHEDULER_add_delayed (delay, &continue_start, plugin_op_wrap); | ||
165 | return; | ||
166 | } | ||
167 | |||
168 | GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub); | ||
169 | pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub); | ||
170 | for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | ||
171 | if (0 == strcmp (pub_keystring, ego_entry->keystring)) | ||
172 | break; | ||
173 | |||
174 | GNUNET_free (pub_keystring); | ||
175 | if (NULL == ego_entry) | ||
176 | { | ||
177 | p_op->anchor_wrap->anchor = NULL; | ||
178 | p_op->anchor_wrap->emsg = _ ("Identity was not found in plugin!\n"); | ||
179 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | p_op->egoName = GNUNET_strdup (ego_entry->identifier); | ||
184 | |||
185 | pk = GNUNET_IDENTITY_ego_get_private_key (p_op->ego); | ||
186 | pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk); | ||
187 | |||
188 | p_op->anchor_wrap->anchor = ESCROW_build_anchor (GNUNET_ESCROW_KEY_PLAINTEXT, | ||
189 | p_op->egoName, | ||
190 | pkString, | ||
191 | strlen (pkString)); | ||
192 | |||
193 | /* update escrow status, i.e. set the last escrow method */ | ||
194 | ESCROW_update_escrow_status_put (p_op->h, p_op->ego, "plaintext"); | ||
195 | |||
196 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); | ||
197 | } | ||
198 | |||
199 | |||
131 | /** | 200 | /** |
132 | * Start the plaintext escrow of the key, i.e. simply hand out the key | 201 | * Start the plaintext escrow of the key, i.e. simply hand out the key |
133 | * | 202 | * |
@@ -146,13 +215,10 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
146 | ESCROW_Plugin_Continuation cb, | 215 | ESCROW_Plugin_Continuation cb, |
147 | uint32_t op_id) | 216 | uint32_t op_id) |
148 | { | 217 | { |
149 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | ||
150 | struct GNUNET_ESCROW_Anchor *anchor; | ||
151 | char *pkString; | ||
152 | uint32_t anchorDataSize; | ||
153 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap; | 218 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap; |
154 | struct ESCROW_PlaintextPluginOperation *p_op; | 219 | struct ESCROW_PlaintextPluginOperation *p_op; |
155 | struct ESCROW_Plugin_AnchorContinuationWrapper *w; | 220 | struct ESCROW_Plugin_AnchorContinuationWrapper *w; |
221 | struct GNUNET_TIME_Relative delay; | ||
156 | 222 | ||
157 | // create a new plaintext plugin operation (in a wrapper) and insert it into the DLL | 223 | // create a new plaintext plugin operation (in a wrapper) and insert it into the DLL |
158 | plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper); | 224 | plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper); |
@@ -164,6 +230,7 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
164 | p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op; | 230 | p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op; |
165 | p_op->h = h; | 231 | p_op->h = h; |
166 | p_op->cont = cb; | 232 | p_op->cont = cb; |
233 | p_op->ego = ego; | ||
167 | 234 | ||
168 | w = GNUNET_new (struct ESCROW_Plugin_AnchorContinuationWrapper); | 235 | w = GNUNET_new (struct ESCROW_Plugin_AnchorContinuationWrapper); |
169 | w->h = h; | 236 | w->h = h; |
@@ -177,22 +244,17 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
177 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); | 244 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); |
178 | return plugin_op_wrap; | 245 | return plugin_op_wrap; |
179 | } | 246 | } |
180 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); | ||
181 | pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk); | ||
182 | |||
183 | anchorDataSize = strlen (pkString) + 1; | ||
184 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize); | ||
185 | anchor->method = GNUNET_ESCROW_KEY_PLAINTEXT; | ||
186 | anchor->egoName = GNUNET_strdup (ego->name); | ||
187 | anchor->size = anchorDataSize; | ||
188 | GNUNET_memcpy (&anchor[1], pkString, anchorDataSize); | ||
189 | 247 | ||
190 | w->anchor = anchor; | 248 | if (ESCROW_PLUGIN_STATE_POST_INIT == ph.state) |
191 | 249 | { | |
192 | /* update escrow status, i.e. set the last escrow method */ | 250 | continue_start (plugin_op_wrap); |
193 | ESCROW_update_escrow_status_put (h, ego, "plaintext"); | 251 | } |
252 | else | ||
253 | { | ||
254 | delay.rel_value_us = 200 * GNUNET_TIME_relative_get_millisecond_().rel_value_us; | ||
255 | GNUNET_SCHEDULER_add_delayed (delay, &continue_start, plugin_op_wrap); | ||
256 | } | ||
194 | 257 | ||
195 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); | ||
196 | return plugin_op_wrap; | 258 | return plugin_op_wrap; |
197 | } | 259 | } |
198 | 260 | ||
@@ -211,6 +273,68 @@ verify_cont (void *cls) | |||
211 | } | 273 | } |
212 | 274 | ||
213 | 275 | ||
276 | static void | ||
277 | continue_verify (void *cls) | ||
278 | { | ||
279 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls; | ||
280 | struct ESCROW_PlaintextPluginOperation *p_op; | ||
281 | struct GNUNET_TIME_Relative delay; | ||
282 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | ||
283 | char *pkString; | ||
284 | int verificationResult; | ||
285 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub; | ||
286 | struct EgoEntry *ego_entry; | ||
287 | char *pub_keystring; | ||
288 | |||
289 | p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op; | ||
290 | |||
291 | if (ESCROW_PLUGIN_STATE_POST_INIT != ph.state) | ||
292 | { | ||
293 | delay.rel_value_us = 100 * GNUNET_TIME_relative_get_millisecond_().rel_value_us; | ||
294 | GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap); | ||
295 | return; | ||
296 | } | ||
297 | |||
298 | GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub); | ||
299 | pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub); | ||
300 | for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | ||
301 | if (0 == strcmp (pub_keystring, ego_entry->keystring)) | ||
302 | break; | ||
303 | |||
304 | GNUNET_free (pub_keystring); | ||
305 | if (NULL == ego_entry) | ||
306 | { | ||
307 | p_op->anchor_wrap->anchor = NULL; | ||
308 | p_op->anchor_wrap->emsg = _ ("Identity was not found in plugin!\n"); | ||
309 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | p_op->egoName = GNUNET_strdup (ego_entry->identifier); | ||
314 | |||
315 | if (0 != strcmp (p_op->egoName, p_op->anchor->egoName)) | ||
316 | { | ||
317 | p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID; | ||
318 | p_op->verify_wrap->emsg = _ ("This anchor was not created when putting that ego in escrow!\n"); | ||
319 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | ||
320 | return; | ||
321 | } | ||
322 | pk = GNUNET_IDENTITY_ego_get_private_key (p_op->ego); | ||
323 | pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk); | ||
324 | verificationResult = strncmp (pkString, | ||
325 | (char *)&p_op->anchor[1], | ||
326 | p_op->anchor->size) == 0 ? | ||
327 | GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID; | ||
328 | |||
329 | /* update the escrow status if valid */ | ||
330 | if (GNUNET_ESCROW_VALID == verificationResult) | ||
331 | ESCROW_update_escrow_status_verify (p_op->h, p_op->ego, "plaintext"); | ||
332 | |||
333 | p_op->verify_wrap->verificationResult = verificationResult; | ||
334 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | ||
335 | } | ||
336 | |||
337 | |||
214 | /** | 338 | /** |
215 | * Verify the plaintext escrow of the key | 339 | * Verify the plaintext escrow of the key |
216 | * | 340 | * |
@@ -229,12 +353,10 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
229 | ESCROW_Plugin_Continuation cb, | 353 | ESCROW_Plugin_Continuation cb, |
230 | uint32_t op_id) | 354 | uint32_t op_id) |
231 | { | 355 | { |
232 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | ||
233 | char *pkString; | ||
234 | int verificationResult; | ||
235 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap; | 356 | struct ESCROW_PluginOperationWrapper *plugin_op_wrap; |
236 | struct ESCROW_PlaintextPluginOperation *p_op; | 357 | struct ESCROW_PlaintextPluginOperation *p_op; |
237 | struct ESCROW_Plugin_VerifyContinuationWrapper *w; | 358 | struct ESCROW_Plugin_VerifyContinuationWrapper *w; |
359 | struct GNUNET_TIME_Relative delay; | ||
238 | 360 | ||
239 | // create a new plaintext plugin operation (in a wrapper) and insert it into the DLL | 361 | // create a new plaintext plugin operation (in a wrapper) and insert it into the DLL |
240 | plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper); | 362 | plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper); |
@@ -246,6 +368,8 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
246 | p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op; | 368 | p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op; |
247 | p_op->h = h; | 369 | p_op->h = h; |
248 | p_op->cont = cb; | 370 | p_op->cont = cb; |
371 | p_op->ego = ego; | ||
372 | p_op->anchor = anchor; | ||
249 | 373 | ||
250 | w = GNUNET_new (struct ESCROW_Plugin_VerifyContinuationWrapper); | 374 | w = GNUNET_new (struct ESCROW_Plugin_VerifyContinuationWrapper); |
251 | w->h = h; | 375 | w->h = h; |
@@ -266,26 +390,17 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h, | |||
266 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | 390 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); |
267 | return plugin_op_wrap; | 391 | return plugin_op_wrap; |
268 | } | 392 | } |
269 | if (0 != strcmp (ego->name, anchor->egoName)) | 393 | |
394 | if (ESCROW_PLUGIN_STATE_POST_INIT == ph.state) | ||
270 | { | 395 | { |
271 | w->verificationResult = GNUNET_ESCROW_INVALID; | 396 | continue_verify (plugin_op_wrap); |
272 | w->emsg = _ ("This anchor was not created when putting that ego in escrow!\n"); | 397 | } |
273 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | 398 | else |
274 | return plugin_op_wrap; | 399 | { |
400 | delay.rel_value_us = 200 * GNUNET_TIME_relative_get_millisecond_().rel_value_us; | ||
401 | GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap); | ||
275 | } | 402 | } |
276 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); | ||
277 | pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk); | ||
278 | verificationResult = strncmp (pkString, | ||
279 | (char *)&anchor[1], | ||
280 | anchor->size) == 0 ? | ||
281 | GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID; | ||
282 | |||
283 | /* update the escrow status if valid */ | ||
284 | if (GNUNET_ESCROW_VALID == verificationResult) | ||
285 | ESCROW_update_escrow_status_verify (h, ego, "plaintext"); | ||
286 | 403 | ||
287 | w->verificationResult = verificationResult; | ||
288 | p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap); | ||
289 | return plugin_op_wrap; | 404 | return plugin_op_wrap; |
290 | } | 405 | } |
291 | 406 | ||
@@ -297,7 +412,8 @@ ego_created (struct GNUNET_IDENTITY_Ego *ego) | |||
297 | struct ESCROW_PlaintextPluginOperation *curr_p_op; | 412 | struct ESCROW_PlaintextPluginOperation *curr_p_op; |
298 | char *ego_pk_string, *curr_pk_string; | 413 | char *ego_pk_string, *curr_pk_string; |
299 | 414 | ||
300 | ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string (&ego->pk); | 415 | ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string ( |
416 | GNUNET_IDENTITY_ego_get_private_key(ego)); | ||
301 | 417 | ||
302 | for (curr = ph.plugin_op_head; NULL != curr; curr = curr->next) | 418 | for (curr = ph.plugin_op_head; NULL != curr; curr = curr->next) |
303 | { | 419 | { |
diff --git a/src/include/gnunet_escrow_plugin.h b/src/include/gnunet_escrow_plugin.h index bc1ea6f52..ec0bbdcdb 100644 --- a/src/include/gnunet_escrow_plugin.h +++ b/src/include/gnunet_escrow_plugin.h | |||
@@ -33,7 +33,6 @@ | |||
33 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
34 | #include "gnunet_escrow_lib.h" | 34 | #include "gnunet_escrow_lib.h" |
35 | #include "gnunet_identity_service.h" | 35 | #include "gnunet_identity_service.h" |
36 | #include "../escrow/escrow.h" | ||
37 | #include "gnunet_scheduler_lib.h" | 36 | #include "gnunet_scheduler_lib.h" |
38 | 37 | ||
39 | #ifdef __cplusplus | 38 | #ifdef __cplusplus |