diff options
Diffstat (limited to 'src/exchange-tools')
| -rw-r--r-- | src/exchange-tools/Makefile.am | 12 | ||||
| -rw-r--r-- | src/exchange-tools/auditor.conf | 12 | ||||
| -rw-r--r-- | src/exchange-tools/coins.conf | 25 | ||||
| -rw-r--r-- | src/exchange-tools/exchange-signkeys.conf | 16 | ||||
| -rw-r--r-- | src/exchange-tools/taler-auditor-sign.c | 47 | ||||
| -rw-r--r-- | src/exchange-tools/taler-exchange-dbinit.c | 46 | ||||
| -rw-r--r-- | src/exchange-tools/taler-exchange-keycheck.c | 42 | ||||
| -rw-r--r-- | src/exchange-tools/taler-exchange-keyup.c | 42 | ||||
| -rw-r--r-- | src/exchange-tools/taler-exchange-reservemod.c | 42 | ||||
| -rw-r--r-- | src/exchange-tools/taler-exchange-wire.c | 29 | 
10 files changed, 222 insertions, 91 deletions
| diff --git a/src/exchange-tools/Makefile.am b/src/exchange-tools/Makefile.am index feb3c314..d283979c 100644 --- a/src/exchange-tools/Makefile.am +++ b/src/exchange-tools/Makefile.am @@ -1,6 +1,14 @@  # This Makefile.am is in the public domain  AM_CPPFLAGS = -I$(top_srcdir)/src/include +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ +  auditor.conf \ +  exchange-signkeys.conf \ +  coins.conf + +  if USE_COVERAGE    AM_CFLAGS = --coverage -O0    XLIB = -lgcov @@ -81,3 +89,7 @@ taler_exchange_dbinit_CPPFLAGS = \    -I$(top_srcdir)/src/include \    -I$(top_srcdir)/src/pq/ \    $(POSTGRESQL_CPPFLAGS) + + +EXTRA_DIST = \ +  auditor.conf diff --git a/src/exchange-tools/auditor.conf b/src/exchange-tools/auditor.conf new file mode 100644 index 00000000..7eb5f8ae --- /dev/null +++ b/src/exchange-tools/auditor.conf @@ -0,0 +1,12 @@ +# This configuration file is in the public domain +# +# It cointains options for the auditor. + +[auditor] + +# Where do we store the auditor's private key? +AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv + +# What is the Web site of the auditor (i.e. to file complaints about +# a misbehaving exchange)? +# AUDITOR_URL = https://auditor.taler.net/ diff --git a/src/exchange-tools/coins.conf b/src/exchange-tools/coins.conf new file mode 100644 index 00000000..90bf7064 --- /dev/null +++ b/src/exchange-tools/coins.conf @@ -0,0 +1,25 @@ +# This configuration file is in the public domain +# +# This is a template file for coin definitions. There are no +# reasonable defaults, as legal and business concerns influence each +# value given. +# +# Note that while we only give one section here, you can define +# any number of coins by providing many "coin_" sections. +# +# Coin definitions are detected because the section name begins with +# "coin_".  The rest of the name is free, but of course following the +# convention of "coin_$CURRENCY[_$SUBUNIT]_$VALUE" make sense. +# +# [coin_eur_ct_1] + +# All options are mandatory! +# value = EUR:0.01 +# duration_overlap = 60 minutes +# duration_withdraw = 7 days +# duration_spend = 2 years +# duration_legal = 3 years +# fee_withdraw = EUR:0.00 +# fee_deposit = EUR:0.00 +# fee_refresh = EUR:0.01 +# rsa_keysize = 1024 diff --git a/src/exchange-tools/exchange-signkeys.conf b/src/exchange-tools/exchange-signkeys.conf new file mode 100644 index 00000000..3146f09b --- /dev/null +++ b/src/exchange-tools/exchange-signkeys.conf @@ -0,0 +1,16 @@ +# General data for signing keys. +[exchange_keys] + +# how long is one signkey valid? +signkey_duration = 4 weeks + +# how long are the signatures with the signkey valid? +legal_duration = 2 years + +# how long do we generate denomination and signing keys +# ahead of time? +lookahead_sign = 32 weeks 1 day + +# how long do we provide to clients denomination and signing keys +# ahead of time? +lookahead_provide = 4 weeks 1 day diff --git a/src/exchange-tools/taler-auditor-sign.c b/src/exchange-tools/taler-auditor-sign.c index 870f889e..d5a3a940 100644 --- a/src/exchange-tools/taler-auditor-sign.c +++ b/src/exchange-tools/taler-auditor-sign.c @@ -59,6 +59,11 @@ static char *auditor_url;   */  static struct TALER_MasterPublicKeyP master_public_key; +/** + * Our configuration. + */ +static struct GNUNET_CONFIGURATION_Handle *cfg; +  /**   * Print denomination key details for diagnostics. @@ -131,10 +136,12 @@ int  main (int argc,        char *const *argv)  { -  static const struct GNUNET_GETOPT_CommandLineOption options[] = { -    {'a', "auditor-key", "FILE", +  char *cfgfile = NULL; +  const struct GNUNET_GETOPT_CommandLineOption options[] = { +    {'a', "auditor-key", "FILENAME",       "file containing the private key of the auditor", 1,       &GNUNET_GETOPT_set_filename, &auditor_key_file}, +    GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),      GNUNET_GETOPT_OPTION_HELP ("Private key of the auditor to use for signing"),      {'m', "exchange-key", "KEY",       "public key of the exchange (Crockford base32 encoded)", 1, @@ -142,10 +149,10 @@ main (int argc,      {'u', "auditor-url", "URL",       "URL of the auditor (informative link for the user)", 1,       &GNUNET_GETOPT_set_string, &auditor_url}, -    {'r', "exchange-request", "FILE", +    {'r', "exchange-request", "FILENAME",       "set of keys the exchange requested the auditor to sign", 1,       &GNUNET_GETOPT_set_string, &exchange_request_file}, -    {'o', "output", "FILE", +    {'o', "output", "FILENAME",       "where to write our signature", 1,       &GNUNET_GETOPT_set_string, &output_file},      GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), @@ -163,20 +170,41 @@ main (int argc,    unsigned int i;    GNUNET_assert (GNUNET_OK == -                 GNUNET_log_setup ("taler-exchange-keyup", +                 GNUNET_log_setup ("taler-auditor-sign",                                     "WARNING",                                     NULL)); -  if (GNUNET_GETOPT_run ("taler-exchange-keyup", +  if (GNUNET_GETOPT_run ("taler-auditor-sign",                           options,                           argc, argv) < 0)      return 1; -  if (NULL == auditor_key_file) +  cfg = GNUNET_CONFIGURATION_create (); +  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, +                                                  cfgfile)) +  { +    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +                _("Malformed configuration file `%s', exit ...\n"), +                cfgfile); +    GNUNET_free_non_null (cfgfile); +    return 1; +  } +  GNUNET_free_non_null (cfgfile); +  if ( (NULL == auditor_key_file) && +       (GNUNET_OK != +        GNUNET_CONFIGURATION_get_value_filename (cfg, +                                                 "auditor", +                                                 "AUDITOR_PRIV_FILE", +                                                 &auditor_key_file)) )    {      fprintf (stderr, -             "Auditor key file not given\n"); +             "Auditor key file not given in neither configuration nor command-line\n");      return 1;    } -  if (NULL == auditor_url) +  if ( (NULL == auditor_url) && +       (GNUNET_OK != +        GNUNET_CONFIGURATION_get_value_string (cfg, +                                               "auditor", +                                               "AUDITOR_URL", +                                               &auditor_url)) )    {      fprintf (stderr,               "Auditor URL not given\n"); @@ -328,6 +356,7 @@ main (int argc,      GNUNET_free (dks);      return 1;    } +    GNUNET_free (sigs);    GNUNET_free (dks);    GNUNET_free (eddsa_priv); diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 43a07022..9f301854 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -20,24 +20,8 @@   */  #include "platform.h"  #include <gnunet/gnunet_util_lib.h> -#include <libpq-fe.h>  #include "taler_exchangedb_plugin.h" -/** - * Exchange directory with the keys. - */ -static char *exchange_base_dir; - -/** - * Our configuration. - */ -static struct GNUNET_CONFIGURATION_Handle *cfg; - -/** - * Our DB plugin. - */ -static struct TALER_EXCHANGEDB_Plugin *plugin; -  /**   * The main function of the database initialization tool. @@ -51,14 +35,15 @@ int  main (int argc,        char *const *argv)  { -  static const struct GNUNET_GETOPT_CommandLineOption options[] = { -    {'d', "exchange-dir", "DIR", -     "exchange directory", 1, -     &GNUNET_GETOPT_set_filename, &exchange_base_dir}, +  char *cfgfile = NULL; +  const struct GNUNET_GETOPT_CommandLineOption options[] = { +    GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),      GNUNET_GETOPT_OPTION_HELP ("Initialize Taler Exchange database"),      GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),      GNUNET_GETOPT_OPTION_END    }; +  struct GNUNET_CONFIGURATION_Handle *cfg; +  struct TALER_EXCHANGEDB_Plugin *plugin;    if (GNUNET_GETOPT_run ("taler-exchange-dbinit",                           options, @@ -69,24 +54,23 @@ main (int argc,                   GNUNET_log_setup ("taler-exchange-dbinit",                                     "INFO",                                     NULL)); -  if (NULL == exchange_base_dir) +  cfg = GNUNET_CONFIGURATION_create (); +  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, +                                                  cfgfile))    { -    fprintf (stderr, -             "Exchange base directory not given.\n"); -    return 1; -  } -  cfg = TALER_config_load (exchange_base_dir); -  if (NULL == cfg) -  { -    fprintf (stderr, -             "Failed to load exchange configuration.\n"); +    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +                _("Malformed configuration file `%s', exit ...\n"), +                cfgfile); +    GNUNET_free_non_null (cfgfile);      return 1;    } +  GNUNET_free_non_null (cfgfile);    if (NULL ==        (plugin = TALER_EXCHANGEDB_plugin_load (cfg)))    {      fprintf (stderr,               "Failed to initialize database plugin.\n"); +    GNUNET_CONFIGURATION_destroy (cfg);      return 1;    }    if (GNUNET_OK != @@ -96,9 +80,11 @@ main (int argc,      fprintf (stderr,               "Failed to initialize database.\n");      TALER_EXCHANGEDB_plugin_unload (plugin); +    GNUNET_CONFIGURATION_destroy (cfg);      return 1;    }    TALER_EXCHANGEDB_plugin_unload (plugin); +  GNUNET_CONFIGURATION_destroy (cfg);    return 0;  } diff --git a/src/exchange-tools/taler-exchange-keycheck.c b/src/exchange-tools/taler-exchange-keycheck.c index d6566cd0..064f2249 100644 --- a/src/exchange-tools/taler-exchange-keycheck.c +++ b/src/exchange-tools/taler-exchange-keycheck.c @@ -1,6 +1,6 @@  /*    This file is part of TALER -  Copyright (C) 2014, 2015 GNUnet e.V. +  Copyright (C) 2014, 2015, 2016 GNUnet e.V.    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 @@ -104,8 +104,8 @@ static int  exchange_signkeys_check ()  {    if (0 > TALER_EXCHANGEDB_signing_keys_iterate (exchange_directory, -                                       &signkeys_iter, -                                       NULL)) +                                                 &signkeys_iter, +                                                 NULL))      return GNUNET_NO;    return GNUNET_OK;  } @@ -186,8 +186,8 @@ static int  exchange_denomkeys_check ()  {    if (0 > TALER_EXCHANGEDB_denomination_keys_iterate (exchange_directory, -                                                  &denomkeys_iter, -                                                  NULL)) +                                                      &denomkeys_iter, +                                                      NULL))      return GNUNET_NO;    return GNUNET_OK;  } @@ -203,11 +203,10 @@ exchange_denomkeys_check ()  int  main (int argc, char *const *argv)  { -  static const struct GNUNET_GETOPT_CommandLineOption options[] = { +  char *cfgfile; +  const struct GNUNET_GETOPT_CommandLineOption options[] = { +    GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),      GNUNET_GETOPT_OPTION_HELP ("gnunet-exchange-keycheck OPTIONS"), -    {'d', "directory", "DIRECTORY", -     "exchange directory with keys to check", 1, -     &GNUNET_GETOPT_set_filename, &exchange_directory},      GNUNET_GETOPT_OPTION_END    }; @@ -220,20 +219,29 @@ main (int argc, char *const *argv)                           options,                           argc, argv) < 0)      return 1; -  if (NULL == exchange_directory) +  kcfg = GNUNET_CONFIGURATION_create (); +  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg, +                                                  cfgfile))    { -    fprintf (stderr, -             "Exchange directory not given\n"); +    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +                _("Malformed configuration file `%s', exit ...\n"), +                cfgfile); +    GNUNET_free_non_null (cfgfile);      return 1;    } - -  kcfg = TALER_config_load (exchange_directory); -  if (NULL == kcfg) +  GNUNET_free_non_null (cfgfile); +  if (GNUNET_OK != +      GNUNET_CONFIGURATION_get_value_filename (kcfg, +                                               "exchange", +                                               "KEYDIR", +                                               &exchange_directory))    { -    fprintf (stderr, -             "Failed to load exchange configuration\n"); +    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, +                               "exchange", +                               "KEYDIR");      return 1;    } +    if ( (GNUNET_OK != exchange_signkeys_check ()) ||         (GNUNET_OK != exchange_denomkeys_check ()) )    { diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index 3413dfb4..ab2123a1 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -1,6 +1,6 @@  /*    This file is part of TALER -  Copyright (C) 2014, 2015 GNUnet e.V. +  Copyright (C) 2014, 2015, 2016 GNUnet e.V.    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 @@ -876,10 +876,9 @@ int  main (int argc,        char *const *argv)  { -  static const struct GNUNET_GETOPT_CommandLineOption options[] = { -    {'d', "exchange-dir", "DIR", -     "exchange directory with keys to update", 1, -     &GNUNET_GETOPT_set_filename, &exchange_directory}, +  char *cfgfile = NULL; +  const struct GNUNET_GETOPT_CommandLineOption options[] = { +    GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),      GNUNET_GETOPT_OPTION_HELP ("Setup signing and denomination keys for a Taler exchange"),      {'m', "master-key", "FILE",       "master key file (private key)", 1, @@ -905,12 +904,17 @@ main (int argc,                           options,                           argc, argv) < 0)      return 1; -  if (NULL == exchange_directory) +  kcfg = GNUNET_CONFIGURATION_create (); +  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg, +                                                  cfgfile))    { -    fprintf (stderr, -             "Exchange directory not given\n"); +    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +                _("Malformed configuration file `%s', exit ...\n"), +                cfgfile); +    GNUNET_free_non_null (cfgfile);      return 1;    } +  GNUNET_free_non_null (cfgfile);    if (NULL != pretend_time_str)    {      if (GNUNET_OK != @@ -928,18 +932,26 @@ main (int argc,      now = GNUNET_TIME_absolute_get ();    }    GNUNET_TIME_round_abs (&now); - -  kcfg = TALER_config_load (exchange_directory); -  if (NULL == kcfg) +  if ( (NULL == masterkeyfile) && +       (GNUNET_OK != +        GNUNET_CONFIGURATION_get_value_filename (kcfg, +                                                 "exchange", +                                                 "MASTER_PRIV_FILE", +                                                 &masterkeyfile)) )    {      fprintf (stderr, -             "Failed to load exchange configuration\n"); +             "Master key file not given in neither configuration nor command-line\n");      return 1;    } -  if (NULL == masterkeyfile) +  if (GNUNET_OK != +      GNUNET_CONFIGURATION_get_value_filename (kcfg, +                                               "exchange", +                                               "KEYDIR", +                                               &exchange_directory))    { -    fprintf (stderr, -             "Master key file not given\n"); +    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, +                               "exchange", +                               "KEYDIR");      return 1;    }    eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); diff --git a/src/exchange-tools/taler-exchange-reservemod.c b/src/exchange-tools/taler-exchange-reservemod.c index 03a0d17d..3494e88a 100644 --- a/src/exchange-tools/taler-exchange-reservemod.c +++ b/src/exchange-tools/taler-exchange-reservemod.c @@ -51,6 +51,7 @@ static struct TALER_EXCHANGEDB_Plugin *plugin;  int  main (int argc, char *const *argv)  { +  char *cfgfile = NULL;    char *reserve_pub_str = NULL;    char *add_str = NULL;    struct TALER_Amount add_value; @@ -63,10 +64,8 @@ main (int argc, char *const *argv)      {'a', "add", "DENOM",       "value to add", 1,       &GNUNET_GETOPT_set_string, &add_str}, -    {'d', "exchange-dir", "DIR", -     "exchange directory with keys to update", 1, -     &GNUNET_GETOPT_set_filename, &exchange_directory}, -    {'D', "details", "JSON", +    GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), +    {'d', "details", "JSON",       "details about the bank transaction which justify why we add this amount", 1,       &GNUNET_GETOPT_set_string, &details},      GNUNET_GETOPT_OPTION_HELP ("Deposit funds into a Taler reserve"), @@ -87,10 +86,29 @@ main (int argc, char *const *argv)                           options,                           argc, argv) < 0)      return 1; -  if (NULL == exchange_directory) +  cfg = GNUNET_CONFIGURATION_create (); +  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, +                                                  cfgfile))    { -    fprintf (stderr, -             "Exchange directory not given\n"); +    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +                _("Malformed configuration file `%s', exit ...\n"), +                cfgfile); +    GNUNET_free_non_null (cfgfile); +    GNUNET_free_non_null (add_str); +    GNUNET_free_non_null (details); +    GNUNET_free_non_null (reserve_pub_str); +    return 1; +  } +  GNUNET_free_non_null (cfgfile); +  if (GNUNET_OK != +      GNUNET_CONFIGURATION_get_value_filename (cfg, +                                               "exchange", +                                               "KEYDIR", +                                               &exchange_directory)) +  { +    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, +                               "exchange", +                               "KEYDIR");      GNUNET_free_non_null (add_str);      GNUNET_free_non_null (details);      GNUNET_free_non_null (reserve_pub_str); @@ -133,16 +151,6 @@ main (int argc, char *const *argv)     return 1;    } -  cfg = TALER_config_load (exchange_directory); -  if (NULL == cfg) -  { -    fprintf (stderr, -             "Failed to load exchange configuration\n"); -    GNUNET_free_non_null (add_str); -    GNUNET_free_non_null (details); -    GNUNET_free_non_null (reserve_pub_str); -   return 1; -  }    ret = 1;    if (NULL ==        (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) diff --git a/src/exchange-tools/taler-exchange-wire.c b/src/exchange-tools/taler-exchange-wire.c index 5bb4835d..930086d3 100644 --- a/src/exchange-tools/taler-exchange-wire.c +++ b/src/exchange-tools/taler-exchange-wire.c @@ -46,6 +46,11 @@ static char *method;   */  static char *output_filename; +/** + * Our configuration. + */ +static struct GNUNET_CONFIGURATION_Handle *cfg; +  /**   * The main function of the taler-exchange-sepa tool.  This tool is used @@ -59,7 +64,9 @@ int  main (int argc,        char *const *argv)  { -  static const struct GNUNET_GETOPT_CommandLineOption options[] = { +  char *cfgfile = NULL; +  const struct GNUNET_GETOPT_CommandLineOption options[] = { +    GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),      {'j', "json", "JSON",       "account information in JSON format", 1,       &GNUNET_GETOPT_set_string, &json_in}, @@ -95,10 +102,26 @@ main (int argc,                           options,                           argc, argv) < 0)      return 1; -  if (NULL == masterkeyfile) +  cfg = GNUNET_CONFIGURATION_create (); +  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, +                                                  cfgfile)) +  { +    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +                _("Malformed configuration file `%s', exit ...\n"), +                cfgfile); +    GNUNET_free_non_null (cfgfile); +    return 1; +  } +  GNUNET_free_non_null (cfgfile); +  if ( (NULL == masterkeyfile) && +       (GNUNET_OK != +        GNUNET_CONFIGURATION_get_value_filename (cfg, +                                                 "exchange-master", +                                                 "MASTER_PRIV_FILE", +                                                 &masterkeyfile)) )    {      fprintf (stderr, -             "Master key file not given\n"); +             "Master key file not given in neither configuration nor command-line\n");      return 1;    }    eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); | 
