donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 6f1d7255ec8cb0c7408ced48d0099b88ecf7feb7
parent b228279a37b9a8d378abb1bac5fd6a68359a1b8f
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date:   Mon,  1 Jan 2024 18:14:54 +0100

cleanup

Diffstat:
Msrc/donau/donau-httpd.c | 180+++++++++++++++++++++++++++++++------------------------------------------------
Msrc/donau/donau-httpd.h | 5++---
Msrc/donau/donau-httpd_keys.c | 144+++++++++++++++++++++----------------------------------------------------------
Msrc/donaudb/test_donaudb.c | 72++++++++----------------------------------------------------------------
Msrc/include/donaudb_plugin.h | 5++---
Msrc/lib/donau_api_batch_submit_receipts.c | 5-----
Msrc/testing/test_donau_api.c | 1-
7 files changed, 121 insertions(+), 291 deletions(-)

diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c @@ -32,7 +32,6 @@ #include "donau-httpd_terms.h" #include "donaudb_lib.h" #include "donaudb_plugin.h" -#include "taler/taler_extensions.h" #include <gnunet/gnunet_mhd_compat.h> #include "donau_util.h" @@ -50,7 +49,7 @@ * Above what request latency do we start to log? */ #define WARN_LATENCY GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MILLISECONDS, 500) + GNUNET_TIME_UNIT_MILLISECONDS, 500) /** * Are clients allowed to request /keys for times other than the @@ -171,14 +170,6 @@ int DH_check_invariants_flag; bool DH_suicide; /** - * Signature of the configuration of all enabled extensions, - * signed by the donau's offline master key with purpose - * TALER_SIGNATURE_MASTER_EXTENSION. - */ -struct TALER_MasterSignatureP DH_extensions_sig; -bool DH_extensions_signed = false; - -/** * Value to return from main() */ static int global_ret; @@ -191,7 +182,7 @@ static uint16_t serve_port; /** * Counter for the number of requests this HTTP has processed so far. */ -//static unsigned long long req_count; +// static unsigned long long req_count; /** * Counter for the number of open connections. @@ -276,11 +267,11 @@ handle_mhd_completion_callback (void *cls, return; GNUNET_async_scope_enter (&rc->async_scope_id, &old_scope); - //check_suicide (); - //DH_check_invariants (); + // check_suicide (); + // DH_check_invariants (); if (NULL != rc->rh_cleaner) rc->rh_cleaner (rc); - //DH_check_invariants (); + // DH_check_invariants (); { #if MHD_VERSION >= 0x00097304 const union MHD_ConnectionInfo *ci; @@ -307,7 +298,7 @@ handle_mhd_completion_callback (void *cls, TALER_MHD_parse_post_cleanup_callback (rc->opaque_post_parsing_context); /* Sanity-check that we didn't leave any transactions hanging */ GNUNET_break (GNUNET_OK == - DH_plugin->preflight (DH_plugin->cls)); + DH_plugin->preflight (DH_plugin->cls)); { struct GNUNET_TIME_Relative latency; @@ -512,75 +503,75 @@ handle_mhd_request (void *cls, { static struct DH_RequestHandler handlers[] = { /* /robots.txt: disallow everything */ -{ - .url = "robots.txt", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = &DH_handler_static_response, - .mime_type = "text/plain", - .data = "User-agent: *\nDisallow: /\n", - .response_code = MHD_HTTP_OK -}, + { + .url = "robots.txt", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = &DH_handler_static_response, + .mime_type = "text/plain", + .data = "User-agent: *\nDisallow: /\n", + .response_code = MHD_HTTP_OK + }, /* Landing page, tell humans to go away. */ -{ - .url = "", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = DH_handler_static_response, - .mime_type = "text/plain", - .data = - "Hello, I'm the Taler donau. This HTTP server is not for humans.\n", - .response_code = MHD_HTTP_OK -}, + { + .url = "", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = DH_handler_static_response, + .mime_type = "text/plain", + .data = + "Hello, I'm the Taler donau. This HTTP server is not for humans.\n", + .response_code = MHD_HTTP_OK + }, /* AGPL licensing page, redirect to source. As per the AGPL-license, every deployment is required to offer the user a download of the source of the actual deployment. We make this easy by including a redirect to the source here. */ -{ - .url = "agpl", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = &DH_handler_agpl_redirect -}, -{ - .url = "seed", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &handler_seed -}, + { + .url = "agpl", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = &DH_handler_agpl_redirect + }, + { + .url = "seed", + .method = MHD_HTTP_METHOD_GET, + .handler.get = &handler_seed + }, /* Configuration */ -{ - .url = "config", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = &DH_handler_config -}, + { + .url = "config", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = &DH_handler_config + }, /* Performance metrics */ -{ - .url = "metrics", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = &DH_handler_metrics -}, + { + .url = "metrics", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = &DH_handler_metrics + }, /* Terms of service */ -{ - .url = "terms", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = &DH_handler_terms -}, + { + .url = "terms", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = &DH_handler_terms + }, /* Privacy policy */ -{ - .url = "privacy", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = &DH_handler_privacy -}, + { + .url = "privacy", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = &DH_handler_privacy + }, /* Return key material and fundamental properties for this donau */ -{ - .url = "keys", - .method = MHD_HTTP_METHOD_GET, - //.handler.get = &DH_keys_get_handler, -}, + { + .url = "keys", + .method = MHD_HTTP_METHOD_GET, + // .handler.get = &DH_keys_get_handler, + }, /* request R, used in clause schnorr withdraw and refresh */ -{ - .url = "csr-melt", - .method = MHD_HTTP_METHOD_POST, - //.handler.post = &DH_handler_csr_melt, - .nargs = 0 -}, + { + .url = "csr-melt", + .method = MHD_HTTP_METHOD_POST, + // .handler.post = &DH_handler_csr_melt, + .nargs = 0 + }, /* mark end of list */ @@ -603,7 +594,7 @@ handle_mhd_request (void *cls, rc = *con_cls = GNUNET_new (struct DH_RequestContext); rc->start_time = GNUNET_TIME_absolute_get (); GNUNET_async_scope_fresh (&rc->async_scope_id); - //DH_check_invariants (); + // DH_check_invariants (); rc->url = url; rc->connection = connection; /* We only read the correlation ID on the first callback for every client */ @@ -630,7 +621,7 @@ handle_mhd_request (void *cls, GNUNET_async_scope_enter (&rc->async_scope_id, &old_scope); - //DH_check_invariants (); + // DH_check_invariants (); if (NULL != correlation_id) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Handling request (%s) for URL '%s', correlation_id=%s\n", @@ -1202,11 +1193,11 @@ run_single_request (void) } } + #endif /* end of HAVE_DEVELOPER */ - /** * Signature of the callback used by MHD to notify the application * about completed connections. If we are running in test-mode with @@ -1262,21 +1253,11 @@ do_shutdown (void *cls) (void) cls; mhd = TALER_MHD_daemon_stop (); - // DH_resume_keys_requests (true); - // DH_deposits_get_cleanup (); - // DH_reserves_get_cleanup (); - // DH_purses_get_cleanup (); - // DH_kyc_check_cleanup (); - // DH_kyc_proof_cleanup (); - // TALER_KYCLOGIC_kyc_done (); if (NULL != mhd) { MHD_stop_daemon (mhd); mhd = NULL; } - // DH_wire_done (); - // DH_extensions_done (); - // DH_keys_finished (); if (NULL != DH_plugin) { DONAUDB_plugin_unload (DH_plugin); @@ -1344,29 +1325,8 @@ run (void *cls, GNUNET_SCHEDULER_shutdown (); return; } - // if (GNUNET_OK != - // DH_extensions_init ()) - // { - // global_ret = EXIT_FAILURE; - // GNUNET_SCHEDULER_shutdown (); - // return; - // } - // if (GNUNET_OK != - // DH_keys_init ()) - // { - // global_ret = EXIT_FAILURE; - // GNUNET_SCHEDULER_shutdown (); - // return; - // } - // if (GNUNET_OK != - // DH_wire_init ()) - // { - // global_ret = EXIT_FAILURE; - // GNUNET_SCHEDULER_shutdown (); - // return; - // } - - //DH_load_terms (DH_cfg); + + // DH_load_terms (DH_cfg); DH_curl_ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, &donau_curl_rc); @@ -1433,6 +1393,7 @@ run (void *cls, #endif } + /** * The main function of the taler-donau-httpd server ("the donau"). * @@ -1485,4 +1446,5 @@ main (int argc, return global_ret; } + /* end of taler-donau-httpd.c */ \ No newline at end of file diff --git a/src/donau/donau-httpd.h b/src/donau/donau-httpd.h @@ -26,7 +26,6 @@ #include <microhttpd.h> #include "taler/taler_json_lib.h" #include <taler/taler_util.h> -#include "taler/taler_extensions.h" #include <gnunet/gnunet_mhd_compat.h> @@ -56,12 +55,12 @@ extern int DH_check_invariants_flag; * as building new /keys responses is expensive. Should only be * enabled for testcases, development and test systems. */ -//extern int DH_allow_keys_timetravel; +// extern int DH_allow_keys_timetravel; /** * Main directory with data. */ -//extern char *DH_revocation_directory; +// extern char *DH_revocation_directory; /** * True if we should commit suicide once all active diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c @@ -23,11 +23,10 @@ #include "taler/taler_json_lib.h" #include "taler/taler_mhd_lib.h" #include "donau-httpd.h" -//#include "donau-httpd_config.h" +// #include "donau-httpd_config.h" #include "donau-httpd_keys.h" #include "donau-httpd_responses.h" #include "donaudb_plugin.h" -#include "taler/taler_extensions.h" /** @@ -52,13 +51,13 @@ struct HelperDenomination /** * When will the helper start to use this key for signing? */ - //struct GNUNET_TIME_Timestamp start_time; + // struct GNUNET_TIME_Timestamp start_time; /** * For how long will the helper allow signing? 0 if * the key was revoked or purged. */ - //struct GNUNET_TIME_Relative validity_duration; + // struct GNUNET_TIME_Relative validity_duration; /** * Hash of the full denomination key. @@ -138,13 +137,13 @@ struct HelperSignkey /** * When will the helper start to use this key for signing? */ - //struct GNUNET_TIME_Timestamp start_time; + // struct GNUNET_TIME_Timestamp start_time; /** * For how long will the helper allow signing? 0 if * the key was revoked or purged. */ - //struct GNUNET_TIME_Relative validity_duration; + // struct GNUNET_TIME_Relative validity_duration; /** * The public key. @@ -236,7 +235,7 @@ struct KeysResponseData * The client's request must include this date or a higher one * for this response to be applicable. */ - struct GNUNET_TIME_Timestamp cherry_pick_date; + struct GNUNET_TIME_Timestamp cherry_pick_date; }; @@ -258,12 +257,6 @@ struct SigningKey */ struct DONAUDB_SignkeyMetaData meta; - /** - * The long-term offline master key's signature for this signing key. - * Signs over @e donau_pub and @e meta. - */ - //struct TALER_MasterSignatureP master_sig; - }; struct DH_KeyStateHandle @@ -314,19 +307,19 @@ struct DH_KeyStateHandle /** * When did we initiate the key reloading? */ - //struct GNUNET_TIME_Timestamp reload_time; + // struct GNUNET_TIME_Timestamp reload_time; /** * What is the period at which we rotate keys * (signing or denomination keys)? */ - //struct GNUNET_TIME_Relative rekey_frequency; + // struct GNUNET_TIME_Relative rekey_frequency; /** * When does our online signing key expire and we * thus need to re-generate this response? */ - //struct GNUNET_TIME_Timestamp signature_expires; + // struct GNUNET_TIME_Timestamp signature_expires; /** * True if #finish_keys_response() was not yet run and this key state @@ -1238,10 +1231,10 @@ DH_keys_init () asset_type = GNUNET_strdup ("fiat"); } keys_eh = DH_plugin->event_listen (DH_plugin->cls, - GNUNET_TIME_UNIT_FOREVER_REL, - &es, - &keys_update_event_cb, - NULL); + GNUNET_TIME_UNIT_FOREVER_REL, + &es, + &keys_update_event_cb, + NULL); if (NULL == keys_eh) { GNUNET_break (0); @@ -1268,7 +1261,7 @@ DH_keys_finished () if (NULL != keys_eh) { DH_plugin->event_listen_cancel (DH_plugin->cls, - keys_eh); + keys_eh); keys_eh = NULL; } } @@ -1895,69 +1888,6 @@ create_krd (struct DH_KeyStateHandle *ksh, &grouped_donau_sig)); GNUNET_assert (NULL != keys); - /* Signal support for the configured, enabled extensions. */ - { - json_t *extensions = json_object (); - bool has_extensions = false; - - GNUNET_assert (NULL != extensions); - /* Fill in the configurations of the enabled extensions */ - for (const struct TALER_Extensions *iter = TALER_extensions_get_head (); - NULL != iter && NULL != iter->extension; - iter = iter->next) - { - const struct TALER_Extension *extension = iter->extension; - json_t *manifest; - int r; - - /* skip if not enabled */ - if (! extension->enabled) - continue; - - /* flag our findings so far */ - has_extensions = true; - - - manifest = extension->manifest (extension); - GNUNET_assert (manifest); - - r = json_object_set_new ( - extensions, - extension->name, - manifest); - GNUNET_assert (0 == r); - } - - /* Update the keys object with the extensions and its signature */ - if (has_extensions) - { - json_t *sig; - int r; - - r = json_object_set_new ( - keys, - "extensions", - extensions); - GNUNET_assert (0 == r); - - /* Add the signature of the extensions, if it is not zero */ - if (DH_extensions_signed) - { - sig = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_data_auto ("extensions_sig", - &DH_extensions_sig)); - - r = json_object_update (keys, sig); - GNUNET_assert (0 == r); - } - } - else - { - json_decref (extensions); - } - } - - { char *keys_json; void *keys_jsonz; @@ -2123,7 +2053,8 @@ finish_keys_response (struct DH_KeyStateHandle *ksh) denominations_by_group = GNUNET_CONTAINER_multihashmap_create (1024, - GNUNET_NO /* NO, because keys are only on the stack */); + GNUNET_NO /* NO, because keys are only on the stack */ + ); /* heap = min heap, sorted by start time */ @@ -2453,7 +2384,8 @@ build_key_state (struct HelperState *hs, ksh->denomkey_map = GNUNET_CONTAINER_multihashmap_create (1024, true); ksh->signkey_map = GNUNET_CONTAINER_multipeermap_create (32, - false /* MUST be false! */); + false /* MUST be false! */ + ); /* NOTE: fetches master-signed signkeys, but ALSO those that were revoked! */ GNUNET_break (GNUNET_OK == DH_plugin->preflight (DH_plugin->cls)); @@ -2466,8 +2398,8 @@ build_key_state (struct HelperState *hs, return NULL; } qs = DH_plugin->iterate_denominations (DH_plugin->cls, - &denomination_info_cb, - ksh); + &denomination_info_cb, + ksh); if (qs < 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); @@ -2478,8 +2410,8 @@ build_key_state (struct HelperState *hs, } /* NOTE: ONLY fetches non-revoked AND master-signed signkeys! */ qs = DH_plugin->iterate_active_signkeys (DH_plugin->cls, - &signkey_info_cb, - ksh); + &signkey_info_cb, + ksh); if (qs < 0) { GNUNET_break (0); @@ -2488,8 +2420,8 @@ build_key_state (struct HelperState *hs, return NULL; } qs = DH_plugin->iterate_auditor_denominations (DH_plugin->cls, - &auditor_denom_cb, - ksh); + &auditor_denom_cb, + ksh); if (qs < 0) { GNUNET_break (0); @@ -2498,8 +2430,8 @@ build_key_state (struct HelperState *hs, return NULL; } qs = DH_plugin->iterate_active_auditors (DH_plugin->cls, - &auditor_info_cb, - ksh); + &auditor_info_cb, + ksh); if (qs < 0) { GNUNET_break (0); @@ -2537,9 +2469,9 @@ DH_keys_update_states () }; DH_plugin->event_notify (DH_plugin->cls, - &es, - NULL, - 0); + &es, + NULL, + 0); key_generation++; DH_resume_keys_requests (false); } @@ -2627,9 +2559,9 @@ DH_keys_denomination_by_hash ( } return DH_keys_denomination_by_hash_from_state (ksh, - h_denom_pub, - conn, - mret); + h_denom_pub, + conn, + mret); } @@ -2649,7 +2581,7 @@ DH_keys_denomination_by_hash_from_state ( if (NULL == conn) return NULL; *mret = DH_RESPONSE_reply_unknown_denom_pub_hash (conn, - h_denom_pub); + h_denom_pub); return NULL; } return dk; @@ -2972,9 +2904,9 @@ DH_keys_donau_sign_ ( return TALER_EC_DONAU_GENERIC_KEYS_MISSING; } return DH_keys_donau_sign2_ (ksh, - purpose, - pub, - sig); + purpose, + pub, + sig); } @@ -3068,7 +3000,7 @@ krd_search_comparator (const void *key, MHD_RESULT DH_keys_get_handler (struct DH_RequestContext *rc, - const char *const args[]) + const char *const args[]) { struct GNUNET_TIME_Timestamp last_issue_date; const char *etag; @@ -3328,7 +3260,7 @@ add_future_signkey_cb (void *cls, MHD_RESULT DH_keys_management_get_keys_handler (const struct DH_RequestHandler *rh, - struct MHD_Connection *connection) + struct MHD_Connection *connection) { struct DH_KeyStateHandle *ksh; json_t *reply; diff --git a/src/donaudb/test_donaudb.c b/src/donaudb/test_donaudb.c @@ -34,24 +34,25 @@ static int result; * Report line of error if @a cond is true, and jump to label "drop". */ #define FAILIF(cond) \ - do { \ - if (! (cond)) { break;} \ - GNUNET_break (0); \ - goto drop; \ - } while (0) + do { \ + if (! (cond)) { break;} \ + GNUNET_break (0); \ + goto drop; \ + } while (0) /** * Initializes @a ptr with random data. */ #define RND_BLK(ptr) \ - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr)) + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (* \ + ptr)) /** * Initializes @a ptr with zeros. */ #define ZR_BLK(ptr) \ - memset (ptr, 0, sizeof (*ptr)) + memset (ptr, 0, sizeof (*ptr)) /** @@ -108,63 +109,6 @@ mark_prepare_cb (void *cls, } -/** - * Simple check that config retrieval and setting for extensions work - */ -static enum GNUNET_GenericReturnValue -test_extension_manifest (void) -{ - char *manifest; - - FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->set_extension_manifest (plugin->cls, - "fnord", - "bar")); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (0 != strcmp ("bar", manifest)); - GNUNET_free (manifest); - - /* let's do this again! */ - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->set_extension_manifest (plugin->cls, - "fnord", - "buzz")); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (0 != strcmp ("buzz", manifest)); - GNUNET_free (manifest); - - /* let's do this again, with NULL */ - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->set_extension_manifest (plugin->cls, - "fnord", - NULL)); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (NULL != manifest); - - return GNUNET_OK; -drop: - return GNUNET_SYSERR; -} - int main (int argc, char *const argv[]) diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h @@ -20,12 +20,11 @@ */ #ifndef DONAUDB_PLUGIN_H #define DONAUDB_PLUGIN_H -//#include <jansson.h> +// #include <jansson.h> #include <gnunet/gnunet_db_lib.h> #include "taler/taler_json_lib.h" #include "donau_signatures.h" #include "donau_util.h" -//#include "taler/taler_extensions_policy.h" /** * Meta data about a donation unit key. @@ -45,7 +44,7 @@ struct DONAUDB_DonationUnitKeyMetaData /** * Hash code of the donation unit public key. */ - struct DONAU_DonationUnitHashP donation_unit_hash; //already in GNUNET_CRYPTO_BlindSignPublicKey -> part of every public donation unit + struct DONAU_DonationUnitHashP donation_unit_hash; // already in GNUNET_CRYPTO_BlindSignPublicKey -> part of every public donation unit }; diff --git a/src/lib/donau_api_batch_submit_receipts.c b/src/lib/donau_api_batch_submit_receipts.c @@ -135,11 +135,6 @@ struct DONAU_BatchDepositHandle struct TALER_CharityWireHashP h_wire; /** - * Hash over the extensions, or all zero. - */ - struct TALER_ExtensionPolicyHashP h_policy; - - /** * Time when this confirmation was generated / when the donau received * the deposit request. */ diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c @@ -34,7 +34,6 @@ #include "taler_bank_service.h" #include "taler_fakebank_lib.h" #include "taler_testing_lib.h" -#include "taler/taler_extensions.h" /** * Configuration file we use. One (big) configuration is used