From 5caa52aa4cf7eb4e59cef34195f61d088a28a622 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 21 Jun 2015 19:18:31 +0200 Subject: implementing /deposit JSON generation --- src/util/json.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/util/json.c') diff --git a/src/util/json.c b/src/util/json.c index 17eb0f3f..1c7cb752 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 */ -- cgit v1.2.3