From a95dfe2f7882055f50ee804cf950b3350e162bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Bl=C3=A4ttler?= Date: Sun, 28 Apr 2024 13:55:58 +0200 Subject: json pack token envelope --- src/include/taler_json_lib.h | 13 ++++++++++++ src/json/json_pack.c | 49 ++++++++++++++++---------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 17768c0e3..22e44fdf0 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -167,6 +167,19 @@ TALER_JSON_pack_token_issue_sig ( const struct TALER_TokenIssueSignatureP *sig); +/** + * Generate packer instruction for a JSON field of type token envelope. + * + * @param name name of the field to add to the object + * @param envelope blinded token envelope + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_token_envelope ( + const char *name, + const struct TALER_TokenEnvelopeP *envelope); + + /** * Generate packer instruction for a JSON field of type * exchange withdraw values (/csr). diff --git a/src/json/json_pack.c b/src/json/json_pack.c index 940123ea0..427ac3e85 100644 --- a/src/json/json_pack.c +++ b/src/json/json_pack.c @@ -170,6 +170,22 @@ TALER_JSON_pack_token_issue_sig ( } +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_token_envelope ( + const char *name, + const struct TALER_TokenEnvelopeP *envelope) +{ + struct GNUNET_JSON_PackSpec ps = { + .field_name = name, + }; + + if (NULL == envelope) + return ps; + return GNUNET_JSON_pack_blinded_message (name, + envelope->blinded_pub); +} + + struct GNUNET_JSON_PackSpec TALER_JSON_pack_exchange_withdraw_values ( const char *name, @@ -263,37 +279,8 @@ TALER_JSON_pack_blinded_planchet ( if (NULL == blinded_planchet) return ps; - bm = blinded_planchet->blinded_message; - switch (bm->cipher) - { - case GNUNET_CRYPTO_BSA_INVALID: - break; - case GNUNET_CRYPTO_BSA_RSA: - ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("cipher", - "RSA"), - GNUNET_JSON_pack_data_varsize ( - "rsa_blinded_planchet", - bm->details.rsa_blinded_message.blinded_msg, - bm->details.rsa_blinded_message.blinded_msg_size)); - return ps; - case GNUNET_CRYPTO_BSA_CS: - ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("cipher", - "CS"), - GNUNET_JSON_pack_data_auto ( - "cs_nonce", - &bm->details.cs_blinded_message.nonce), - GNUNET_JSON_pack_data_auto ( - "cs_blinded_c0", - &bm->details.cs_blinded_message.c[0]), - GNUNET_JSON_pack_data_auto ( - "cs_blinded_c1", - &bm->details.cs_blinded_message.c[1])); - return ps; - } - GNUNET_assert (0); - return ps; + return GNUNET_JSON_pack_blinded_message (name, + blinded_planchet->blinded_message); } -- cgit v1.2.3