From 2c6956f32acc6a9f0c65bc8aac4713d0e3a88928 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 14 Jul 2017 17:43:07 +0200 Subject: clean up PQ tables (renamings, remove redunant column), and primarily fix #4751 --- src/auditor/taler-auditor-sign.c | 64 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) (limited to 'src/auditor/taler-auditor-sign.c') diff --git a/src/auditor/taler-auditor-sign.c b/src/auditor/taler-auditor-sign.c index d1a205b3d..5494cd2f5 100644 --- a/src/auditor/taler-auditor-sign.c +++ b/src/auditor/taler-auditor-sign.c @@ -21,6 +21,7 @@ */ #include #include "taler_exchangedb_lib.h" +#include "taler_auditordb_lib.h" /** @@ -59,6 +60,11 @@ static struct TALER_MasterPublicKeyP master_public_key; */ static struct GNUNET_CONFIGURATION_Handle *cfg; +/** + * Handle to access the auditor's database. + */ +static struct TALER_AUDITORDB_Plugin *adb; + /** * Print denomination key details for diagnostics. @@ -180,7 +186,6 @@ main (int argc, unsigned int dks_len; struct TALER_ExchangeKeyValidityPS kv; off_t in_size; - unsigned int i; GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-auditor-sign", @@ -223,7 +228,8 @@ main (int argc, "Auditor URL not given in neither configuration nor command-line\n"); return 1; } - if (GNUNET_YES != GNUNET_DISK_file_test (auditor_key_file)) + if (GNUNET_YES != + GNUNET_DISK_file_test (auditor_key_file)) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Auditor private key `%s' does not exist yet, creating it!\n", auditor_key_file); @@ -277,9 +283,18 @@ main (int argc, "Denomination list has length zero, signature not produced.\n"); GNUNET_DISK_file_close (fh); GNUNET_free (eddsa_priv); - return 2; - + return 2; + } + if (NULL == + (adb = TALER_AUDITORDB_plugin_load (cfg))) + { + fprintf (stderr, + "Failed to initialize auditor database plugin.\n"); + GNUNET_DISK_file_close (fh); + GNUNET_free (eddsa_priv); + return 3; } + kv.purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS); kv.purpose.size = htonl (sizeof (struct TALER_ExchangeKeyValidityPS)); GNUNET_CRYPTO_hash (auditor_url, @@ -299,6 +314,7 @@ main (int argc, "Failed to read input file `%s': %s\n", exchange_request_file, STRERROR (errno)); + TALER_AUDITORDB_plugin_unload (adb); GNUNET_DISK_file_close (fh); GNUNET_free (sigs); GNUNET_free (dks); @@ -306,7 +322,7 @@ main (int argc, return 1; } GNUNET_DISK_file_close (fh); - for (i=0;iget_session (adb->cls); + if (NULL == session) + { + fprintf (stderr, + "Failed to initialize database session\n"); + TALER_AUDITORDB_plugin_unload (adb); + GNUNET_free (dks); + GNUNET_free (sigs); + GNUNET_free (eddsa_priv); + return 3; + } + for (unsigned int i=0;iinsert_denomination_info (adb->cls, + session, + dk); + if (0 > qs) + { + fprintf (stderr, + "Failed to store key in auditor DB\n"); + TALER_AUDITORDB_plugin_unload (adb); + GNUNET_free (dks); + GNUNET_free (sigs); + GNUNET_free (eddsa_priv); + return 3; + } + } + } + TALER_AUDITORDB_plugin_unload (adb); /* write result to disk */ if (GNUNET_OK != @@ -357,7 +410,6 @@ main (int argc, GNUNET_free (dks); return 1; } - GNUNET_free (sigs); GNUNET_free (dks); GNUNET_free (eddsa_priv); -- cgit v1.2.3