aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-06-23 13:54:56 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-06-23 13:54:56 +0200
commit7995b55ebf7786719afb4fec95a9b7c2c3111149 (patch)
treec8e16613502d63fd7f8462ea1df79f89a38f5ff5
parentf17c43614d46e3c8d024f2de63299abf86125ff4 (diff)
validating and hashing (wireformats of) merchants instances
m---------examples/blog/web-common0
m---------examples/shop/web-common0
-rw-r--r--src/backend/taler-merchant-httpd.c93
-rw-r--r--src/backend/taler-merchant-httpd.h6
4 files changed, 76 insertions, 23 deletions
diff --git a/examples/blog/web-common b/examples/blog/web-common
-Subproject 026ef2476676ef00b6c2a0cec135a8e64024ee5
+Subproject 80f1e2708dbe4b19349244b611a6167b4b7a98c
diff --git a/examples/shop/web-common b/examples/shop/web-common
-Subproject 026ef2476676ef00b6c2a0cec135a8e64024ee5
+Subproject 80f1e2708dbe4b19349244b611a6167b4b7a98c
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 96fb7923..3b253a9a 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -497,28 +497,31 @@ instances_iterator_cb (void *cls,
instance_wiresection);
GNUNET_free (instance_wiresection);
- /** template for validating wiredetails **
- ret = plugin->wire_validate (plugin->cls,
- j_wire,
- NULL);
- GNUNET_PLUGIN_unload (lib_name,
- plugin);
- GNUNET_free (lib_name);
- if (GNUNET_YES != ret)
- return GNUNET_SYSERR;
- if (GNUNET_SYSERR ==
- TALER_JSON_hash (j_wire,
- &h_wire))
- return GNUNET_SYSERR;
+ if (GNUNET_YES != iic->plugin->wire_validate (iic->plugin->cls,
+ mi->j_wire,
+ NULL))
+ {
+
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Malformed wireformat\n");
+ iic->ret |= GNUNET_SYSERR;
+ }
- ** end of template for validating wiredetails **/
+ if (GNUNET_YES != TALER_JSON_hash (mi->j_wire,
+ &mi->h_wire))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to hash wireformat\n");
+ iic->ret |= GNUNET_SYSERR;
+ }
+ #if EXTRADEBUG
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Found wireformat instance:\n");
+ json_dumpf (mi->j_wire, stdout, 0);
+ printf ("\n");
+ #endif
GNUNET_array_append (instances, iic->current_index, mi);
- /**
- * TODO
- * Validate fetched wiredetails
- */
-
}
/**
@@ -563,21 +566,65 @@ iterate_instances (const struct GNUNET_CONFIGURATION_Handle *config,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No default merchant instance found\n");
- GNUNET_PLUGIN_unload (lib_name,
- iic->plugin);
- GNUNET_SCHEDULER_shutdown ();
- return GNUNET_SYSERR;
+ goto fail;
}
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Congratulations, you have a default instance\n");
+ if (0 != (GNUNET_SYSERR & iic->ret))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No default merchant instance found\n");
+ goto fail;
+ }
+
GNUNET_PLUGIN_unload (lib_name,
iic->plugin);
GNUNET_free (lib_name);
GNUNET_array_append (instances, iic->current_index, NULL);
+ #if EXTRADEBUG
+ unsigned int i;
+ for (i=0; NULL != instances[i]; i++)
+ {
+ char *hash;
+ char *priv;
+ char *pub;
+
+ hash =
+ GNUNET_STRINGS_data_to_string_alloc (&instances[i]->h_wire,
+ sizeof (struct GNUNET_HashCode));
+ priv =
+ GNUNET_STRINGS_data_to_string_alloc (&instances[i]->privkey.eddsa_priv,
+ sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey));
+ pub =
+ GNUNET_STRINGS_data_to_string_alloc (&instances[i]->pubkey.eddsa_pub,
+ sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "instances[%d]: id=%s,\nj_wire=%s,\nj_hash=%s,\npriv=%s,\npub=%s\n",
+ i,
+ instances[i]->id,
+ json_dumps (instances[i]->j_wire, JSON_INDENT (2)),
+ hash,
+ priv,
+ pub);
+
+ GNUNET_free (hash);
+ GNUNET_free (priv);
+ GNUNET_free (pub);
+ }
+ #endif
GNUNET_free (iic);
return GNUNET_OK;
+
+ fail: do {
+ GNUNET_PLUGIN_unload (lib_name,
+ iic->plugin);
+ GNUNET_free (lib_name);
+ GNUNET_free (iic);
+ GNUNET_SCHEDULER_shutdown ();
+ return GNUNET_SYSERR;
+ } while (0);
}
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h
index c9a64249..060fd26e 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -60,6 +60,12 @@ struct IterateInstancesCls {
* Wire plugin
*/
struct TALER_WIRE_Plugin *plugin;
+
+ /**
+ * Tells if the parsing encountered any error. We need this
+ * field since the iterator must return void
+ */
+ unsigned int ret;
};