From 53b189868edbc855240026c2a02fe6c4e53f9bb0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 15 Mar 2015 16:39:06 +0100 Subject: moving low-level JSON encoding logic to json.c --- src/util/json.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/util') 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 @@ -150,6 +150,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. -- cgit v1.2.3