donau

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

donau-secmod-eddsa.c (3084B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014-2024 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file util/donau-secmod-eddsa.c
     18  * @brief Standalone process to perform private key EDDSA operations
     19  * @author Christian Grothoff
     20  *
     21  * Key design points:
     22  * - EVERY thread of the exchange will have its own pair of connections to the
     23  *   crypto helpers.  This way, every threat will also have its own /keys state
     24  *   and avoid the need to synchronize on those.
     25  * - auditor signatures and master signatures are to be kept in the exchange DB,
     26  *   and merged with the public keys of the helper by the exchange HTTPD!
     27  * - the main loop of the helper is SINGLE-THREADED, but there are
     28  *   threads for crypto-workers which (only) do the signing in parallel,
     29  *   one per client.
     30  * - thread-safety: signing happens in parallel, thus when REMOVING private keys,
     31  *   we must ensure that all signers are done before we fully free() the
     32  *   private key. This is done by reference counting (as work is always
     33  *   assigned and collected by the main thread).
     34  */
     35 #include "donau_config.h"
     36 #include <sys/stat.h>
     37 #include <taler/taler_util.h>
     38 #include "donau_util.h"
     39 
     40 /* LSB-style exit status codes */
     41 #ifndef EXIT_INVALIDARGUMENT
     42 /**
     43  * Command-line arguments are invalid.
     44  * Restarting useless.
     45  */
     46 #define EXIT_INVALIDARGUMENT 2
     47 #endif
     48 
     49 /**
     50  * The entry point.
     51  *
     52  * @param argc number of arguments in @a argv
     53  * @param argv command-line arguments
     54  * @return 0 on normal termination
     55  */
     56 int
     57 main (int argc,
     58       char **argv)
     59 {
     60   struct TALER_SECMOD_Options opts = {
     61     .max_workers = 16,
     62     .section = "donau"
     63   };
     64   struct GNUNET_GETOPT_CommandLineOption options[] = {
     65     TALER_SECMOD_OPTIONS (&opts),
     66     GNUNET_GETOPT_OPTION_END
     67   };
     68   enum GNUNET_GenericReturnValue ret;
     69 
     70   /* Restrict permissions for the key files that we create. */
     71   (void) umask (S_IWGRP | S_IROTH | S_IWOTH | S_IXOTH);
     72   opts.global_now_tmp
     73     = opts.global_now = GNUNET_TIME_timestamp_get ();
     74   ret = GNUNET_PROGRAM_run (DONAU_project_data (),
     75                             argc,
     76                             argv,
     77                             "donau-secmod-eddsa",
     78                             "Handle private EDDSA key operations for a Donau",
     79                             options,
     80                             &TALER_SECMOD_eddsa_run,
     81                             &opts);
     82   if (GNUNET_NO == ret)
     83     return EXIT_SUCCESS;
     84   if (GNUNET_SYSERR == ret)
     85     return EXIT_INVALIDARGUMENT;
     86   return opts.global_ret;
     87 }