commit 929815f1630d7b3d19f8b6c2abb27bbb35d754fb parent ffddf74b59250a9a6865bf6a50ec9b0127c64959 Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch> Date: Fri, 5 Jan 2024 12:30:31 +0100 cleanup and rename Diffstat:
21 files changed, 268 insertions(+), 465 deletions(-)
diff --git a/doc/Makefile.am b/doc/Makefile.am @@ -19,24 +19,24 @@ man_MANS = \ #prebuilt/man/taler-auditor-sync.1 \ #prebuilt/man/taler-bank-benchmark.1 \ #prebuilt/man/taler-bank-transfer.1 \ - prebuilt/man/taler-donau-aggregator.1 \ - prebuilt/man/taler-donau-benchmark.1 \ - prebuilt/man/taler-donau-closer.1 \ - prebuilt/man/taler-donau-dbconfig.1 \ - prebuilt/man/taler-donau-dbinit.1 \ - #prebuilt/man/taler-donau-drain.1 \ - #prebuilt/man/taler-donau-expire.1 \ + prebuilt/man/donau-aggregator.1 \ + prebuilt/man/donau-benchmark.1 \ + prebuilt/man/donau-closer.1 \ + prebuilt/man/donau-dbconfig.1 \ + prebuilt/man/donau-dbinit.1 \ + #prebuilt/man/donau-drain.1 \ + #prebuilt/man/donau-expire.1 \ prebuilt/man/donau-httpd.1 \ - #prebuilt/man/taler-donau-kyc-aml-pep-trigger.1 \ - #prebuilt/man/taler-donau-kyc-tester.1 \ - prebuilt/man/taler-donau-offline.1 \ - prebuilt/man/taler-donau-router.1\ - prebuilt/man/taler-donau-secmod-cs.1\ - prebuilt/man/taler-donau-secmod-eddsa.1\ - prebuilt/man/taler-donau-secmod-rsa.1 \ - #prebuilt/man/taler-donau-transfer.1\ - #prebuilt/man/taler-donau-wire-gateway-client.1\ - #prebuilt/man/taler-donau-wirewatch.1 \ + #prebuilt/man/donau-kyc-aml-pep-trigger.1 \ + #prebuilt/man/donau-kyc-tester.1 \ + prebuilt/man/donau-offline.1 \ + prebuilt/man/donau-router.1\ + prebuilt/man/donau-secmod-cs.1\ + prebuilt/man/donau-secmod-eddsa.1\ + prebuilt/man/donau-secmod-rsa.1 \ + #prebuilt/man/donau-transfer.1\ + #prebuilt/man/donau-wire-gateway-client.1\ + #prebuilt/man/donau-wirewatch.1 \ #prebuilt/man/taler-helper-auditor-aggregation.1 \ #prebuilt/man/taler-helper-auditor-coins.1\ #prebuilt/man/taler-helper-auditor-deposits.1\ @@ -50,7 +50,7 @@ man_MANS = \ #prebuilt/texinfo/taler-auditor.texi \ #prebuilt/texinfo/taler-bank.texi \ #prebuilt/texinfo/taler-developer-manual.texi \ - #prebuilt/texinfo/taler-donau.texi + #prebuilt/texinfo/donau.texi EXTRA_DIST = \ @@ -69,6 +69,6 @@ EXTRA_DIST = \ #prebuilt/texinfo/taler-developer-manual-figures/donau-db.png \ #prebuilt/texinfo/taler-developer-manual-figures/charity-db.png \ #prebuilt/texinfo/taler-developer-manual-figures/replication.png \ - #prebuilt/texinfo/taler-donau-figures/auditor-db.png \ - #prebuilt/texinfo/taler-donau-figures/donau-db.png\ - #prebuilt/texinfo/taler-donau-figures/replication.png + #prebuilt/texinfo/donau-figures/auditor-db.png \ + #prebuilt/texinfo/donau-figures/donau-db.png\ + #prebuilt/texinfo/donau-figures/replication.png diff --git a/src/donau-tools/Makefile.am b/src/donau-tools/Makefile.am @@ -15,7 +15,7 @@ bin_PROGRAMS = \ donau-dbinit donau_dbinit_SOURCES = \ - taler-donau-dbinit.c + donau-dbinit.c donau_dbinit_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/util/libdonauutil.la \ @@ -23,7 +23,7 @@ donau_dbinit_LDADD = \ $(top_builddir)/src/donaudb/libdonaudb.la \ -lgnunetutil \ $(XLIB) -taler_donau_dbinit_CPPFLAGS = \ +donau_dbinit_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/pq/ \ $(POSTGRESQL_CPPFLAGS) diff --git a/src/donau-tools/donau-dbinit.c b/src/donau-tools/donau-dbinit.c @@ -116,23 +116,23 @@ run (void *cls, global_ret = EXIT_NOPERMISSION; return; } - if (clear_shards) - { - if (GNUNET_OK != - plugin->delete_shard_locks (plugin->cls)) - { - fprintf (stderr, - "Clearing revolving shards failed!\n"); - } - } - if (gc_db) - { - if (GNUNET_SYSERR == plugin->gc (plugin->cls)) - { - fprintf (stderr, - "Garbage collection failed!\n"); - } - } + //if (clear_shards) + //{ + // if (GNUNET_OK != + // plugin->delete_shard_locks (plugin->cls)) + // { + // fprintf (stderr, + // "Clearing revolving shards failed!\n"); + // } + //} + //if (gc_db) + //{ + // if (GNUNET_SYSERR == plugin->gc (plugin->cls)) + // { + // fprintf (stderr, + // "Garbage collection failed!\n"); + // } + //} } DONAUDB_plugin_unload (plugin); plugin = NULL; diff --git a/src/donau-tools/taler-donau-dbinit.c b/src/donau-tools/taler-donau-dbinit.c @@ -1,204 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of CHARITYABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -*/ -/** - * @file donau-tools/donau-dbinit.c - * @brief Create tables for the donau database. - * @author Florian Dold - * @author Christian Grothoff - */ -#include "taler/platform.h" -#include <gnunet/gnunet_util_lib.h> -#include "donaudb_lib.h" - - -/** - * Return value from main(). - */ -static int global_ret; - -/** - * -r option: do full DB reset - */ -static int reset_db; - -/** - * -s option: clear revolving shard locks - */ -static int clear_shards; - -/** - * -g option: garbage collect DB reset - */ -static int gc_db; - -/** - * -P option: setup a partitioned database - */ -static uint32_t num_partitions; - -/** - * -f option: force partitions to be created when there is only one - */ -static int force_create_partitions; - -/** - * Main function that will be run. - * - * @param cls closure - * @param args remaining command-line arguments - * @param cfgfile name of the configuration file used (for saving, can be NULL!) - * @param cfg configuration - */ -// static void -// run (void *cls, -// char *const *args, -// const char *cfgfile, -// const struct GNUNET_CONFIGURATION_Handle *cfg) -// { -// struct DONAUDB_Plugin *plugin; - -// (void) cls; -// (void) args; -// (void) cfgfile; - -// if (NULL == -// (plugin = DONAUDB_plugin_load (cfg))) -// { -// fprintf (stderr, -// "Failed to initialize database plugin.\n"); -// global_ret = EXIT_NOTINSTALLED; -// return; -// } -// if (reset_db) -// { -// if (GNUNET_OK != -// plugin->drop_tables (plugin->cls)) -// { -// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -// "Could not drop tables as requested. Either database was not yet initialized, or permission denied. Consult the logs. Will still try to create new tables.\n"); -// } -// } -// if (GNUNET_OK != -// plugin->create_tables (plugin->cls, -// force_create_partitions || num_partitions > 0, -// num_partitions)) -// { -// fprintf (stderr, -// "Failed to initialize database.\n"); -// DONAUDB_plugin_unload (plugin); -// plugin = NULL; -// global_ret = EXIT_NOPERMISSION; -// return; -// } -// if (gc_db || clear_shards) -// { -// if (GNUNET_OK != -// plugin->preflight (plugin->cls)) -// { -// fprintf (stderr, -// "Failed to prepare database.\n"); -// DONAUDB_plugin_unload (plugin); -// plugin = NULL; -// global_ret = EXIT_NOPERMISSION; -// return; -// } -// if (clear_shards) -// { -// if (GNUNET_OK != -// plugin->delete_shard_locks (plugin->cls)) -// { -// fprintf (stderr, -// "Clearing revolving shards failed!\n"); -// } -// } -// if (gc_db) -// { -// if (GNUNET_SYSERR == plugin->gc (plugin->cls)) -// { -// fprintf (stderr, -// "Garbage collection failed!\n"); -// } -// } -// } -// DONAUDB_plugin_unload (plugin); -// plugin = NULL; -// } - - -/** - * The main function of the database initialization tool. - * Used to initialize the Taler Donau's database. - * - * @param argc number of arguments from the command line - * @param argv command line arguments - * @return 0 ok, non-zero on error - */ -int -main (int argc, - char *const *argv) -{ - const struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_option_flag ('g', - "gc", - "garbage collect database", - &gc_db), - GNUNET_GETOPT_option_flag ('r', - "reset", - "reset database (DANGEROUS: all existing data is lost!)", - &reset_db), - GNUNET_GETOPT_option_flag ('s', - "shardunlock", - "unlock all revolving shard locks (use after system crash or shard size change while services are not running)", - &clear_shards), - GNUNET_GETOPT_option_uint ('P', - "partition", - "NUMBER", - "Setup a partitioned database where each table which can be partitioned holds NUMBER partitions on a single DB node", - &num_partitions), - GNUNET_GETOPT_option_flag ('f', - "force", - "Force partitions to be created if there is only one partition", - &force_create_partitions), - GNUNET_GETOPT_OPTION_END - }; - enum GNUNET_GenericReturnValue ret; - (void) options; // delete me - ret = 1; // delete me - - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; - /* force linker to link against libtalerutil; if we do - not do this, the linker may "optimize" libtalerutil - away and skip #TALER_OS_init(), which we do need */ - // TALER_OS_init (); - // ret = GNUNET_PROGRAM_run ( - // argc, argv, - // "donau-dbinit", - // gettext_noop ("Initialize Taler donau database"), - // options, - // &run, NULL); - GNUNET_free_nz ((void *) argv); - if (GNUNET_SYSERR == ret) - return EXIT_INVALIDARGUMENT; - if (GNUNET_NO == ret) - return EXIT_SUCCESS; - return global_ret; -} - - -/* end of donau-dbinit.c */ diff --git a/src/donau/Makefile.am b/src/donau/Makefile.am @@ -49,10 +49,10 @@ donau_httpd_SOURCES = \ AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; check_SCRIPTS = \ - test_taler_donau_httpd.sh + test_donau_httpd.sh if HAVE_EXPENSIVE_TESTS check_SCRIPTS += \ - test_taler_donau_httpd_afl.sh + test_donau_httpd_afl.sh endif .NOTPARALLEL: @@ -62,11 +62,11 @@ TESTS = \ # Distribution EXTRA_DIST = \ - test_taler_donau_httpd_home/.local/share/taler/donau/offline-keys/master.priv \ - test_taler_donau_httpd.conf \ - test_taler_donau_unix.conf \ - test_taler_donau_httpd.get \ - test_taler_donau_httpd.post \ + test_donau_httpd_home/.local/share/taler/donau/offline-keys/master.priv \ + test_donau_httpd.conf \ + test_donau_unix.conf \ + test_donau_httpd.get \ + test_donau_httpd.post \ donau.conf \ $(bin_SCRIPTS) \ $(check_SCRIPTS) diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c @@ -81,12 +81,6 @@ static struct MHD_Daemon *mhd; struct GNUNET_TIME_Relative DH_max_keys_caching; /** - * Master public key (according to the - * configuration in the donau directory). (global) - */ -struct TALER_MasterPublicKeyP DH_master_public_key; - -/** * Our DB plugin. (global) */ struct DONAUDB_Plugin *DH_plugin; @@ -815,11 +809,11 @@ do_shutdown (void *cls) MHD_stop_daemon (mhd); mhd = NULL; } - if (NULL != DH_plugin) - { - DONAUDB_plugin_unload (DH_plugin); - DH_plugin = NULL; - } + //if (NULL != DH_plugin) + //{ + // DONAUDB_plugin_unload (DH_plugin); + // DH_plugin = NULL; + //} if (NULL != DH_curl_ctx) { GNUNET_CURL_fini (DH_curl_ctx); diff --git a/src/donau/donau-httpd_config.c b/src/donau/donau-httpd_config.c @@ -39,7 +39,7 @@ DH_handler_config (struct DH_RequestContext *rc, GNUNET_JSON_pack_string ("currency", DH_currency), GNUNET_JSON_pack_string ("name", - "taler-donau"), + "donau"), GNUNET_JSON_pack_string ("version", DONAU_PROTOCOL_VERSION)); } diff --git a/src/donau/donau-httpd_db.c b/src/donau/donau-httpd_db.c @@ -39,17 +39,17 @@ DH_DB_run_transaction (struct MHD_Connection *connection, { if (NULL != mhd_ret) *mhd_ret = -1; /* set to invalid value, to help detect bugs */ - if (GNUNET_OK != - DH_plugin->preflight (DH_plugin->cls)) - { - GNUNET_break (0); - if (NULL != mhd_ret) - *mhd_ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_SETUP_FAILED, - NULL); - return GNUNET_SYSERR; - } + //if (GNUNET_OK != + // DH_plugin->preflight (DH_plugin->cls)) + //{ + // GNUNET_break (0); + // if (NULL != mhd_ret) + // *mhd_ret = TALER_MHD_reply_with_error (connection, + // MHD_HTTP_INTERNAL_SERVER_ERROR, + // TALER_EC_GENERIC_DB_SETUP_FAILED, + // NULL); + // return GNUNET_SYSERR; + //} GNUNET_assert (mt < DH_MT_REQUEST_COUNT); DH_METRICS_num_requests[mt]++; for (unsigned int retries = 0; @@ -58,43 +58,43 @@ DH_DB_run_transaction (struct MHD_Connection *connection, { enum GNUNET_DB_QueryStatus qs; - if (GNUNET_OK != - DH_plugin->start (DH_plugin->cls, - name)) - { - GNUNET_break (0); - if (NULL != mhd_ret) - *mhd_ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_START_FAILED, - NULL); - return GNUNET_SYSERR; - } + //if (GNUNET_OK != + // DH_plugin->start (DH_plugin->cls, + // name)) + //{ + // GNUNET_break (0); + // if (NULL != mhd_ret) + // *mhd_ret = TALER_MHD_reply_with_error (connection, + // MHD_HTTP_INTERNAL_SERVER_ERROR, + // TALER_EC_GENERIC_DB_START_FAILED, + // NULL); + // return GNUNET_SYSERR; + //} qs = cb (cb_cls, connection, mhd_ret); - if (0 > qs) - { - DH_plugin->rollback (DH_plugin->cls); - if (GNUNET_DB_STATUS_HARD_ERROR == qs) - return GNUNET_SYSERR; - } - else - { - qs = DH_plugin->commit (DH_plugin->cls); - if (GNUNET_DB_STATUS_HARD_ERROR == qs) - { - DH_plugin->rollback (DH_plugin->cls); - if (NULL != mhd_ret) - *mhd_ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_COMMIT_FAILED, - NULL); - return GNUNET_SYSERR; - } - if (0 > qs) - DH_plugin->rollback (DH_plugin->cls); - } + //if (0 > qs) + //{ + // DH_plugin->rollback (DH_plugin->cls); + // if (GNUNET_DB_STATUS_HARD_ERROR == qs) + // return GNUNET_SYSERR; + //} + //else + //{ + // qs = DH_plugin->commit (DH_plugin->cls); + // if (GNUNET_DB_STATUS_HARD_ERROR == qs) + // { + // DH_plugin->rollback (DH_plugin->cls); + // if (NULL != mhd_ret) + // *mhd_ret = TALER_MHD_reply_with_error (connection, + // MHD_HTTP_INTERNAL_SERVER_ERROR, + // TALER_EC_GENERIC_DB_COMMIT_FAILED, + // NULL); + // return GNUNET_SYSERR; + // } + // if (0 > qs) + // DH_plugin->rollback (DH_plugin->cls); + //} if (0 <= qs) return GNUNET_OK; DH_METRICS_num_conflict[mt]++; diff --git a/src/donau/donau-httpd_db.h b/src/donau/donau-httpd_db.h @@ -22,7 +22,7 @@ #define DONAU_HTTPD_DB_H #include <microhttpd.h> -#include "donaudb_plugin.h" +//#include "donaudb_plugin.h" #include "donau-httpd_metrics.h" #include <gnunet/gnunet_mhd_compat.h> diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c @@ -85,12 +85,12 @@ struct SigningKey /** * The donau's (online signing) public key. */ - struct DONAU_DonationUnitPublicKey donau_pub; + struct DONAU_EddsaPublicKeyP donau_pub; /** * Meta data about the signing key, such as validity periods. */ - struct DONAUDB_DonationUnitKeyMetaData meta; + struct DONAUDB_SignkeyMetaData meta; }; @@ -294,26 +294,26 @@ add_sign_key_cb (void *cls, struct SigningKey *sk = value; (void) pid; - //if (GNUNET_TIME_absolute_is_future (sk->meta.expire_sign.abs_time)) - //{ + // if (GNUNET_TIME_absolute_is_future (sk->meta.expire_sign.abs_time)) + // { // ctx->min_sk_frequency = // GNUNET_TIME_relative_min (ctx->min_sk_frequency, // GNUNET_TIME_absolute_get_difference ( // sk->meta.start.abs_time, // sk->meta.expire_sign.abs_time)); - //} + // } GNUNET_assert ( 0 == json_array_append_new ( ctx->signkeys, GNUNET_JSON_PACK ( - //GNUNET_JSON_pack_timestamp ("stamp_start", + // GNUNET_JSON_pack_timestamp ("stamp_start", // sk->meta.start), - //GNUNET_JSON_pack_timestamp ("stamp_expire", + // GNUNET_JSON_pack_timestamp ("stamp_expire", // sk->meta.expire_sign), - //GNUNET_JSON_pack_timestamp ("stamp_end", + // GNUNET_JSON_pack_timestamp ("stamp_end", // sk->meta.expire_legal), - //GNUNET_JSON_pack_data_auto ("master_sig", + // GNUNET_JSON_pack_data_auto ("master_sig", // &sk->master_sig), GNUNET_JSON_pack_data_auto ("key", &sk->donau_pub)))); @@ -321,7 +321,6 @@ add_sign_key_cb (void *cls, } - /** * Add the headers we want to set for every /keys response. * @@ -358,6 +357,7 @@ setup_general_response_headers (void *cls, "public,max-age=3600")); } + /** * Update the "/keys" responses in @a ksh, computing the detailed replies. * @@ -377,7 +377,7 @@ finish_keys_response (struct DH_KeyStateHandle *ksh) struct GNUNET_TIME_Timestamp last_cherry_pick_date; struct GNUNET_CONTAINER_Heap *heap; struct GNUNET_HashContext *hash_context = NULL; - //struct GNUNET_HashCode grouped_hash_xor = {0}; + // struct GNUNET_HashCode grouped_hash_xor = {0}; sctx.signkeys = json_array (); GNUNET_assert (NULL != sctx.signkeys); @@ -395,10 +395,10 @@ finish_keys_response (struct DH_KeyStateHandle *ksh) .min_dk_frequency = GNUNET_TIME_UNIT_FOREVER_REL, }; - //GNUNET_CONTAINER_multihashmap_iterate (ksh->denomkey_map, + // GNUNET_CONTAINER_multihashmap_iterate (ksh->denomkey_map, // &add_denom_key_cb, // &dkc); - //ksh->rekey_frequency + // ksh->rekey_frequency // = GNUNET_TIME_relative_min (dkc.min_dk_frequency, // sctx.min_sk_frequency); } @@ -417,7 +417,7 @@ finish_keys_response (struct DH_KeyStateHandle *ksh) GNUNET_CRYPTO_hash_context_finish (hash_context, &hc); - //if (GNUNET_OK != + // if (GNUNET_OK != // create_krd (ksh, // &hc, // last_cherry_pick_date, @@ -425,12 +425,12 @@ finish_keys_response (struct DH_KeyStateHandle *ksh) // recoup, // grouped_denominations, // &grouped_hash_xor)) - //{ + // { // GNUNET_log (GNUNET_ERROR_TYPE_WARNING, // "Failed to generate key response data for %s\n", // GNUNET_TIME_timestamp2s (last_cherry_pick_date)); // goto CLEANUP; - //} + // } ksh->management_only = false; } else @@ -449,6 +449,7 @@ CLEANUP: return ret; } + /** * Free denomination key data. * @@ -466,7 +467,7 @@ clear_denomination_cb (void *cls, (void) cls; (void) h_donation_unit_pub; - //TALER_denom_pub_free (&dk->denom_pub); + // TALER_denom_pub_free (&dk->denom_pub); GNUNET_free (dk); return GNUNET_OK; } @@ -493,6 +494,7 @@ clear_signkey_cb (void *cls, return GNUNET_OK; } + /** * Clear memory for responses to "/keys" in @a ksh. * @@ -514,6 +516,7 @@ clear_response_cache (struct DH_KeyStateHandle *ksh) 0); } + /** * Synchronize helper state. Polls the key helper for updates. * @@ -527,6 +530,7 @@ sync_key_helpers (struct HelperState *hs) TALER_CRYPTO_helper_esign_poll (hs->esh); } + /** * Destroy helper state. Does NOT call free() on @a hs, as that * state is not separately allocated! Dual to #setup_key_helpers(). @@ -536,19 +540,19 @@ sync_key_helpers (struct HelperState *hs) static void destroy_key_helpers (struct HelperState *hs) { - //GNUNET_CONTAINER_multihashmap_iterate (hs->denom_keys, + // GNUNET_CONTAINER_multihashmap_iterate (hs->denom_keys, // &free_denom_cb, // hs); - //GNUNET_CONTAINER_multihashmap_destroy (hs->rsa_keys); - //hs->rsa_keys = NULL; - //GNUNET_CONTAINER_multihashmap_destroy (hs->cs_keys); - //hs->cs_keys = NULL; - //GNUNET_CONTAINER_multihashmap_destroy (hs->denom_keys); - //hs->denom_keys = NULL; - //GNUNET_CONTAINER_multipeermap_iterate (hs->esign_keys, + // GNUNET_CONTAINER_multihashmap_destroy (hs->rsa_keys); + // hs->rsa_keys = NULL; + // GNUNET_CONTAINER_multihashmap_destroy (hs->cs_keys); + // hs->cs_keys = NULL; + // GNUNET_CONTAINER_multihashmap_destroy (hs->denom_keys); + // hs->denom_keys = NULL; + // GNUNET_CONTAINER_multipeermap_iterate (hs->esign_keys, // &free_esign_cb, // hs); - //GNUNET_CONTAINER_multipeermap_destroy (hs->esign_keys); + // GNUNET_CONTAINER_multipeermap_destroy (hs->esign_keys); hs->esign_keys = NULL; if (NULL != hs->rsadh) { @@ -567,6 +571,7 @@ destroy_key_helpers (struct HelperState *hs) } } + /** * Free resources associated with @a cls, possibly excluding * the helper data. @@ -578,16 +583,16 @@ static void destroy_key_state (struct DH_KeyStateHandle *ksh, bool free_helper) { - //struct DH_GlobalFee *gf; + // struct DH_GlobalFee *gf; clear_response_cache (ksh); - //while (NULL != (gf = ksh->gf_head)) - //{ + // while (NULL != (gf = ksh->gf_head)) + // { // GNUNET_CONTAINER_DLL_remove (ksh->gf_head, // ksh->gf_tail, // gf); // GNUNET_free (gf); - //} + // } GNUNET_CONTAINER_multihashmap_iterate (ksh->denomkey_map, &clear_denomination_cb, ksh); @@ -596,10 +601,10 @@ destroy_key_state (struct DH_KeyStateHandle *ksh, &clear_signkey_cb, ksh); GNUNET_CONTAINER_multipeermap_destroy (ksh->signkey_map); - //json_decref (ksh->auditors); - //ksh->auditors = NULL; - //json_decref (ksh->global_fees); - //ksh->global_fees = NULL; + // json_decref (ksh->auditors); + // ksh->auditors = NULL; + // json_decref (ksh->global_fees); + // ksh->global_fees = NULL; if (free_helper) { destroy_key_helpers (ksh->helpers); @@ -613,6 +618,7 @@ destroy_key_state (struct DH_KeyStateHandle *ksh, GNUNET_free (ksh); } + /** * Setup helper state. * @@ -622,7 +628,7 @@ destroy_key_state (struct DH_KeyStateHandle *ksh, static enum GNUNET_GenericReturnValue setup_key_helpers (struct HelperState *hs) { - //hs->denom_keys + // hs->denom_keys // = GNUNET_CONTAINER_multihashmap_create (1024, // GNUNET_YES); hs->rsa_keys @@ -634,33 +640,34 @@ setup_key_helpers (struct HelperState *hs) hs->esign_keys = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_NO /* MUST BE NO! */); - //hs->rsadh = TALER_CRYPTO_helper_rsa_connect (DH_cfg, + // hs->rsadh = TALER_CRYPTO_helper_rsa_connect (DH_cfg, // &helper_rsa_cb, // hs); - //if (NULL == hs->rsadh) - //{ + // if (NULL == hs->rsadh) + // { // destroy_key_helpers (hs); // return GNUNET_SYSERR; - //} - //hs->csdh = TALER_CRYPTO_helper_cs_connect (DH_cfg, + // } + // hs->csdh = TALER_CRYPTO_helper_cs_connect (DH_cfg, // &helper_cs_cb, // hs); - //if (NULL == hs->csdh) - //{ + // if (NULL == hs->csdh) + // { // destroy_key_helpers (hs); // return GNUNET_SYSERR; - //} - //hs->esh = TALER_CRYPTO_helper_esign_connect (DH_cfg, + // } + // hs->esh = TALER_CRYPTO_helper_esign_connect (DH_cfg, // &helper_esign_cb, // hs); - //if (NULL == hs->esh) - //{ + // if (NULL == hs->esh) + // { // destroy_key_helpers (hs); // return GNUNET_SYSERR; - //} + // } return GNUNET_OK; } + /** * Create a key state. * @@ -703,19 +710,8 @@ build_key_state (struct HelperState *hs, 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)); - if (qs < 0) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); - GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); - destroy_key_state (ksh, - true); - return NULL; - } - //qs = DH_plugin->iterate_denominations (DH_plugin->cls, - // &denomination_info_cb, - // ksh); + //GNUNET_break (GNUNET_OK == + // DH_plugin->preflight (DH_plugin->cls)); //if (qs < 0) //{ // GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); @@ -724,17 +720,28 @@ build_key_state (struct HelperState *hs, // true); // return NULL; //} + // qs = DH_plugin->iterate_denominations (DH_plugin->cls, + // &denomination_info_cb, + // ksh); + // if (qs < 0) + // { + // GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); + // GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + // destroy_key_state (ksh, + // true); + // return NULL; + // } /* NOTE: ONLY fetches non-revoked AND master-signed signkeys! */ - //qs = DH_plugin->iterate_active_signkeys (DH_plugin->cls, + // qs = DH_plugin->iterate_active_signkeys (DH_plugin->cls, // &signkey_info_cb, // ksh); - //if (qs < 0) - //{ + // if (qs < 0) + // { // GNUNET_break (0); // destroy_key_state (ksh, // true); // return NULL; - //} + // } if (management_only) { @@ -755,13 +762,13 @@ build_key_state (struct HelperState *hs, return ksh; } - + void DH_keys_update_states () { struct GNUNET_DB_EventHeaderP es = { .size = htons (sizeof (es)), - //.type = htons (TALER_DBEVENT_DONAU_KEYS_UPDATED), + // .type = htons (TALER_DBEVENT_DONAU_KEYS_UPDATED), }; DH_plugin->event_notify (DH_plugin->cls, @@ -769,49 +776,52 @@ DH_keys_update_states () NULL, 0); key_generation++; - //DH_resume_keys_requests (false); + // DH_resume_keys_requests (false); } + static struct DH_KeyStateHandle * keys_get_state (bool management_only) { - struct DH_KeyStateHandle *old_ksh; - struct DH_KeyStateHandle *ksh; - old_ksh = key_state; - if (NULL == old_ksh) - { - //ksh = build_key_state (NULL, management_only); - ksh = NULL; - if (NULL == ksh) - return NULL; - key_state = ksh; - return ksh; - } - if ( (old_ksh->key_generation < key_generation) || - (GNUNET_TIME_absolute_is_past (old_ksh->signature_expires.abs_time)) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Rebuilding /keys, generation upgrade from %llu to %llu\n", - (unsigned long long) old_ksh->key_generation, - (unsigned long long) key_generation); - ksh = build_key_state (old_ksh->helpers, - management_only); - key_state = ksh; - old_ksh->helpers = NULL; - destroy_key_state (old_ksh, - false); - return ksh; - } - sync_key_helpers (old_ksh->helpers); - return old_ksh; + struct DH_KeyStateHandle *old_ksh; + struct DH_KeyStateHandle *ksh; + old_ksh = key_state; + if (NULL == old_ksh) + { + // ksh = build_key_state (NULL, management_only); + ksh = NULL; + if (NULL == ksh) + return NULL; + key_state = ksh; + return ksh; + } + if ( (old_ksh->key_generation < key_generation) || + (GNUNET_TIME_absolute_is_past (old_ksh->signature_expires.abs_time)) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Rebuilding /keys, generation upgrade from %llu to %llu\n", + (unsigned long long) old_ksh->key_generation, + (unsigned long long) key_generation); + ksh = build_key_state (old_ksh->helpers, + management_only); + key_state = ksh; + old_ksh->helpers = NULL; + destroy_key_state (old_ksh, + false); + return ksh; + } + sync_key_helpers (old_ksh->helpers); + return old_ksh; } + struct DH_KeyStateHandle * DH_keys_get_state_for_management_only (void) { - return keys_get_state (true); + return keys_get_state (true); } + MHD_RESULT DH_keys_management_get_keys_handler (const struct DH_RequestHandler *rh, struct MHD_Connection *connection) @@ -832,65 +842,66 @@ DH_keys_management_get_keys_handler (const struct DH_RequestHandler *rh, sync_key_helpers (ksh->helpers); if (NULL == ksh->management_keys_reply) { - //struct FutureBuilderContext fbc = { - // .ksh = ksh, - // .donation_units = json_array (), - // .signkeys = json_array () - //}; - if ( (GNUNET_is_zero (&donation_unit_rsa_sm_pub)) && - (GNUNET_is_zero (&donation_unit_cs_sm_pub)) ) - { - /* Either IPC failed, or neither helper had any donation_unitinations configured. */ - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_GATEWAY, - TALER_EC_EXCHANGE_DENOMINATION_HELPER_UNAVAILABLE, - NULL); - } - if (GNUNET_is_zero (&esign_sm_pub)) - { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_GATEWAY, - TALER_EC_EXCHANGE_SIGNKEY_HELPER_UNAVAILABLE, - NULL); - } - //GNUNET_assert (NULL != fbc.donation_units); - //GNUNET_assert (NULL != fbc.signkeys); - //GNUNET_CONTAINER_multihashmap_iterate (ksh->helpers->donation_unit_keys, - // &add_future_donation_unitkey_cb, - // &fbc); - //GNUNET_CONTAINER_multipeermap_iterate (ksh->helpers->esign_keys, - // &add_future_signkey_cb, - // &fbc); - reply = GNUNET_JSON_PACK ( - //GNUNET_JSON_pack_array_steal ("future_donation_units", - // fbc.donation_units), - //GNUNET_JSON_pack_array_steal ("future_signkeys", - // fbc.signkeys), - //GNUNET_JSON_pack_data_auto ("master_pub", - // &DH_master_public_key), - GNUNET_JSON_pack_data_auto ("donation_unit_secmod_public_key", - &donation_unit_rsa_sm_pub), - GNUNET_JSON_pack_data_auto ("donation_unit_secmod_cs_public_key", - &donation_unit_cs_sm_pub), - GNUNET_JSON_pack_data_auto ("signkey_secmod_public_key", - &esign_sm_pub)); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Returning GET /management/keys response:\n"); - if (NULL == reply) - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, - NULL); - GNUNET_assert (NULL == ksh->management_keys_reply); - ksh->management_keys_reply = reply; + // struct FutureBuilderContext fbc = { + // .ksh = ksh, + // .donation_units = json_array (), + // .signkeys = json_array () + // }; + if ( (GNUNET_is_zero (&donation_unit_rsa_sm_pub)) && + (GNUNET_is_zero (&donation_unit_cs_sm_pub)) ) + { + /* Either IPC failed, or neither helper had any donation_unitinations configured. */ + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_GATEWAY, + TALER_EC_EXCHANGE_DENOMINATION_HELPER_UNAVAILABLE, + NULL); + } + if (GNUNET_is_zero (&esign_sm_pub)) + { + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_GATEWAY, + TALER_EC_EXCHANGE_SIGNKEY_HELPER_UNAVAILABLE, + NULL); + } + // GNUNET_assert (NULL != fbc.donation_units); + // GNUNET_assert (NULL != fbc.signkeys); + // GNUNET_CONTAINER_multihashmap_iterate (ksh->helpers->donation_unit_keys, + // &add_future_donation_unitkey_cb, + // &fbc); + // GNUNET_CONTAINER_multipeermap_iterate (ksh->helpers->esign_keys, + // &add_future_signkey_cb, + // &fbc); + reply = GNUNET_JSON_PACK ( + // GNUNET_JSON_pack_array_steal ("future_donation_units", + // fbc.donation_units), + // GNUNET_JSON_pack_array_steal ("future_signkeys", + // fbc.signkeys), + // GNUNET_JSON_pack_data_auto ("master_pub", + // &DH_master_public_key), + GNUNET_JSON_pack_data_auto ("donation_unit_secmod_public_key", + &donation_unit_rsa_sm_pub), + GNUNET_JSON_pack_data_auto ("donation_unit_secmod_cs_public_key", + &donation_unit_cs_sm_pub), + GNUNET_JSON_pack_data_auto ("signkey_secmod_public_key", + &esign_sm_pub)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Returning GET /management/keys response:\n"); + if (NULL == reply) + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, + NULL); + GNUNET_assert (NULL == ksh->management_keys_reply); + ksh->management_keys_reply = reply; } else { - reply = ksh->management_keys_reply; + reply = ksh->management_keys_reply; } return TALER_MHD_reply_json (connection, reply, MHD_HTTP_OK); } + /* end of donau-httpd_keys.c */ diff --git a/src/donau/donau-httpd_keys.h b/src/donau/donau-httpd_keys.h @@ -23,6 +23,7 @@ #include "taler/taler_mhd_lib.h" // #include "donau-httpd_responses.h" #include "donau_util.h" +#include "donaudb_plugin.h" #ifndef DONAU_HTTPD_KEYS_H @@ -51,7 +52,7 @@ struct DH_DonationUnitKey * Meta data about the type of the donation unit, containing the validity * year and the value of the donation unit. */ - // struct DONAUDB_DonationUnitKeyMetaData meta; + struct DONAUDB_DonationUnitKeyMetaData meta; }; diff --git a/src/donau/test_taler_donau_httpd.conf b/src/donau/test_donau_httpd.conf diff --git a/src/donau/test_taler_donau_httpd.sh b/src/donau/test_donau_httpd.sh diff --git a/src/donau/test_taler_donau_unix.conf b/src/donau/test_donau_unix.conf diff --git a/src/donaudb/pg_activate_signing_key.c b/src/donaudb/pg_activate_signing_key.c @@ -28,7 +28,7 @@ enum GNUNET_DB_QueryStatus DH_PG_activate_signing_key ( void *cls, - const struct DONAU_DonauPublicKeyP *donau_pub, + const struct DONAU_EddsaPublicKeyP *donau_pub, const struct DONAUDB_SignkeyMetaData *meta) { struct PostgresClosure *pg = cls; diff --git a/src/donaudb/pg_activate_signing_key.h b/src/donaudb/pg_activate_signing_key.h @@ -36,7 +36,7 @@ enum GNUNET_DB_QueryStatus DH_PG_activate_signing_key ( void *cls, - const struct DONAU_DonauPublicKeyP *donau_pub, + const struct DONAU_EddsaPublicKeyP *donau_pub, const struct DONAUDB_SignkeyMetaData *meta); #endif diff --git a/src/donaudb/pg_lookup_signing_key.c b/src/donaudb/pg_lookup_signing_key.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus DH_PG_lookup_signing_key ( void *cls, - const struct DONAU_DonauPublicKeyP *donau_pub, + const struct DONAU_EddsaPublicKeyP *donau_pub, struct DONAUDB_SignkeyMetaData *meta) { struct PostgresClosure *pg = cls; diff --git a/src/donaudb/pg_lookup_signing_key.h b/src/donaudb/pg_lookup_signing_key.h @@ -37,7 +37,7 @@ enum GNUNET_DB_QueryStatus DH_PG_lookup_signing_key ( void *cls, - const struct DONAU_DonauPublicKeyP *donau_pub, + const struct DONAU_EddsaPublicKeyP *donau_pub, struct DONAUDB_SignkeyMetaData *meta); #endif diff --git a/src/include/donau_service.h b/src/include/donau_service.h @@ -14,7 +14,7 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ /** - * @file include/taler_donau_service.h + * @file include/donau_service.h * @brief C interface of libtalerdonau, a C library to use donau's HTTP API * @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Christian Grothoff diff --git a/src/include/donaudb_lib.h b/src/include/donaudb_lib.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with COPYING.If not, see <http: // www.gnu.org/licenses/> */ /** - *@file include/taler_donaudb_lib.h + *@file include/donaudb_lib.h * @brief IO operations for the donau's private keys * @author Florian Dold * @author Benedikt Mueller diff --git a/src/testing/testing_api_misc.c b/src/testing/testing_api_misc.c @@ -51,6 +51,7 @@ DONAU_TESTING_has_in_name (const char *prog, marker)); } + /** * Remove @a option directory from @a section in @a cfg. *