donau

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

commit 3395dca930d297b1949c71e28ac696bc8e9164f5
parent 4fc8dc919a1b0758080549367d581143cf373ca2
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Thu, 11 Jan 2024 16:55:24 +0100

[lib] revise key decode and encode

Diffstat:
Msrc/include/donau_crypto_lib.h | 11-----------
Msrc/include/donau_json_lib.h | 12++++++++++++
Msrc/json/donau_json.c | 15+++++++++++++++
Msrc/lib/donau_api_handle.c | 44++++++++++++++++++--------------------------
Msrc/testing/Makefile.am | 3---
Dsrc/testing/donau-unified-setup.sh | 871-------------------------------------------------------------------------------
Msrc/util/donau_crypto.c | 2+-
7 files changed, 46 insertions(+), 912 deletions(-)

diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -368,16 +368,5 @@ struct TALER_DonauBatchIssueValues struct GNUNET_CRYPTO_BlindingInputValues *blinding_inputs; }; -/** - * Compute a unique key for the meta data of a donation unit group. - * - * @param dg donation unit group to evaluate - * @param[out] key key to set - */ -void -TALER_donation_unit_group_get_key ( - const struct DONAU_DonationUnitGroup *dg, - struct GNUNET_HashCode *key); - #endif diff --git a/src/include/donau_json_lib.h b/src/include/donau_json_lib.h @@ -59,4 +59,16 @@ DONAU_JSON_spec_donation_unit_group (const char *field, const char *currency, struct DONAU_DonationUnitGroup *group); +/** + * Generate packer instruction for a JSON field of type + * unsigned integer. + * + * @param name name of the field to add to the object + * @param num numeric value + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +DONAU_JSON_pack_uint32 (const char *name, + uint64_t num); + #endif \ No newline at end of file diff --git a/src/json/donau_json.c b/src/json/donau_json.c @@ -24,6 +24,7 @@ #include "taler/taler_json_lib.h" #include <unistr.h> #include "donau_json_lib.h" +# /** * Parse given JSON object partially into a donation unit public key. @@ -212,4 +213,18 @@ DONAU_JSON_spec_donation_unit_group (const char *name, }; return ret; +} + +struct GNUNET_JSON_PackSpec +DONAU_JSON_pack_uint32 (const char *name, + uint32_t num) +{ + struct GNUNET_JSON_PackSpec ps = { + .field_name = name, + .object = json_integer ((json_int_t) num) + }; + + GNUNET_assert (num <= ULONG_MAX); + + return ps; } \ No newline at end of file diff --git a/src/lib/donau_api_handle.c b/src/lib/donau_api_handle.c @@ -24,18 +24,11 @@ * @author Christian Grothoff * @author Lukas Matyja */ -#include "taler/platform.h" -#include <microhttpd.h> #include <gnunet/gnunet_curl_lib.h> #include "taler/taler_json_lib.h" #include "donau_service.h" -#include "taler/taler_signatures.h" #include "donau_api_curl_defaults.h" -#include "taler/taler_curl_lib.h" -#include <gnunet/gnunet_util_lib.h> #include "donau_json_lib.h" -#include "taler/taler_util.h" -#include "taler/taler_curl_lib.h" /** * Which version of the Donau protocol is implemented @@ -144,7 +137,7 @@ parse_json_signkey (struct DONAU_SigningPublicKeyAndValidity *sign_key, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("key", &sign_key->key), - GNUNET_JSON_spec_uint32 ("year_of_validity", + GNUNET_JSON_spec_uint32 ("year", &sign_key->year), GNUNET_JSON_spec_end () }; @@ -206,7 +199,6 @@ decode_keys_json (const json_t *resp_obj, struct DONAU_Keys *key_data, enum DONAU_VersionCompatibility *vc) { - //struct DONAU_SigningPublicKeyAndValidity donau_pub; const json_t *sign_keys_array; const json_t *donation_units_by_group; @@ -270,17 +262,14 @@ decode_keys_json (const json_t *resp_obj, { const char *currency; struct GNUNET_JSON_Specification mspec[] = { - // GNUNET_JSON_spec_fixed_auto ( // already in signkeys? - // "donau_pub", - // &donau_pub), GNUNET_JSON_spec_array_const ( - "signkeys", // naming convention? + "sign_keys", // naming convention? &sign_keys_array), GNUNET_JSON_spec_string ( "currency", &currency), //&key_data->currency instead? GNUNET_JSON_spec_array_const ( - "donation_units", + "donation_units_group", &donation_units_by_group), GNUNET_JSON_spec_end () }; @@ -336,8 +325,7 @@ decode_keys_json (const json_t *resp_obj, } /* - * Parse the donation unit keys, merging with the - * possibly EXISTING array as required (/keys cherry picking). + * Parse the donation unit keys * * The donation units are grouped by common values of * {cipher, value}. @@ -349,7 +337,7 @@ decode_keys_json (const json_t *resp_obj, json_array_foreach (donation_units_by_group, group_idx, group_obj) { - /* First, parse { cipher, value, hash } of the current + /* First, parse { cipher, value} of the current group. */ struct DONAU_DonationUnitGroup group = {0}; // what must be given to be a part of a group? const json_t *donation_unit_keys_array; @@ -385,6 +373,7 @@ decode_keys_json (const json_t *resp_obj, bool found = false; struct GNUNET_JSON_Specification kspec[] = { + GNUNET_JSON_spec_uint32("year", &dk.year), // DONAU_JSON_spec_donation_unit_pub_cipher (NULL, // group.cipher, // &dk->key), @@ -414,7 +403,6 @@ decode_keys_json (const json_t *resp_obj, if (found) { - /* 0:0:0 did not support /keys cherry picking */ TALER_LOG_DEBUG ("Skipping donation unit key: already know it\n"); DONAU_donation_unit_pub_free (&dk.key); continue; @@ -426,7 +414,6 @@ decode_keys_json (const json_t *resp_obj, key_data->donation_unit_keys_size * 2 + 2); key_data->donation_unit_keys[key_data->num_donation_unit_keys++] = dk; - /* Update "last_denom_issue_date" */ TALER_LOG_DEBUG ("Adding donation unit key that is valid for the year %d\n", dk.year); @@ -864,9 +851,9 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) signkey = GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("key", - &sk->key)); - // GNUNET_JSON_pack_uint32 ("year", - // &sk->year)); + &sk->key), + GNUNET_JSON_pack_uint64 ("year", + sk->year)); GNUNET_assert (NULL != signkey); GNUNET_assert (0 == json_array_append_new (signkeys, @@ -878,7 +865,7 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) { struct GNUNET_CONTAINER_MultiHashMap *dbg; - dbg = GNUNET_CONTAINER_multihashmap_create (128, // why 128 and why do we need a multihashmap (remove doubles?), why are the timestamps not included? + dbg = GNUNET_CONTAINER_multihashmap_create (128, // why 128?? false); for (unsigned int i = 0; i<kd->num_donation_unit_keys; i++) { @@ -886,17 +873,20 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) struct DONAU_DonationUnitGroup meta = { .cipher = dk->key.bsign_pub_key->cipher, .value = dk->value - //.year = dk->year ?? }; struct GNUNET_HashCode key; struct GroupData *gd; json_t *donation_unit; struct GNUNET_JSON_PackSpec key_spec; + // get hash of meta data DONAU_donation_unit_group_get_key (&meta, &key); gd = GNUNET_CONTAINER_multihashmap_get (dbg, &key); + + // If group (differentiated in value and cipher) does not exist + // add a new one to the map. if (NULL == gd) { gd = GNUNET_new (struct GroupData); @@ -935,10 +925,12 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) dk->year), key_spec ); + // add entry into the donation unit group GNUNET_assert (0 == json_array_append_new (gd->json, donation_unit)); } + // every donation unit group of the map is added to the array donation_units_by_group GNUNET_CONTAINER_multihashmap_iterate (dbg, &add_grp, donation_units_by_group); @@ -953,9 +945,9 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) GNUNET_JSON_pack_object_steal ("currency_specification", TALER_CONFIG_currency_specs_to_json ( &kd->currency_specification)), - GNUNET_JSON_pack_array_steal ("signkeys", + GNUNET_JSON_pack_array_steal ("sign_keys", signkeys), - GNUNET_JSON_pack_array_steal ("donation_units", + GNUNET_JSON_pack_array_steal ("donation_units_group", donation_units_by_group) ); return GNUNET_JSON_PACK ( diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am @@ -13,9 +13,6 @@ endif clean-local: rm -rf report* -bin_SCRIPTS = \ - donau-unified-setup.sh - lib_LTLIBRARIES = \ libdonautesting.la diff --git a/src/testing/donau-unified-setup.sh b/src/testing/donau-unified-setup.sh @@ -1,871 +0,0 @@ -#!/bin/bash -# -# This file is part of TALER -# Copyright (C) 2023 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 -# MERCHANTABILITY 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/> -# -# Author: Christian Grothoff -# -# This script configures and launches various GNU Taler services. -# Which ones depend on command-line options. Use "-h" to find out. -# Prints "<<READY>>" on a separate line once all requested services -# are running. Close STDIN (or input 'NEWLINE') to stop all started -# services again. -# -# shellcheck disable=SC2317 - -set -eu - -EXIT_STATUS=2 - -# Exit, with status code "skip" (no 'real' failure) -function exit_skip() { - echo " SKIP: " "$@" >&2 - EXIT_STATUS=77 - exit "$EXIT_STATUS" -} - -# Exit, with error message (hard failure) -function exit_fail() { - echo " FAIL: " "$@" >&2 - EXIT_STATUS=1 - exit "$EXIT_STATUS" -} - -# Cleanup to run whenever we exit -function cleanup() -{ - echo "Taler unified setup terminating!" >&2 - - for n in $(jobs -p) - do - kill "$n" 2> /dev/null || true - done - wait - rm -f libeufin-nexus.pid libeufin-sandbox.pid - exit "$EXIT_STATUS" -} - -# Install cleanup handler (except for kill -9) -trap cleanup EXIT - -WAIT_FOR_SIGNAL=0 -START_AUDITOR=0 -START_BACKUP=0 -START_EXCHANGE=0 -START_FAKEBANK=0 -START_DONAU=0 -START_CHALLENGER=0 -START_AGGREGATOR=0 -START_MERCHANT=0 -START_NEXUS=0 -START_BANK=0 -START_TRANSFER=0 -START_WIREWATCH=0 -USE_ACCOUNT="exchange-account-1" -USE_VALGRIND="" -WIRE_DOMAIN="x-taler-bank" -CONF_ORIG="$HOME/.config/donau.conf" -LOGLEVEL="DEBUG" -DEFAULT_SLEEP="0.2" - -# Parse command-line options -while getopts ':abc:d:efghkL:mnr:stu:vwWD' OPTION; do - case "$OPTION" in - a) - START_AUDITOR="1" - ;; - b) - START_BANK="1" - ;; - c) - CONF_ORIG="$OPTARG" - ;; - d) - WIRE_DOMAIN="$OPTARG" - ;; - D) - START_DONAU="1" - ;; - e) - START_EXCHANGE="1" - ;; - f) - START_FAKEBANK="1" - ;; - h) - echo 'Supported options:' - echo ' -a -- start auditor' - echo ' -b -- start bank' - # shellcheck disable=SC2016 - echo ' -c $CONF -- set configuration' - # shellcheck disable=SC2016 - echo ' -d $METHOD -- use wire method (default: x-taler-bank)' - echo ' -D -- start donau' - echo ' -e -- start exchange' - echo ' -f -- start fakebank' - echo ' -g -- start aggregator' - echo ' -h -- print this help' - # shellcheck disable=SC2016 - echo ' -L $LOGLEVEL -- set log level' - echo ' -m -- start merchant' - echo ' -n -- start nexus' - # shellcheck disable=SC2016 - echo ' -r $MEX -- which exchange to use at the merchant (optional)' - echo ' -s -- start backup/sync' - echo ' -t -- start transfer' - # shellcheck disable=SC2016 - echo ' -u $SECTION -- exchange account to use' - echo ' -v -- use valgrind' - echo ' -w -- start wirewatch' - exit 0 - ;; - g) - START_AGGREGATOR="1" - ;; - k) - START_CHALLENGER="1" - ;; - L) - LOGLEVEL="$OPTARG" - ;; - m) - START_MERCHANT="1" - ;; - n) - START_NEXUS="1" - ;; - r) - USE_MERCHANT_EXCHANGE="$OPTARG" - ;; - s) - START_BACKUP="1" - ;; - t) - START_TRANSFER="1" - ;; - u) - USE_ACCOUNT="$OPTARG" - ;; - v) - USE_VALGRIND="valgrind --leak-check=yes" - DEFAULT_SLEEP="2" - ;; - w) - START_WIREWATCH="1" - ;; - W) - WAIT_FOR_SIGNAL="1" - ;; - ?) - exit_fail "Unrecognized command line option" - ;; - esac -done - -echo "Starting with configuration file at: $CONF_ORIG" -CONF="$CONF_ORIG.edited" -cp "${CONF_ORIG}" "${CONF}" - -echo -n "Testing for jq" -jq -h > /dev/null || exit_skip " jq required" -echo " FOUND" - -if [ "1" = "$START_EXCHANGE" ] -then - echo -n "Testing for Taler exchange" - taler-exchange-httpd -h > /dev/null || exit_skip " taler-exchange-httpd required" - echo " FOUND" -fi - -if [ "1" = "$START_DONAU" ] -then - echo -n "Testing for Donau" - donau-httpd -h > /dev/null || exit_skip " donau-httpd required" - echo " FOUND" -fi - -if [ "1" = "$START_MERCHANT" ] -then - echo -n "Testing for Taler merchant" - taler-merchant-httpd -h > /dev/null || exit_skip " taler-merchant-httpd required" - echo " FOUND" -fi - -if [ "1" = "$START_CHALLENGER" ] -then - echo -n "Testing for Taler challenger" - challenger-httpd -h > /dev/null || exit_skip " challenger-httpd required" - echo " FOUND" -fi - -if [ "1" = "$START_BACKUP" ] -then - echo -n "Testing for sync-httpd" - sync-httpd -h > /dev/null || exit_skip " sync-httpd required" - echo " FOUND" -fi - -if [ "1" = "$START_NEXUS" ] -then - echo -n "Testing for libeufin-cli" - libeufin-cli --help >/dev/null </dev/null || exit_skip " MISSING" - echo " FOUND" -fi - -DONAU_URL=$(donau-config -c "$CONF" -s "DONAU" -o "BASE_URL") -EXCHANGE_URL=$(taler-config -c "$CONF" -s "EXCHANGE" -o "BASE_URL") -CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY") - -echo "Setting up for $CURRENCY at $EXCHANGE_URL" - -register_bank_account() { - wget \ - --http-user="$AUSER" \ - --http-password="$APASS" \ - --method=DELETE \ - -o /dev/null \ - -O /dev/null \ - -a wget-delete-account.log \ - "http://localhost:${BANK_PORT}/accounts/$1" \ - || true # deletion may fail, that's OK! - if [ "$1" = "exchange" ] || [ "$1" = "Exchange" ] - then - IS_EXCHANGE="true" - else - IS_EXCHANGE="false" - fi - MAYBE_IBAN="${4:-}" - if test -n "$MAYBE_IBAN"; - then - # shellcheck disable=SC2001 - ENAME=$(echo "$3" | sed -e "s/ /+/g") - # Note: this assumes that $3 has no spaces. Should probably escape in the future.. - PAYTO="payto://iban/SANDBOXX/${MAYBE_IBAN}?receiver-name=$ENAME" - BODY='{"username":"'"$1"'","password":"'"$2"'","is_taler_exchange":'"$IS_EXCHANGE"',"name":"'"$3"'","internal_payto_uri":"'"$PAYTO"'"}' - else - BODY='{"username":"'"$1"'","password":"'"$2"'","is_taler_exchange":'"$IS_EXCHANGE"',"name":"'"$3"'"}' - fi - wget \ - --http-user="$AUSER" \ - --http-password="$APASS" \ - --method=POST \ - --header='Content-type: application/json' \ - --body-data="${BODY}" \ - --content-on-error \ - -a wget-register-account.log \ - -o /dev/null \ - -O /dev/null \ - "http://localhost:${BANK_PORT}/accounts" -} - -register_fakebank_account() { - if [ "$1" = "exchange" ] || [ "$1" = "Exchange" ] - then - IS_EXCHANGE="true" - else - IS_EXCHANGE="false" - fi - BODY='{"username":"'"$1"'","password":"'"$2"'","name":"'"$1"'","is_taler_exchange":'"$IS_EXCHANGE"'}' - wget \ - --post-data="$BODY" \ - --header='Content-type: application/json' \ - --tries=3 \ - --waitretry=1 \ - --timeout=30 \ - "http://localhost:$BANK_PORT/accounts" \ - -a wget-register-account.log \ - -o /dev/null \ - -O /dev/null \ - >/dev/null -} - - -if [[ "1" = "$START_BANK" || "1" = "$START_FAKEBANK" ]] -then - BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT") - BANK_URL="http://localhost:${BANK_PORT}/" -fi - -if [ "1" = "$START_BANK" ] -then - echo -n "Setting up bank database ... " - libeufin-bank dbinit \ - -r \ - -c "$CONF" \ - &> libeufin-bank-reset.log - echo "DONE" - echo -n "Launching bank ... " - libeufin-bank serve \ - -c "$CONF" \ - > libeufin-bank-stdout.log \ - 2> libeufin-bank-stderr.log & - echo $! > libeufin-bank.pid - echo "DONE" - echo -n "Waiting for Bank ..." - OK="0" - for n in $(seq 1 100); do - echo -n "." - sleep "$DEFAULT_SLEEP" - wget --timeout=1 \ - --tries=3 \ - --waitretry=0 \ - -o /dev/null \ - -O /dev/null \ - "$BANK_URL/config" || continue - OK="1" - break - done - if [ "1" != "$OK" ] - then - exit_skip "Failed to launch services (bank)" - fi - echo "OK" - echo -n "Set admin password..." - AUSER="admin" - APASS="secret" - libeufin-bank \ - passwd \ - -c "$CONF" \ - "$AUSER" "$APASS" \ - &> libeufin-bank-passwd.log - libeufin-bank \ - edit-account \ - -c "$CONF" \ - --debit_threshold="$CURRENCY:1000000" \ - "$AUSER" \ - &> libeufin-bank-debit-threshold.log - echo " OK" -fi - -if [ "1" = "$START_NEXUS" ] -then - echo "Nexus currently not supported ..." -fi - -if [ "1" = "$START_FAKEBANK" ] -then - echo -n "Setting up fakebank ..." - $USE_VALGRIND taler-fakebank-run \ - -c "$CONF" \ - -L "$LOGLEVEL" \ - -n 4 \ - 2> taler-fakebank-run.log & - echo " OK" -fi - -if [[ "1" = "$START_NEXUS" || "1" = "$START_FAKEBANK" ]] -then - echo -n "Waiting for the bank" - # Wait for bank to be available (usually the slowest) - OK="0" - for n in $(seq 1 300) - do - echo -n "." - sleep "$DEFAULT_SLEEP" - # bank - wget --tries=1 \ - --waitretry=0 \ - --timeout=1 \ - --user admin \ - --password secret \ - "http://localhost:${BANK_PORT}/" \ - -o /dev/null \ - -O /dev/null >/dev/null || continue - OK="1" - break - done - if [ "1" != "$OK" ] - then - exit_skip "Failed to launch services (bank)" - fi - echo " OK" -fi - -if [ "1" = "$START_FAKEBANK" ] -then - echo -n "Register Fakebank users ..." - register_fakebank_account fortytwo x - register_fakebank_account fortythree x - register_fakebank_account exchange x - register_fakebank_account tor x - register_fakebank_account gnunet x - register_fakebank_account tutorial x - register_fakebank_account survey x - echo " DONE" -fi - -if [ "1" = "$START_BANK" ] -then - echo -n "Register bank users ..." - # The specified IBAN and name must match the ones hard-coded into - # the C helper for the add-incoming call. Without this value, - # libeufin-bank won't find the target account to debit along a /add-incoming - # call. - register_bank_account fortytwo x "User42" FR7630006000011234567890189 - register_bank_account fortythree x "Forty Three" - register_bank_account exchange x "Exchange Company" DE989651 - register_bank_account tor x "Tor Project" - register_bank_account gnunet x "GNUnet" - register_bank_account tutorial x "Tutorial" - register_bank_account survey x "Survey" - echo " DONE" -fi - -if [ "1" = "$START_EXCHANGE" ] -then - echo -n "Starting exchange ..." - EXCHANGE_PORT=$(taler-config -c "$CONF" -s EXCHANGE -o PORT) - SERVE=$(taler-config -c "$CONF" -s EXCHANGE -o SERVE) - if [ "${SERVE}" = "unix" ] - then - EXCHANGE_URL=$(taler-config -c "$CONF" -s EXCHANGE -o BASE_URL) - else - EXCHANGE_URL="http://localhost:${EXCHANGE_PORT}/" - fi - MASTER_PRIV_FILE=$(taler-config -f -c "${CONF}" -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE") - MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE") - mkdir -p "${MASTER_PRIV_DIR}" - if [ ! -e "$MASTER_PRIV_FILE" ] - then - gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null 2> /dev/null - echo -n "." - fi - MASTER_PUB=$(gnunet-ecc -p "${MASTER_PRIV_FILE}") - MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY) - if [ "$MPUB" != "$MASTER_PUB" ] - then - echo -n " patching master_pub ($MASTER_PUB)..." - taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB" - fi - taler-exchange-dbinit -c "$CONF" --reset - $USE_VALGRIND taler-exchange-secmod-eddsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-eddsa.log & - $USE_VALGRIND taler-exchange-secmod-rsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-rsa.log & - $USE_VALGRIND taler-exchange-secmod-cs -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-cs.log & - $USE_VALGRIND taler-exchange-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-httpd.log & - echo " DONE" -fi - -if [ "1" = "$START_DONAU" ] -then - echo -n "Starting Donau ..." - DONAU_PORT=$(donau-config -c "$CONF" -s DONAU -o PORT) - SERVE=$(donau-config -c "$CONF" -s DONAU -o SERVE) - if [ "${SERVE}" = "unix" ] - then - DONAU_URL=$(donau-config -c "$CONF" -s DONAU -o BASE_URL) - else - DONAU_URL="http://localhost:${DONAU_PORT}/" - fi - donau-dbinit -c "$CONF" --reset - $USE_VALGRIND taler-secmod-eddsa -c "$CONF" -L "$LOGLEVEL" -s donau 2> donau-secmod-eddsa.log & - $USE_VALGRIND taler-secmod-rsa -c "$CONF" -L "$LOGLEVEL" -s donau 2> donau-secmod-rsa.log & - $USE_VALGRIND taler-secmod-cs -c "$CONF" -L "$LOGLEVEL" -s donau 2> donau-secmod-cs.log & - $USE_VALGRIND donau-httpd -c "$CONF" -L "$LOGLEVEL" 2> donau-httpd.log & - echo " DONE" -fi - -if [ "1" = "$START_WIREWATCH" ] -then - echo -n "Starting wirewatch ..." - $USE_VALGRIND taler-exchange-wirewatch \ - --account="$USE_ACCOUNT" \ - -c "$CONF" \ - --longpoll-timeout="1 s" \ - 2> taler-exchange-wirewatch.log & - echo " DONE" -fi - -if [ "1" = "$START_AGGREGATOR" ] -then - echo -n "Starting aggregator ..." - $USE_VALGRIND taler-exchange-aggregator -c "$CONF" 2> taler-exchange-aggregator.log & - echo " DONE" -fi - -if [ "1" = "$START_TRANSFER" ] -then - echo -n "Starting transfer ..." - $USE_VALGRIND taler-exchange-transfer -c "$CONF" 2> taler-exchange-transfer.log & - echo " DONE" -fi - -if [ "1" = "$START_MERCHANT" ] -then - echo -n "Starting merchant ..." - if [ -n "${USE_MERCHANT_EXCHANGE+x}" ] - then - MEPUB=$(taler-config -c "$CONF" -s "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY) - MXPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)} - if [ "$MEPUB" != "$MXPUB" ] - then - echo -n " patching master_pub ($MXPUB)..." - taler-config -c "$CONF" -s "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY -V "$MXPUB" - fi - fi - MERCHANT_TYPE=$(taler-config -c "$CONF" -s MERCHANT -o SERVE) - if [ "unix" = "$MERCHANT_TYPE" ] - then - MERCHANT_URL="$(taler-config -c "$CONF" -s MERCHANT -o BASE_URL)" - else - MERCHANT_PORT="$(taler-config -c "$CONF" -s MERCHANT -o PORT)" - MERCHANT_URL="http://localhost:${MERCHANT_PORT}/" - fi - taler-merchant-dbinit -c "$CONF" -L "$LOGLEVEL" --reset &> taler-merchant-dbinit.log - $USE_VALGRIND taler-merchant-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-httpd.log & - $USE_VALGRIND taler-merchant-webhook -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-webhook.log & - echo " DONE" -fi - -if [ "1" = "$START_BACKUP" ] -then - echo -n "Starting sync ..." - SYNC_PORT=$(taler-config -c "$CONF" -s SYNC -o PORT) - SERVE=$(taler-config -c "$CONF" -s SYNC -o SERVE) - if [ "${SERVE}" = "unix" ] - then - SYNC_URL=$(taler-config -c "$CONF" -s SYNC -o BASE_URL) - else - SYNC_URL="http://localhost:${SYNC_PORT}/" - fi - sync-dbinit -c "$CONF" --reset - $USE_VALGRIND sync-httpd -c "$CONF" -L "$LOGLEVEL" 2> sync-httpd.log & - echo " DONE" -fi - -if [ "1" = "$START_CHALLENGER" ] -then - echo -n "Starting challenger ..." - CHALLENGER_PORT=$(challenger-config -c "$CONF" -s CHALLENGER -o PORT) - SERVE=$(taler-config -c "$CONF" -s CHALLENGER -o SERVE) - if [ "${SERVE}" = "unix" ] - then - CHALLENGER_URL=$(taler-config -c "$CONF" -s CHALLENGER -o BASE_URL) - else - CHALLENGER_URL="http://localhost:${CHALLENGER_PORT}/" - fi - challenger-dbinit -c "$CONF" --reset - $USE_VALGRIND challenger-httpd -c "$CONF" -L "$LOGLEVEL" 2> challenger-httpd.log & - echo " DONE" - for SECTION in $(taler-config -c "$CONF" -S | grep kyc-provider) - do - LOGIC=$(taler-config -c "$CONF" -s "$SECTION" -o "LOGIC") - if [ "${LOGIC}" = "oauth2" ] - then - INFO=$(taler-config -c "$CONF" -s "$SECTION" -o "KYC_OAUTH2_INFO_URL") - if [ "${CHALLENGER_URL}info" = "$INFO" ] - then - echo -n "Enabling Challenger client for $SECTION" - CLIENT_SECRET=$(taler-config -c "$CONF" -s "$SECTION" -o "KYC_OAUTH2_CLIENT_SECRET") - RFC_8959_PREFIX="secret-token:" - if ! echo "${CLIENT_SECRET}" | grep ^${RFC_8959_PREFIX} > /dev/null - then - exit_fail "Client secret does not begin with '${RFC_8959_PREFIX}'" - fi - REDIRECT_URI="${EXCHANGE_URL}kyc-proof/kyc-provider-example-challeger" - CLIENT_ID=$(challenger-admin --add="${CLIENT_SECRET}" --quiet "${REDIRECT_URI}") - taler-config -c "$CONF" -s "$SECTION" -o KYC_OAUTH2_CLIENT_ID -V "$CLIENT_ID" - echo " DONE" - fi - fi - done -fi - - -if [ "1" = "$START_AUDITOR" ] -then - echo -n "Starting auditor ..." - AUDITOR_URL=$(taler-config -c "$CONF" -s AUDITOR -o BASE_URL) - AUDITOR_PRIV_FILE=$(taler-config -f -c "$CONF" -s AUDITOR -o AUDITOR_PRIV_FILE) - AUDITOR_PRIV_DIR=$(dirname "$AUDITOR_PRIV_FILE") - mkdir -p "$AUDITOR_PRIV_DIR" - if [ ! -e "$AUDITOR_PRIV_FILE" ] - then - gnunet-ecc -g1 "$AUDITOR_PRIV_FILE" > /dev/null 2> /dev/null - echo -n "." - fi - AUDITOR_PUB=$(gnunet-ecc -p "${AUDITOR_PRIV_FILE}") - MAPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)} - taler-auditor-dbinit -c "$CONF" --reset - taler-auditor-exchange -c "$CONF" -m "$MAPUB" -u "$EXCHANGE_URL" - $USE_VALGRIND taler-auditor-httpd -L "$LOGLEVEL" -c "$CONF" 2> taler-auditor-httpd.log & - echo " DONE" -fi - - -echo -n "Waiting for Taler services ..." -# Wait for all other taler services to be available -E_DONE=0 -D_DONE=0 -M_DONE=0 -S_DONE=0 -K_DONE=0 -A_DONE=0 -for n in $(seq 1 20) -do - sleep "$DEFAULT_SLEEP" - OK="0" - if [ "0" = "$E_DONE" ] && [ "1" = "$START_EXCHANGE" ] - then - echo -n "E" - wget \ - --tries=1 \ - --timeout=1 \ - "${EXCHANGE_URL}config" \ - -o /dev/null \ - -O /dev/null >/dev/null || continue - E_DONE=1 - fi - if [ "0" = "$D_DONE" ] && [ "1" = "$START_DONAU" ] - then - echo -n "D" - wget \ - --tries=1 \ - --timeout=1 \ - "${DONAU_URL}config" \ - -o /dev/null \ - -O /dev/null >/dev/null || continue - D_DONE=1 - fi - if [ "0" = "$M_DONE" ] && [ "1" = "$START_MERCHANT" ] - then - echo -n "M" - wget \ - --tries=1 \ - --timeout=1 \ - "${MERCHANT_URL}config" \ - -o /dev/null \ - -O /dev/null >/dev/null || continue - M_DONE=1 - fi - if [ "0" = "$S_DONE" ] && [ "1" = "$START_BACKUP" ] - then - echo -n "S" - wget \ - --tries=1 \ - --timeout=1 \ - "${SYNC_URL}config" \ - -o /dev/null \ - -O /dev/null >/dev/null || continue - S_DONE=1 - fi - if [ "0" = "$K_DONE" ] && [ "1" = "$START_CHALLENGER" ] - then - echo -n "K" - wget \ - --tries=1 \ - --timeout=1 \ - "${CHALLENGER_URL}config" \ - -o /dev/null \ - -O /dev/null >/dev/null || continue - K_DONE=1 - fi - if [ "0" = "$A_DONE" ] && [ "1" = "$START_AUDITOR" ] - then - echo -n "A" - wget \ - --tries=1 \ - --timeout=1 \ - "${AUDITOR_URL}config" \ - -o /dev/null \ - -O /dev/null >/dev/null || continue - A_DONE=1 - fi - OK="1" - break -done -if [ 1 != "$OK" ] -then - exit_skip "Failed to launch (some) Taler services" -fi -echo " OK" - -if [ "1" = "$START_EXCHANGE" ] -then - echo -n "Wait for exchange /management/keys to be ready " - OK="0" - LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX) - for n in $(seq 1 10) - do - echo -n "." - sleep "$DEFAULT_SLEEP" - # exchange - wget \ - --tries=3 \ - --waitretry=0 \ - --timeout=30 \ - "${EXCHANGE_URL}management/keys"\ - -o /dev/null \ - -O "$LAST_RESPONSE" \ - >/dev/null || continue - OK="1" - break; - done - if [ "1" != "$OK" ] - then - cat "$LAST_RESPONSE" - exit_fail "Failed to setup exchange keys, check secmod logs" - fi - rm "$LAST_RESPONSE" - echo " OK" - - echo -n "Setting up exchange keys ..." - taler-exchange-offline -c "$CONF" \ - download \ - sign \ - wire-fee now "$WIRE_DOMAIN" "$CURRENCY:0.01" "$CURRENCY:0.01" \ - global-fee now "$CURRENCY:0.01" "$CURRENCY:0.01" "$CURRENCY:0.01" 1h 1year 5 \ - upload &> taler-exchange-offline.log - echo "OK" - ENABLED=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "ENABLE_CREDIT") - if [ "YES" = "$ENABLED" ] - then - echo -n "Configuring bank account $USE_ACCOUNT ..." - EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "PAYTO_URI") - taler-exchange-offline -c "$CONF" \ - enable-account "$EXCHANGE_PAYTO_URI" \ - upload &> "taler-exchange-offline-account.log" - echo " OK" - else - echo "WARNING: Account ${USE_ACCOUNT} not enabled (set to: '$ENABLED')" - fi - if [ "1" = "$START_AUDITOR" ] - then - echo -n "Enabling auditor ..." - taler-exchange-offline -c "$CONF" \ - enable-auditor "$AUDITOR_PUB" "$AUDITOR_URL" "$CURRENCY Auditor" \ - upload &> taler-exchange-offline-auditor.log - echo "OK" - fi - - echo -n "Checking /keys " - OK="0" - LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX) - for n in $(seq 1 10) - do - echo -n "." - sleep "$DEFAULT_SLEEP" - wget \ - --tries=1 \ - --timeout=5 \ - "${EXCHANGE_URL}keys" \ - -a wget-keys-check.log \ - -o /dev/null \ - -O "$LAST_RESPONSE" \ - >/dev/null || continue - OK="1" - break - done - if [ "1" != "$OK" ] - then - cat "$LAST_RESPONSE" - exit_fail " Failed to fetch ${EXCHANGE_URL}keys" - fi - rm "$LAST_RESPONSE" - echo " OK" -fi - -if [ "1" = "$START_DONAU" ] -then - echo -n "Wait for donau /keys to be ready " - OK="0" - LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX) - for n in $(seq 1 10) - do - echo -n "." - sleep "$DEFAULT_SLEEP" - # donau - wget \ - --tries=3 \ - --waitretry=0 \ - --timeout=30 \ - "${DONAU_URL}keys"\ - -o /dev/null \ - -O "$LAST_RESPONSE" \ - >/dev/null || continue - OK="1" - break; - done - if [ "1" != "$OK" ] - then - cat "$LAST_RESPONSE" - exit_fail "Failed to setup donau keys, check secmod logs" - fi - rm "$LAST_RESPONSE" - echo " OK" - - echo -n "Setting up donau keys ..." - donau-offline -c "$CONF" \ - download \ - sign \ - upload &> donau-offline.log - echo "OK" - - echo -n "Checking /keys " - OK="0" - LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX) - for n in $(seq 1 10) - do - echo -n "." - sleep "$DEFAULT_SLEEP" - wget \ - --tries=1 \ - --timeout=5 \ - "${DONAU_URL}keys" \ - -a wget-keys-check.log \ - -o /dev/null \ - -O "$LAST_RESPONSE" \ - >/dev/null || continue - OK="1" - break - done - if [ "1" != "$OK" ] - then - cat "$LAST_RESPONSE" - exit_fail " Failed to fetch ${DONAU_URL}keys" - fi - rm "$LAST_RESPONSE" - echo " OK" -fi - -if [ "1" = "$START_AUDITOR" ] -then - echo -n "Setting up auditor signatures ..." - timeout 15 taler-auditor-offline -c "$CONF" \ - download \ - sign \ - upload &> taler-auditor-offline.log - echo " OK" -fi - -# Signal caller that we are ready. -echo "<<READY>>" - -if [ "1" = "$WAIT_FOR_SIGNAL" ] -then - while true - do - sleep 0.1 - done -else - # Wait until caller stops us. - # shellcheck disable=SC2162 - read -fi - -echo "Taler unified setup terminating!" >&2 -EXIT_STATUS=0 -exit "$EXIT_STATUS" diff --git a/src/util/donau_crypto.c b/src/util/donau_crypto.c @@ -45,7 +45,7 @@ GNUNET_NETWORK_STRUCT_END void -TALER_donation_unit_group_get_key ( +DONAU_donation_unit_group_get_key ( const struct DONAU_DonationUnitGroup *dg, struct GNUNET_HashCode *key) {