summaryrefslogtreecommitdiff
path: root/src/json/json.c
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-01-27 20:25:40 +0100
committerFlorian Dold <florian@dold.me>2022-01-27 20:25:40 +0100
commite6e0cabf084ca4a333718b953bc0b48ac12e7356 (patch)
treec39e33b10046ecae33bec6e47537eb43f452e464 /src/json/json.c
parent32f1276b8c9cdc65f6873b8dc8d86240f25c8907 (diff)
downloadexchange-e6e0cabf084ca4a333718b953bc0b48ac12e7356.tar.gz
exchange-e6e0cabf084ca4a333718b953bc0b48ac12e7356.tar.bz2
exchange-e6e0cabf084ca4a333718b953bc0b48ac12e7356.zip
test and hopefully fix JSON canonicalization
Diffstat (limited to 'src/json/json.c')
-rw-r--r--src/json/json.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/json/json.c b/src/json/json.c
index bf3b2a0e7..da4472522 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -144,6 +144,9 @@ rfc8785encode (char **inp)
if ( (1 == mbl) &&
(val <= 0x1F) )
{
+ /* Should not happen, as input is produced by
+ * JSON stringification */
+ GNUNET_break (0);
lowdump (&buf,
val);
}
@@ -193,6 +196,12 @@ rfc8785encode (char **inp)
}
}
break;
+ default:
+ mbl = 2;
+ GNUNET_buffer_write (&buf,
+ pos,
+ mbl);
+ break;
}
}
else
@@ -1009,6 +1018,24 @@ TALER_deposit_extension_hash (const json_t *extensions,
}
+char *
+TALER_JSON_canonicalize (const json_t *input)
+{
+ char *wire_enc;
+
+ if (NULL == (wire_enc = json_dumps (input,
+ JSON_ENCODE_ANY
+ | JSON_COMPACT
+ | JSON_SORT_KEYS)))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ rfc8785encode (&wire_enc);
+ return wire_enc;
+}
+
+
enum GNUNET_GenericReturnValue
TALER_JSON_extensions_config_hash (const json_t *config,
struct TALER_ExtensionConfigHash *ech)