diff options
Diffstat (limited to 'src/exchange/taler-exchange-httpd_management_post_keys.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_management_post_keys.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c b/src/exchange/taler-exchange-httpd_management_post_keys.c index ab7afd34b..4d5a65af9 100644 --- a/src/exchange/taler-exchange-httpd_management_post_keys.c +++ b/src/exchange/taler-exchange-httpd_management_post_keys.c @@ -26,9 +26,8 @@ #include <pthread.h> #include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_refund.h" +#include "taler_signatures.h" #include "taler-exchange-httpd_responses.h" -#include "taler-exchange-httpd_keystate.h" /** @@ -126,7 +125,7 @@ add_keys (void *cls, bool is_active = false; struct TALER_EXCHANGEDB_DenominationKeyMetaData meta; - qs = TEH_plugin->lookup_future_deomination_key ( + qs = TEH_plugin->lookup_future_denomination_key ( TEH_plugin->cls, session, &akc->d_sigs[i].h_denom_pub, @@ -134,7 +133,7 @@ add_keys (void *cls, if (0 == qs) { /* For idempotency, check if the key is already active */ - qs = TEH_plugin->lookup_deomination_key ( + qs = TEH_plugin->lookup_denomination_key ( TEH_plugin->cls, session, &akc->d_sigs[i].h_denom_pub, @@ -148,17 +147,17 @@ add_keys (void *cls, GNUNET_break (0); *mhd_ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_LOOKUP_FAILED, + TALER_EC_GENERIC_DB_FETCH_FAILED, "lookup denomination key"); return qs; } if (0 == qs) { - *mhd_ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_GENERIC_DENOM_UNKNOWN, - GNUNET_h2s ( - &aks->d_sigs[i].h_denom_pub)); + *mhd_ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN, + GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); return qs; } @@ -190,20 +189,20 @@ add_keys (void *cls, GNUNET_CRYPTO_eddsa_verify ( TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, &dkv, - &akc->d_sigs[i].master_sig.eddsa_sig, + &akc->d_sigs[i].master_sig.eddsa_signature, &TEH_master_public_key.eddsa_pub)) { GNUNET_break_op (0); return TALER_MHD_reply_with_error ( connection, MHD_HTTP_FORBIDDEN, - TALER_EC_EXCHANGE_KEYS_ADD_SIGNATURE_INVALID, - GNUNET_h2s (&aks->d_sigs[i].h_denom_pub)); + TALER_EC_EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_ADD_SIGNATURE_INVALID, + GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); } } if (is_active) continue; /* skip, already known */ - qs = TEH_plugin->activate_deomination_key ( + qs = TEH_plugin->activate_denomination_key ( TEH_plugin->cls, session, &akc->d_sigs[i].h_denom_pub, @@ -252,17 +251,17 @@ add_keys (void *cls, GNUNET_break (0); *mhd_ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_LOOKUP_FAILED, + TALER_EC_GENERIC_DB_FETCH_FAILED, "lookup signing key"); return qs; } if (0 == qs) { - *mhd_ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_GENERIC_SIGNKEY_UNKNOWN, - TALER_B2S ( - &aks->s_sigs[i].exchange_pub)); + *mhd_ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_UNKNOWN, + TALER_B2S (&akc->s_sigs[i].exchange_pub)); return qs; } @@ -271,27 +270,27 @@ add_keys (void *cls, struct TALER_ExchangeSigningKeyValidityPS skv = { .purpose.purpose = htonl ( TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY), - .purpose.size = htonl (sizeof (dkv)), + .purpose.size = htonl (sizeof (skv)), .master_public_key = TEH_master_public_key, .start = x, .expire = y, .end = z, - .signkey_pub = akc->d_sigs[i].exchange_pub + .signkey_pub = akc->s_sigs[i].exchange_pub }; if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify ( TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY, &skv, - &akc->s_sigs[i].master_sig.eddsa_sig, + &akc->s_sigs[i].master_sig.eddsa_signature, &TEH_master_public_key.eddsa_pub)) { GNUNET_break_op (0); return TALER_MHD_reply_with_error ( connection, MHD_HTTP_FORBIDDEN, - TALER_EC_EXCHANGE_KEYS_ADD_SIGNATURE_INVALID, - GNUNET_h2s (&aks->d_sigs[i].h_denom_pub)); + TALER_EC_EXCHANGE_MANAGEMENT_KEYS_DENOMKEY_ADD_SIGNATURE_INVALID, + GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); } } if (is_active) @@ -365,7 +364,7 @@ TEH_handler_management_post_keys ( return TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_XXX, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "array expected for denom_sigs and signkey_sigs"); } akc.nd_sigs = json_array_size (denom_sigs); @@ -375,7 +374,7 @@ TEH_handler_management_post_keys ( for (unsigned int i = 0; i<akc.nd_sigs; i++) { struct DenomSig *d = &akc.d_sigs[i]; - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_fixed_auto ("master_sig", &d->master_sig), GNUNET_JSON_spec_fixed_auto ("h_denom_pub", @@ -385,9 +384,9 @@ TEH_handler_management_post_keys ( enum GNUNET_GenericReturnValue res; res = TALER_MHD_parse_json_data (connection, - root, json_array_get (denom_sigs, - i)); + i), + ispec); if (GNUNET_SYSERR == res) { ret = MHD_NO; /* hard failure */ @@ -412,7 +411,7 @@ TEH_handler_management_post_keys ( for (unsigned int i = 0; i<akc.nd_sigs; i++) { struct SigningSig *s = &akc.s_sigs[i]; - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_fixed_auto ("master_sig", &s->master_sig), GNUNET_JSON_spec_fixed_auto ("exchange_pub", @@ -422,9 +421,9 @@ TEH_handler_management_post_keys ( enum GNUNET_GenericReturnValue res; res = TALER_MHD_parse_json_data (connection, - root, json_array_get (signkey_sigs, - i)); + i), + ispec); if (GNUNET_SYSERR == res) { ret = MHD_NO; /* hard failure */ @@ -446,11 +445,11 @@ TEH_handler_management_post_keys ( } qs = TEH_DB_run_transaction (connection, "add keys", - &res, + &ret, &add_keys, &akc); if (qs < 0) - return res; + return ret; return TALER_MHD_reply_static ( connection, MHD_HTTP_NO_CONTENT, |