summaryrefslogtreecommitdiff
path: root/src/util/json.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-15 16:39:06 +0100
committerChristian Grothoff <christian@grothoff.org>2015-03-15 16:39:06 +0100
commit53b189868edbc855240026c2a02fe6c4e53f9bb0 (patch)
tree6e8529155e75d0791f845784a98dbc7e6541cbed /src/util/json.c
parent76dda24c111c7316da36eba050b18494c6c83c56 (diff)
downloadexchange-53b189868edbc855240026c2a02fe6c4e53f9bb0.tar.gz
exchange-53b189868edbc855240026c2a02fe6c4e53f9bb0.tar.bz2
exchange-53b189868edbc855240026c2a02fe6c4e53f9bb0.zip
moving low-level JSON encoding logic to json.c
Diffstat (limited to 'src/util/json.c')
-rw-r--r--src/util/json.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/util/json.c b/src/util/json.c
index a9d6dc5cc..84fac4c98 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -151,6 +151,50 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
/**
+ * Convert RSA public key to JSON.
+ *
+ * @param pk public key to convert
+ * @return corresponding JSON encoding
+ */
+json_t *
+TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk)
+{
+ char *buf;
+ size_t buf_len;
+ json_t *ret;
+
+ buf_len = GNUNET_CRYPTO_rsa_public_key_encode (pk,
+ &buf);
+ ret = TALER_JSON_from_data (buf,
+ buf_len);
+ GNUNET_free (buf);
+ return ret;
+}
+
+
+/**
+ * Convert RSA signature to JSON.
+ *
+ * @param sig signature to convert
+ * @return corresponding JSON encoding
+ */
+json_t *
+TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig)
+{
+ char *buf;
+ size_t buf_len;
+ json_t *ret;
+
+ buf_len = GNUNET_CRYPTO_rsa_signature_encode (sig,
+ &buf);
+ ret = TALER_JSON_from_data (buf,
+ buf_len);
+ GNUNET_free (buf);
+ return ret;
+}
+
+
+/**
* Convert binary data to a JSON string
* with the base32crockford encoding.
*