summaryrefslogtreecommitdiff
path: root/src/json
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-02-12 12:10:33 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-12 12:10:33 +0100
commitdb8cdc8c4c80d305deb7b3b26c8e986d94ef5041 (patch)
treef5d8b37b0750574f0b3622b698adc5242b0325fc /src/json
parentea4be7ba6fcbd8ba6860f3fc7234a51c474f4e30 (diff)
downloadexchange-db8cdc8c4c80d305deb7b3b26c8e986d94ef5041.tar.gz
exchange-db8cdc8c4c80d305deb7b3b26c8e986d94ef5041.tar.bz2
exchange-db8cdc8c4c80d305deb7b3b26c8e986d94ef5041.zip
-remove addessed documentation FIXMEs
Diffstat (limited to 'src/json')
-rw-r--r--src/json/json_helper.c51
-rw-r--r--src/json/json_pack.c40
2 files changed, 55 insertions, 36 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),