Line data Source code
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/taler-exchange-secmod-cs.c 18 : * @brief Standalone process to perform private key CS 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 thread 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 do the signing in parallel, one per client. 29 : * - thread-safety: signing happens in parallel, thus when REMOVING private keys, 30 : * we must ensure that all signers are done before we fully free() the 31 : * private key. This is done by reference counting (as work is always 32 : * assigned and collected by the main thread). 33 : */ 34 : #include "taler/platform.h" 35 : #include "taler/taler_util.h" 36 : 37 : /** 38 : * The entry point. 39 : * 40 : * @param argc number of arguments in @a argv 41 : * @param argv command-line arguments 42 : * @return 0 on normal termination 43 : */ 44 : int 45 20 : main (int argc, 46 : char **argv) 47 : { 48 20 : struct TALER_SECMOD_Options opts = { 49 : .max_workers = 16, 50 : .section = "taler-exchange" 51 : }; 52 20 : struct GNUNET_GETOPT_CommandLineOption options[] = { 53 20 : TALER_SECMOD_OPTIONS (&opts), 54 : GNUNET_GETOPT_OPTION_END 55 : }; 56 : enum GNUNET_GenericReturnValue ret; 57 : 58 : /* Restrict permissions for the key files that we create. */ 59 20 : (void) umask (S_IWGRP | S_IROTH | S_IWOTH | S_IXOTH); 60 : opts.global_now_tmp 61 20 : = opts.global_now 62 20 : = GNUNET_TIME_timestamp_get (); 63 20 : ret = GNUNET_PROGRAM_run (TALER_EXCHANGE_project_data (), 64 : argc, argv, 65 : "taler-exchange-secmod-cs", 66 : "Handle private CS key operations for a Taler exchange", 67 : options, 68 : &TALER_SECMOD_cs_run, 69 : &opts); 70 20 : if (GNUNET_NO == ret) 71 0 : return EXIT_SUCCESS; 72 20 : if (GNUNET_SYSERR == ret) 73 0 : return EXIT_INVALIDARGUMENT; 74 20 : return opts.global_ret; 75 : }