aboutsummaryrefslogtreecommitdiff
path: root/src/util/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/json.c')
-rw-r--r--src/util/json.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util/json.c b/src/util/json.c
index 17eb0f3fd..1c7cb7520 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -402,4 +402,31 @@ TALER_json_to_data (json_t *json,
return GNUNET_SYSERR;
}
+
+/**
+ * Hash a JSON for binary signing.
+ *
+ * @param[in] json some JSON value
+ * @param[out] hc resulting hash code
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+int
+TALER_hash_json (json_t *json,
+ struct GNUNET_HashCode *hc)
+{
+ char *wire_enc;
+ size_t len;
+
+ if (NULL == (wire_enc = json_dumps (json,
+ JSON_COMPACT | JSON_SORT_KEYS)))
+ return GNUNET_SYSERR;
+ len = strlen (wire_enc) + 1;
+ GNUNET_CRYPTO_hash (wire_enc,
+ len,
+ hc);
+ GNUNET_free (wire_enc);
+ return GNUNET_OK;
+}
+
+
/* End of util/json.c */