aboutsummaryrefslogtreecommitdiff
path: root/src/util/json.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-06-21 19:18:31 +0200
committerChristian Grothoff <christian@grothoff.org>2015-06-21 19:18:31 +0200
commit5caa52aa4cf7eb4e59cef34195f61d088a28a622 (patch)
treecaacee4443a52e4b23fd5e5f5fbb8d94701d31e4 /src/util/json.c
parentc5641e9141ed8fccf13a2a11cb859e93e8270974 (diff)
implementing /deposit JSON generation
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 */