From db8cdc8c4c80d305deb7b3b26c8e986d94ef5041 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 12 Feb 2022 12:10:33 +0100 Subject: [PATCH] -remove addessed documentation FIXMEs --- src/json/json_helper.c | 51 ++++++++++++++++++--------- src/json/json_pack.c | 40 ++++++++++----------- src/lib/exchange_api_link.c | 2 -- src/lib/exchange_api_recoup.c | 1 - src/lib/exchange_api_recoup_refresh.c | 1 - 5 files changed, 55 insertions(+), 40 deletions(-) diff --git a/src/json/json_helper.c b/src/json/json_helper.c index 7c5f7dde2..96e41b5e3 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c @@ -26,6 +26,25 @@ #include "taler_json_lib.h" +/** + * Convert string value to numeric cipher value. + * + * @param cipher_s input string + * @return numeric cipher value + */ +static enum TALER_DenominationCipher +string_to_cipher (const char *cipher_s) +{ + if (0 == strcasecmp (cipher_s, + "RSA")) + return TALER_DENOMINATION_RSA; + if (0 == strcasecmp (cipher_s, + "CS")) + return TALER_DENOMINATION_CS; + return TALER_DENOMINATION_INVALID; +} + + json_t * TALER_JSON_from_amount (const struct TALER_Amount *amount) { @@ -229,9 +248,9 @@ parse_denom_pub (void *cls, struct GNUNET_JSON_Specification *spec) { struct TALER_DenominationPublicKey *denom_pub = spec->ptr; - uint32_t cipher; + const char *cipher; struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_uint32 ("cipher", + GNUNET_JSON_spec_string ("cipher", &cipher), GNUNET_JSON_spec_uint32 ("age_mask", &denom_pub->age_mask.mask), @@ -250,7 +269,7 @@ parse_denom_pub (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - denom_pub->cipher = (enum TALER_DenominationCipher) cipher; + denom_pub->cipher = string_to_cipher (cipher); switch (denom_pub->cipher) { case TALER_DENOMINATION_RSA: @@ -346,9 +365,9 @@ parse_denom_sig (void *cls, struct GNUNET_JSON_Specification *spec) { struct TALER_DenominationSignature *denom_sig = spec->ptr; - uint32_t cipher; + const char *cipher; struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_uint32 ("cipher", + GNUNET_JSON_spec_string ("cipher", &cipher), GNUNET_JSON_spec_end () }; @@ -365,7 +384,7 @@ parse_denom_sig (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - denom_sig->cipher = (enum TALER_DenominationCipher) cipher; + denom_sig->cipher = string_to_cipher (cipher); switch (denom_sig->cipher) { case TALER_DENOMINATION_RSA: @@ -462,9 +481,9 @@ parse_blinded_denom_sig (void *cls, struct GNUNET_JSON_Specification *spec) { struct TALER_BlindedDenominationSignature *denom_sig = spec->ptr; - uint32_t cipher; + const char *cipher; struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_uint32 ("cipher", + GNUNET_JSON_spec_string ("cipher", &cipher), GNUNET_JSON_spec_end () }; @@ -481,7 +500,7 @@ parse_blinded_denom_sig (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - denom_sig->cipher = (enum TALER_DenominationCipher) cipher; + denom_sig->cipher = string_to_cipher (cipher); switch (denom_sig->cipher) { case TALER_DENOMINATION_RSA: @@ -581,9 +600,9 @@ parse_blinded_planchet (void *cls, struct GNUNET_JSON_Specification *spec) { struct TALER_BlindedPlanchet *blinded_planchet = spec->ptr; - uint32_t cipher; + const char *cipher; struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_uint32 ("cipher", + GNUNET_JSON_spec_string ("cipher", &cipher), GNUNET_JSON_spec_end () }; @@ -600,7 +619,7 @@ parse_blinded_planchet (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - blinded_planchet->cipher = (enum TALER_DenominationCipher) cipher; + blinded_planchet->cipher = string_to_cipher (cipher); switch (blinded_planchet->cipher) { case TALER_DENOMINATION_RSA: @@ -704,9 +723,9 @@ parse_exchange_withdraw_values (void *cls, struct GNUNET_JSON_Specification *spec) { struct TALER_ExchangeWithdrawValues *ewv = spec->ptr; - uint32_t cipher; + const char *cipher; struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_uint32 ("cipher", + GNUNET_JSON_spec_string ("cipher", &cipher), GNUNET_JSON_spec_end () }; @@ -723,8 +742,8 @@ parse_exchange_withdraw_values (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - ewv->cipher = (enum TALER_DenominationCipher) cipher; - switch (cipher) + ewv->cipher = string_to_cipher (cipher); + switch (ewv->cipher) { case TALER_DENOMINATION_RSA: return GNUNET_OK; diff --git a/src/json/json_pack.c b/src/json/json_pack.c index 535e8fa1c..8f888eaf0 100644 --- a/src/json/json_pack.c +++ b/src/json/json_pack.c @@ -61,8 +61,8 @@ TALER_JSON_pack_denom_pub ( case TALER_DENOMINATION_RSA: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_RSA), + GNUNET_JSON_pack_string ("cipher", + "RSA"), GNUNET_JSON_pack_uint64 ("age_mask", pk->age_mask.mask), GNUNET_JSON_pack_rsa_public_key ("rsa_public_key", @@ -71,8 +71,8 @@ TALER_JSON_pack_denom_pub ( case TALER_DENOMINATION_CS: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_CS), + GNUNET_JSON_pack_string ("cipher", + "CS"), GNUNET_JSON_pack_uint64 ("age_mask", pk->age_mask.mask), GNUNET_JSON_pack_data_varsize ("cs_public_key", @@ -99,15 +99,15 @@ TALER_JSON_pack_denom_sig ( { case TALER_DENOMINATION_RSA: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_RSA), + GNUNET_JSON_pack_string ("cipher", + "RSA"), GNUNET_JSON_pack_rsa_signature ("rsa_signature", sig->details.rsa_signature)); break; case TALER_DENOMINATION_CS: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_CS), + GNUNET_JSON_pack_string ("cipher", + "CS"), GNUNET_JSON_pack_data_auto ("cs_signature_r", &sig->details.cs_signature.r_point), GNUNET_JSON_pack_data_auto ("cs_signature_s", @@ -133,13 +133,13 @@ TALER_JSON_pack_exchange_withdraw_values ( { case TALER_DENOMINATION_RSA: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_RSA)); + GNUNET_JSON_pack_string ("cipher", + "RSA")); break; case TALER_DENOMINATION_CS: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_CS), + GNUNET_JSON_pack_string ("cipher", + "CS"), GNUNET_JSON_pack_data_varsize ( "r_pub_0", &ewv->details.cs_values.r_pub[0], @@ -170,15 +170,15 @@ TALER_JSON_pack_blinded_denom_sig ( { case TALER_DENOMINATION_RSA: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_RSA), + GNUNET_JSON_pack_string ("cipher", + "RSA"), GNUNET_JSON_pack_rsa_signature ("blinded_rsa_signature", sig->details.blinded_rsa_signature)); break; case TALER_DENOMINATION_CS: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_CS), + GNUNET_JSON_pack_string ("cipher", + "CS"), GNUNET_JSON_pack_uint64 ("b", sig->details.blinded_cs_answer.b), GNUNET_JSON_pack_data_auto ("s", @@ -204,8 +204,8 @@ TALER_JSON_pack_blinded_planchet ( { case TALER_DENOMINATION_RSA: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_RSA), + GNUNET_JSON_pack_string ("cipher", + "RSA"), GNUNET_JSON_pack_data_varsize ( "rsa_blinded_planchet", blinded_planchet->details.rsa_blinded_planchet.blinded_msg, @@ -213,8 +213,8 @@ TALER_JSON_pack_blinded_planchet ( break; case TALER_DENOMINATION_CS: ps.object = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("cipher", - TALER_DENOMINATION_CS), + GNUNET_JSON_pack_string ("cipher", + "CS"), GNUNET_JSON_pack_data_auto ( "cs_nonce", &blinded_planchet->details.cs_blinded_planchet.nonce), diff --git a/src/lib/exchange_api_link.c b/src/lib/exchange_api_link.c index 6a904da1b..ff1efe15b 100644 --- a/src/lib/exchange_api_link.c +++ b/src/lib/exchange_api_link.c @@ -102,12 +102,10 @@ parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh, &rpub), TALER_JSON_spec_blinded_denom_sig ("ev_sig", &bsig), - // FIXME: add to spec! TALER_JSON_spec_exchange_withdraw_values ("ewv", &alg_values), GNUNET_JSON_spec_fixed_auto ("link_sig", &link_sig), - // FIXME: add to spec! GNUNET_JSON_spec_uint32 ("coin_idx", &coin_idx), GNUNET_JSON_spec_end () diff --git a/src/lib/exchange_api_recoup.c b/src/lib/exchange_api_recoup.c index a3ba18afd..2584ade92 100644 --- a/src/lib/exchange_api_recoup.c +++ b/src/lib/exchange_api_recoup.c @@ -322,7 +322,6 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, &h_denom_pub), TALER_JSON_pack_denom_sig ("denom_sig", denom_sig), - // FIXME: add this to the spec! TALER_JSON_pack_exchange_withdraw_values ("ewv", exchange_vals), GNUNET_JSON_pack_data_auto ("coin_sig", diff --git a/src/lib/exchange_api_recoup_refresh.c b/src/lib/exchange_api_recoup_refresh.c index 517497067..9133e5942 100644 --- a/src/lib/exchange_api_recoup_refresh.c +++ b/src/lib/exchange_api_recoup_refresh.c @@ -326,7 +326,6 @@ TALER_EXCHANGE_recoup_refresh ( &h_denom_pub), TALER_JSON_pack_denom_sig ("denom_sig", denom_sig), - // FIXME: add this to the spec! TALER_JSON_pack_exchange_withdraw_values ("ewv", exchange_vals), GNUNET_JSON_pack_data_auto ("coin_sig",