summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-09-07 17:18:10 +0200
committerjospaeth <spaethj@in.tum.de>2020-09-07 17:18:10 +0200
commitd391974aeba2f6778e701db32029404d286d3b4e (patch)
tree4416ae6322988977195d2ad15cb5b1c648f12394
parente12cdc513908ed0cf5acc73b7576a6ecbc9669ad (diff)
fix includes, don't depend on "../identity/identity.h"
-rw-r--r--src/escrow/escrow_plugin_helper.c35
-rw-r--r--src/escrow/escrow_plugin_helper.h18
-rw-r--r--src/escrow/gnunet-escrow.c13
-rw-r--r--src/escrow/plugin_escrow_gns.c139
-rw-r--r--src/escrow/plugin_escrow_plaintext.c196
-rw-r--r--src/include/gnunet_escrow_plugin.h1
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 @@
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_escrow_plugin.h"
+#include "escrow.h"
/**
@@ -180,6 +181,40 @@ ESCROW_cleanup_ego_list (struct ESCROW_PluginHandle *ph)
}
+/**
+ * Build an anchor struct.
+ *
+ * @param method escrow method
+ * @param egoName name of the ego
+ * @param data anchor data
+ * @param data_size size of the anchor data
+ *
+ * @return a new anchor struct
+ */
+struct GNUNET_ESCROW_Anchor *
+ESCROW_build_anchor (enum GNUNET_ESCROW_Key_Escrow_Method method,
+ const char *egoName,
+ void *data,
+ uint32_t data_size)
+{
+ struct GNUNET_ESCROW_Anchor *anchor;
+ char *ptr;
+
+ anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor)
+ + data_size
+ + strlen (egoName) + 1);
+ anchor->method = method;
+ anchor->size = data_size;
+ ptr = (char *)&anchor[1];
+ GNUNET_memcpy (ptr, data, data_size);
+ ptr += data_size;
+ anchor->egoName = ptr;
+ strcpy (ptr, egoName);
+
+ return anchor;
+}
+
+
static char *
string_to_upper (const char *str)
{
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 @@
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_escrow_plugin.h"
+#include "escrow.h"
/**
@@ -82,6 +83,23 @@ ESCROW_cleanup_ego_list (struct ESCROW_PluginHandle *ph);
/**
+ * Build an anchor struct.
+ *
+ * @param method escrow method
+ * @param egoName name of the ego
+ * @param data anchor data
+ * @param data_size size of the anchor data
+ *
+ * @return a new anchor struct
+ */
+struct GNUNET_ESCROW_Anchor *
+ESCROW_build_anchor (enum GNUNET_ESCROW_Key_Escrow_Method method,
+ const char *egoName,
+ void *data,
+ uint32_t data_size);
+
+
+/**
* Update the status of an escrow in the configuration after a VERIFY operation.
*
* @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 @@
#include "gnunet_util_lib.h"
#include "gnunet_escrow_lib.h"
-#include "../identity/identity.h"
/**
* return value
@@ -211,6 +210,9 @@ verify_cb (void *cls,
{
escrow_op = NULL;
+ if (NULL != emsg)
+ fprintf (stderr, "%s", emsg);
+
switch (verificationResult)
{
case GNUNET_ESCROW_VALID:
@@ -226,8 +228,7 @@ verify_cb (void *cls,
break;
default:
ret = 1;
- if (NULL != emsg)
- fprintf (stderr, "invalid verificationResult: %s", emsg);
+ fprintf (stderr, "invalid verificationResult");
}
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
@@ -247,7 +248,7 @@ get_cb (void *cls,
fprintf (stderr, "Escrow failed: %s", emsg);
}
else
- fprintf (stdout, "Identity %s could successfully be restored!\n", ego->name);
+ fprintf (stdout, "Identity %s could successfully be restored!\n", anchor->egoName);
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
@@ -315,10 +316,10 @@ start_process ()
method);
if (GNUNET_ESCROW_KEY_NONE == escrow_status->last_method)
- fprintf (stdout, "No escrow has been performed for identity %s!\n", ego->name);
+ fprintf (stdout, "No escrow has been performed for identity %s!\n", status_ego);
else
{
- fprintf (stdout, "Escrow STATUS information for identity %s\n", ego->name);
+ fprintf (stdout, "Escrow STATUS information for identity %s\n", status_ego);
fprintf (stdout, "=======================================================\n");
if (0 == escrow_status->last_successful_verification_time.abs_value_us)
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 @@
#include "gnunet_namestore_service.h"
#include "gnunet_gns_service.h"
#include "gnunet_gnsrecord_lib.h"
-#include "../identity/identity.h"
+#include "escrow.h"
#include <sss.h>
#include <inttypes.h>
@@ -287,6 +287,11 @@ struct ESCROW_GnsPluginOperation
struct GNUNET_IDENTITY_Ego *ego;
/**
+ * The anchor
+ */
+ const struct GNUNET_ESCROW_Anchor *anchor;
+
+ /**
* The name of the ego
*/
char *egoName;
@@ -526,21 +531,15 @@ keyshare_distribution_finished (void *cls)
{
struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls;
struct ESCROW_GnsPluginOperation *p_op;
- struct GNUNET_ESCROW_Anchor *anchor;
- int anchorDataSize;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All keyshares distributed\n");
p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op;
- anchorDataSize = strlen(p_op->userSecret) + 1;
- anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize);
- anchor->method = GNUNET_ESCROW_KEY_GNS;
- anchor->egoName = GNUNET_strdup (p_op->ego->name);
- anchor->size = anchorDataSize;
- GNUNET_memcpy (&anchor[1], p_op->userSecret, anchorDataSize);
-
- p_op->anchor_wrap->anchor = anchor;
+ p_op->anchor_wrap->anchor = ESCROW_build_anchor (GNUNET_ESCROW_KEY_GNS,
+ p_op->egoName,
+ p_op->userSecret,
+ strlen (p_op->userSecret));
/* update escrow status, i.e. set the last escrow method */
ESCROW_update_escrow_status_put (p_op->h, p_op->ego, "gns");
@@ -803,7 +802,7 @@ escrow_id_exists (const char *name,
{
if (0 == strcmp (name, curr->identifier))
{
- if (0 == memcmp (&curr->ego->pk,
+ if (0 == memcmp (GNUNET_IDENTITY_ego_get_private_key (curr->ego),
pk,
sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
return GNUNET_YES;
@@ -1034,6 +1033,9 @@ continue_start (void *cls)
struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls;
struct ESCROW_GnsPluginOperation *p_op;
struct GNUNET_TIME_Relative delay;
+ struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub;
+ struct EgoEntry *ego_entry;
+ char *pub_keystring;
p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op;
@@ -1044,12 +1046,34 @@ continue_start (void *cls)
return;
}
+ GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub);
+ pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub);
+ for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
+ if (0 == strcmp (pub_keystring, ego_entry->keystring))
+ break;
+
+ GNUNET_free (pub_keystring);
+ if (NULL == ego_entry)
+ {
+ p_op->anchor_wrap->anchor = NULL;
+ p_op->anchor_wrap->emsg = _ ("Identity was not found in plugin!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap);
+ return;
+ }
+
+ p_op->egoName = GNUNET_strdup (ego_entry->identifier);
+
/* load config */
if (GNUNET_OK != load_keyshare_config (plugin_op_wrap))
+ {
+ p_op->anchor_wrap->anchor = NULL;
+ p_op->anchor_wrap->emsg = _ ("Failed to load keyshare configuration parameters!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap);
return;
+ }
/* create the escrow identities */
- create_escrow_identities (plugin_op_wrap, p_op->ego->name);
+ create_escrow_identities (plugin_op_wrap, p_op->egoName);
/* operation continues in escrow_ids_finished
after all escrow identities are created */
@@ -1431,6 +1455,66 @@ verify_restored_pk (void *cls,
}
+static void
+continue_verify (void *cls)
+{
+ struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls;
+ struct ESCROW_GnsPluginOperation *p_op;
+ struct GNUNET_TIME_Relative delay;
+ struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub;
+ struct EgoEntry *ego_entry;
+ char *pub_keystring;
+
+ p_op = (struct ESCROW_GnsPluginOperation *)plugin_op_wrap->plugin_op;
+
+ if (ESCROW_PLUGIN_STATE_POST_INIT != ph.state)
+ {
+ delay.rel_value_us = 100 * GNUNET_TIME_relative_get_millisecond_().rel_value_us;
+ GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap);
+ return;
+ }
+
+ GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub);
+ pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub);
+ for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
+ if (0 == strcmp (pub_keystring, ego_entry->keystring))
+ break;
+
+ GNUNET_free (pub_keystring);
+ if (NULL == ego_entry)
+ {
+ p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID;
+ p_op->verify_wrap->emsg = _ ("Identity was not found in plugin!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
+ return;
+ }
+
+ p_op->egoName = GNUNET_strdup (ego_entry->identifier);
+
+ if (0 != strcmp (p_op->egoName, p_op->anchor->egoName))
+ {
+ p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID;
+ p_op->verify_wrap->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;
+ }
+
+ /* load config */
+ if (GNUNET_OK != load_keyshare_config (plugin_op_wrap))
+ {
+ p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID;
+ p_op->verify_wrap->emsg = _ ("Failed to load keyshare configuration parameters!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
+ return;
+ }
+
+ restore_private_key (plugin_op_wrap,
+ p_op->anchor,
+ &verify_restored_pk,
+ plugin_op_wrap);
+}
+
+
/**
* Verify the GNS escrow of the key
*
@@ -1452,6 +1536,7 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h,
struct ESCROW_PluginOperationWrapper *plugin_op_wrap;
struct ESCROW_GnsPluginOperation *p_op;
struct ESCROW_Plugin_VerifyContinuationWrapper *w;
+ struct GNUNET_TIME_Relative delay;
// create a new GNS plugin operation (in a wrapper) and insert it into the DLL
plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper);
@@ -1464,7 +1549,7 @@ verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h,
p_op->h = h;
p_op->cont = cb;
p_op->ego = ego;
- p_op->egoName = GNUNET_strdup (ego->name);
+ p_op->anchor = anchor;
w = GNUNET_new (struct ESCROW_Plugin_VerifyContinuationWrapper);
w->h = h;
@@ -1485,22 +1570,16 @@ 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 (0 != strcmp (ego->name, anchor->egoName))
+
+ if (ESCROW_PLUGIN_STATE_POST_INIT == ph.state)
{
- w->verificationResult = GNUNET_ESCROW_INVALID;
- 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;
+ continue_verify (plugin_op_wrap);
+ }
+ else
+ {
+ delay.rel_value_us = 200 * GNUNET_TIME_relative_get_millisecond_().rel_value_us;
+ GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap);
}
-
- /* load config */
- if (GNUNET_OK != load_keyshare_config (plugin_op_wrap))
- return plugin_op_wrap;
-
- restore_private_key (plugin_op_wrap,
- anchor,
- &verify_restored_pk,
- plugin_op_wrap);
return plugin_op_wrap;
}
@@ -1513,7 +1592,8 @@ ego_created (struct GNUNET_IDENTITY_Ego *ego)
struct ESCROW_GnsPluginOperation *curr_p_op;
char *ego_pk_string, *curr_pk_string;
- ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string (&ego->pk);
+ ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string (
+ GNUNET_IDENTITY_ego_get_private_key (ego));
for (curr = ph.plugin_op_head; NULL != curr; curr = curr->next)
{
@@ -1626,6 +1706,7 @@ restore_gns_key_escrow (struct GNUNET_ESCROW_Handle *h,
// set cont here (has to be scheduled from the IDENTITY service when it finished)
p_op->cont = cb;
p_op->egoName = GNUNET_strdup (anchor->egoName);
+ p_op->anchor = anchor;
w = GNUNET_new (struct ESCROW_Plugin_EgoContinuationWrapper);
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 @@
#include "gnunet_escrow_plugin.h"
#include "escrow_plugin_helper.h"
#include "gnunet_identity_service.h"
-#include "../identity/identity.h"
#include "escrow.h"
#include <inttypes.h>
@@ -57,6 +56,21 @@ struct ESCROW_PlaintextPluginOperation
struct GNUNET_CRYPTO_EcdsaPrivateKey pk;
/**
+ * The ego
+ */
+ struct GNUNET_IDENTITY_Ego *ego;
+
+ /**
+ * The anchor
+ */
+ const struct GNUNET_ESCROW_Anchor *anchor;
+
+ /**
+ * Name of the ego
+ */
+ char *egoName;
+
+ /**
* Continuation for a plugin operation (e.g. used for restore, as this
* callback has to be called from the IDENTITY service after finishing)
*/
@@ -109,6 +123,8 @@ cleanup_plugin_operation (struct ESCROW_PluginOperationWrapper *plugin_op_wrap)
GNUNET_free (p_op->ego_wrap);
if (NULL != p_op->verify_wrap)
GNUNET_free (p_op->verify_wrap);
+ if (NULL != p_op->egoName)
+ GNUNET_free (p_op->egoName);
GNUNET_free (p_op);
GNUNET_free (plugin_op_wrap);
}
@@ -128,6 +144,59 @@ start_cont (void *cls)
}
+static void
+continue_start (void *cls)
+{
+ struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls;
+ struct ESCROW_PlaintextPluginOperation *p_op;
+ struct GNUNET_TIME_Relative delay;
+ struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub;
+ struct EgoEntry *ego_entry;
+ char *pub_keystring;
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
+ char *pkString;
+
+ p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op;
+
+ if (ESCROW_PLUGIN_STATE_POST_INIT != ph.state)
+ {
+ delay.rel_value_us = 100 * GNUNET_TIME_relative_get_millisecond_().rel_value_us;
+ GNUNET_SCHEDULER_add_delayed (delay, &continue_start, plugin_op_wrap);
+ return;
+ }
+
+ GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub);
+ pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub);
+ for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
+ if (0 == strcmp (pub_keystring, ego_entry->keystring))
+ break;
+
+ GNUNET_free (pub_keystring);
+ if (NULL == ego_entry)
+ {
+ p_op->anchor_wrap->anchor = NULL;
+ p_op->anchor_wrap->emsg = _ ("Identity was not found in plugin!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap);
+ return;
+ }
+
+ p_op->egoName = GNUNET_strdup (ego_entry->identifier);
+
+ pk = GNUNET_IDENTITY_ego_get_private_key (p_op->ego);
+ pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk);
+
+ p_op->anchor_wrap->anchor = ESCROW_build_anchor (GNUNET_ESCROW_KEY_PLAINTEXT,
+ p_op->egoName,
+ pkString,
+ strlen (pkString));
+
+ /* update escrow status, i.e. set the last escrow method */
+ ESCROW_update_escrow_status_put (p_op->h, p_op->ego, "plaintext");
+
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap);
+}
+
+
/**
* Start the plaintext escrow of the key, i.e. simply hand out the key
*
@@ -146,13 +215,10 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
ESCROW_Plugin_Continuation cb,
uint32_t op_id)
{
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
- struct GNUNET_ESCROW_Anchor *anchor;
- char *pkString;
- uint32_t anchorDataSize;
struct ESCROW_PluginOperationWrapper *plugin_op_wrap;
struct ESCROW_PlaintextPluginOperation *p_op;
struct ESCROW_Plugin_AnchorContinuationWrapper *w;
+ struct GNUNET_TIME_Relative delay;
// create a new plaintext plugin operation (in a wrapper) and insert it into the DLL
plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper);
@@ -164,6 +230,7 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op;
p_op->h = h;
p_op->cont = cb;
+ p_op->ego = ego;
w = GNUNET_new (struct ESCROW_Plugin_AnchorContinuationWrapper);
w->h = h;
@@ -177,22 +244,17 @@ start_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap);
return plugin_op_wrap;
}
- pk = GNUNET_IDENTITY_ego_get_private_key (ego);
- pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk);
-
- anchorDataSize = strlen (pkString) + 1;
- anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize);
- anchor->method = GNUNET_ESCROW_KEY_PLAINTEXT;
- anchor->egoName = GNUNET_strdup (ego->name);
- anchor->size = anchorDataSize;
- GNUNET_memcpy (&anchor[1], pkString, anchorDataSize);
- w->anchor = anchor;
-
- /* update escrow status, i.e. set the last escrow method */
- ESCROW_update_escrow_status_put (h, ego, "plaintext");
+ if (ESCROW_PLUGIN_STATE_POST_INIT == ph.state)
+ {
+ continue_start (plugin_op_wrap);
+ }
+ else
+ {
+ delay.rel_value_us = 200 * GNUNET_TIME_relative_get_millisecond_().rel_value_us;
+ GNUNET_SCHEDULER_add_delayed (delay, &continue_start, plugin_op_wrap);
+ }
- p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap);
return plugin_op_wrap;
}
@@ -211,6 +273,68 @@ verify_cont (void *cls)
}
+static void
+continue_verify (void *cls)
+{
+ struct ESCROW_PluginOperationWrapper *plugin_op_wrap = cls;
+ struct ESCROW_PlaintextPluginOperation *p_op;
+ struct GNUNET_TIME_Relative delay;
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
+ char *pkString;
+ int verificationResult;
+ struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub;
+ struct EgoEntry *ego_entry;
+ char *pub_keystring;
+
+ p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op;
+
+ if (ESCROW_PLUGIN_STATE_POST_INIT != ph.state)
+ {
+ delay.rel_value_us = 100 * GNUNET_TIME_relative_get_millisecond_().rel_value_us;
+ GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap);
+ return;
+ }
+
+ GNUNET_IDENTITY_ego_get_public_key (p_op->ego, &ego_pub);
+ pub_keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ego_pub);
+ for (ego_entry = ph.ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
+ if (0 == strcmp (pub_keystring, ego_entry->keystring))
+ break;
+
+ GNUNET_free (pub_keystring);
+ if (NULL == ego_entry)
+ {
+ p_op->anchor_wrap->anchor = NULL;
+ p_op->anchor_wrap->emsg = _ ("Identity was not found in plugin!\n");
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&start_cont, plugin_op_wrap);
+ return;
+ }
+
+ p_op->egoName = GNUNET_strdup (ego_entry->identifier);
+
+ if (0 != strcmp (p_op->egoName, p_op->anchor->egoName))
+ {
+ p_op->verify_wrap->verificationResult = GNUNET_ESCROW_INVALID;
+ p_op->verify_wrap->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;
+ }
+ pk = GNUNET_IDENTITY_ego_get_private_key (p_op->ego);
+ pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk);
+ verificationResult = strncmp (pkString,
+ (char *)&p_op->anchor[1],
+ p_op->anchor->size) == 0 ?
+ GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID;
+
+ /* update the escrow status if valid */
+ if (GNUNET_ESCROW_VALID == verificationResult)
+ ESCROW_update_escrow_status_verify (p_op->h, p_op->ego, "plaintext");
+
+ p_op->verify_wrap->verificationResult = verificationResult;
+ p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
+}
+
+
/**
* Verify the plaintext escrow of the key
*
@@ -229,12 +353,10 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
ESCROW_Plugin_Continuation cb,
uint32_t op_id)
{
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
- char *pkString;
- int verificationResult;
struct ESCROW_PluginOperationWrapper *plugin_op_wrap;
struct ESCROW_PlaintextPluginOperation *p_op;
struct ESCROW_Plugin_VerifyContinuationWrapper *w;
+ struct GNUNET_TIME_Relative delay;
// create a new plaintext plugin operation (in a wrapper) and insert it into the DLL
plugin_op_wrap = GNUNET_new (struct ESCROW_PluginOperationWrapper);
@@ -246,6 +368,8 @@ verify_plaintext_key_escrow (struct GNUNET_ESCROW_Handle *h,
p_op = (struct ESCROW_PlaintextPluginOperation *)plugin_op_wrap->plugin_op;
p_op->h = h;
p_op->cont = cb;
+ p_op->ego = ego;
+ p_op->anchor = anchor;
w = GNUNET_new (struct ESCROW_Plugin_VerifyContinuationWrapper);
w->h = h;
@@ -266,26 +390,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 (0 != strcmp (ego->name, anchor->egoName))
+
+ if (ESCROW_PLUGIN_STATE_POST_INIT == ph.state)
{
- w->verificationResult = GNUNET_ESCROW_INVALID;
- 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;
+ continue_verify (plugin_op_wrap);
+ }
+ else
+ {
+ delay.rel_value_us = 200 * GNUNET_TIME_relative_get_millisecond_().rel_value_us;
+ GNUNET_SCHEDULER_add_delayed (delay, &continue_verify, plugin_op_wrap);
}
- pk = GNUNET_IDENTITY_ego_get_private_key (ego);
- pkString = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk);
- verificationResult = strncmp (pkString,
- (char *)&anchor[1],
- anchor->size) == 0 ?
- GNUNET_ESCROW_VALID : GNUNET_ESCROW_INVALID;
-
- /* update the escrow status if valid */
- if (GNUNET_ESCROW_VALID == verificationResult)
- ESCROW_update_escrow_status_verify (h, ego, "plaintext");
- w->verificationResult = verificationResult;
- p_op->sched_task = GNUNET_SCHEDULER_add_now (&verify_cont, plugin_op_wrap);
return plugin_op_wrap;
}
@@ -297,7 +412,8 @@ ego_created (struct GNUNET_IDENTITY_Ego *ego)
struct ESCROW_PlaintextPluginOperation *curr_p_op;
char *ego_pk_string, *curr_pk_string;
- ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string (&ego->pk);
+ ego_pk_string = GNUNET_CRYPTO_ecdsa_private_key_to_string (
+ GNUNET_IDENTITY_ego_get_private_key(ego));
for (curr = ph.plugin_op_head; NULL != curr; curr = curr->next)
{
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 @@
#include "gnunet_util_lib.h"
#include "gnunet_escrow_lib.h"
#include "gnunet_identity_service.h"
-#include "../escrow/escrow.h"
#include "gnunet_scheduler_lib.h"
#ifdef __cplusplus