diff options
Diffstat (limited to 'src/donau/donau-httpd_csr.c')
-rw-r--r-- | src/donau/donau-httpd_csr.c | 89 |
1 files changed, 24 insertions, 65 deletions
diff --git a/src/donau/donau-httpd_csr.c b/src/donau/donau-httpd_csr.c index ee18314..e016fbb 100644 --- a/src/donau/donau-httpd_csr.c +++ b/src/donau/donau-httpd_csr.c @@ -19,9 +19,7 @@ /** * @file donau-httpd_csr.c * @brief Handle /csr requests - * @author Lucien Heuzeveldt - * @author Gian Demarmles - * @author Christian Grothoff + * @author Johannes Casaburi */ #include <taler/platform.h> #include <gnunet/gnunet_util_lib.h> @@ -32,6 +30,7 @@ #include <taler/taler_mhd_lib.h> #include <taler/taler_signatures.h> #include "donaudb_plugin.h" +#include "donau-httpd_keys.h" #include "donau-httpd_csr.h" @@ -43,22 +42,22 @@ MHD_RESULT DH_handler_csr_issue (struct DH_RequestContext *rc, - const json_t *root, - const char *const args[]) + const json_t *root, + const char *const args[]) { struct GNUNET_CRYPTO_CsSessionNonce nonce; - struct TALER_DenominationHashP denom_pub_hash; + struct DONAU_DonationUnitHashP du_pub_hash; struct GNUNET_CRYPTO_BlindingInputValues ewv = { .cipher = GNUNET_CRYPTO_BSA_CS }; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("nonce", &nonce), - GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", - &denom_pub_hash), + GNUNET_JSON_spec_fixed_auto ("du_pub_hash", + &du_pub_hash), GNUNET_JSON_spec_end () }; - struct TEH_DenominationKey *dk; + struct DH_DonationUnitKey *dk; (void) args; { @@ -72,74 +71,34 @@ DH_handler_csr_issue (struct DH_RequestContext *rc, } { - struct TEH_KeyStateHandle *ksh; - - ksh = TEH_keys_get_state (); - if (NULL == ksh) - { - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING, - NULL); - } - dk = TEH_keys_denomination_by_hash_from_state (ksh, - &denom_pub_hash, - NULL, - NULL); + dk = DH_keys_donation_unit_by_hash (&du_pub_hash); if (NULL == dk) { - return TEH_RESPONSE_reply_unknown_denom_pub_hash ( - rc->connection, - &denom_pub_hash); - } - if (GNUNET_TIME_absolute_is_past (dk->meta.expire_withdraw.abs_time)) - { - /* This denomination is past the expiration time for withdraws/refreshes*/ - return TEH_RESPONSE_reply_expired_denom_pub_hash ( - rc->connection, - &denom_pub_hash, - TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED, - "csr-withdraw"); - } - if (GNUNET_TIME_absolute_is_future (dk->meta.start.abs_time)) - { - /* This denomination is not yet valid, no need to check - for idempotency! */ - return TEH_RESPONSE_reply_expired_denom_pub_hash ( - rc->connection, - &denom_pub_hash, - TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE, - "csr-withdraw"); - } - if (dk->recoup_possible) - { - /* This denomination has been revoked */ - return TEH_RESPONSE_reply_expired_denom_pub_hash ( + GNUNET_break (0); + return TALER_MHD_reply_with_error ( rc->connection, - &denom_pub_hash, - TALER_EC_EXCHANGE_GENERIC_DENOMINATION_REVOKED, - "csr-withdraw"); + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DONAU_GENERIC_KEYS_MISSING, + NULL); } if (GNUNET_CRYPTO_BSA_CS != - dk->denom_pub.bsign_pub_key->cipher) + dk->donation_unit_pub.bsign_pub_key->cipher) { - /* denomination is valid but not for CS */ - return TEH_RESPONSE_reply_invalid_denom_cipher_for_operation ( + /* donation_unit is valid but not for CS */ + GNUNET_break (0); + return TALER_MHD_reply_with_error ( rc->connection, - &denom_pub_hash); + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DONAU_GENERIC_KEYS_MISSING, + NULL); } } /* derive r_pub */ { enum TALER_ErrorCode ec; - const struct TEH_CsDeriveData cdd = { - .h_denom_pub = &denom_pub_hash, - .nonce = &nonce - }; - - ec = TEH_keys_denomination_cs_r_pub (&cdd, - false, + ec = DH_keys_donation_unit_cs_r_pub (&du_pub_hash, + &nonce, &ewv.details.cs_values); if (TALER_EC_NONE != ec) { @@ -156,7 +115,7 @@ DH_handler_csr_issue (struct DH_RequestContext *rc, return TALER_MHD_REPLY_JSON_PACK ( rc->connection, - MHD_HTTP_OK, + MHD_HTTP_CREATED, TALER_JSON_pack_exchange_withdraw_values ("ewv", &exw)); } |