summaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-16 19:23:29 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-16 19:23:29 +0100
commit6f6c71a8d39e5f1f4d69ec06ad20f832617783d6 (patch)
tree0d6d99bfc2d65d632da771e968bc422754f156ba /src/exchangedb
parente0497239e90df63eaee085a45488e9ff3ee799bc (diff)
downloadexchange-6f6c71a8d39e5f1f4d69ec06ad20f832617783d6.tar.gz
exchange-6f6c71a8d39e5f1f4d69ec06ad20f832617783d6.tar.bz2
exchange-6f6c71a8d39e5f1f4d69ec06ad20f832617783d6.zip
load fees from DB instead of from config, also in wire tools
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/Makefile.am46
-rw-r--r--src/exchangedb/exchangedb_accounts.c1
-rw-r--r--src/exchangedb/exchangedb_auditorkeys.c344
-rw-r--r--src/exchangedb/exchangedb_denomkeys.c518
-rw-r--r--src/exchangedb/exchangedb_fees.c412
-rw-r--r--src/exchangedb/exchangedb_signkeys.c187
-rw-r--r--src/exchangedb/test_exchangedb_auditors.c169
-rw-r--r--src/exchangedb/test_exchangedb_denomkeys.c213
-rw-r--r--src/exchangedb/test_exchangedb_fees.c153
-rw-r--r--src/exchangedb/test_exchangedb_signkeys.c99
10 files changed, 1 insertions, 2141 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 6736ce379..582030b53 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -53,11 +53,7 @@ lib_LTLIBRARIES = \
libtalerexchangedb_la_SOURCES = \
exchangedb_accounts.c \
- exchangedb_auditorkeys.c \
- exchangedb_denomkeys.c \
- exchangedb_fees.c \
exchangedb_plugin.c \
- exchangedb_signkeys.c \
exchangedb_transactions.c
libtalerexchangedb_la_LIBADD = \
$(top_builddir)/src/bank-lib/libtalerbank.la \
@@ -71,51 +67,11 @@ libtalerexchangedb_la_LDFLAGS = \
check_PROGRAMS = \
- test-exchangedb-auditors \
- test-exchangedb-denomkeys \
- test-exchangedb-fees \
- test-exchangedb-signkeys \
test-exchangedb-postgres
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
- test-exchangedb-auditors \
- test-exchangedb-denomkeys \
- test-exchangedb-fees \
- test-exchangedb-postgres \
- test-exchangedb-signkeys
-
-test_exchangedb_auditors_SOURCES = \
- test_exchangedb_auditors.c
-test_exchangedb_auditors_LDADD = \
- libtalerexchangedb.la \
- $(top_srcdir)/src/util/libtalerutil.la \
- -lgnunetutil \
- $(XLIB)
-
-test_exchangedb_denomkeys_SOURCES = \
- test_exchangedb_denomkeys.c
-test_exchangedb_denomkeys_LDADD = \
- libtalerexchangedb.la \
- $(top_srcdir)/src/util/libtalerutil.la \
- -lgnunetutil \
- $(XLIB)
-
-test_exchangedb_fees_SOURCES = \
- test_exchangedb_fees.c
-test_exchangedb_fees_LDADD = \
- libtalerexchangedb.la \
- $(top_srcdir)/src/util/libtalerutil.la \
- -lgnunetutil \
- $(XLIB)
-
-test_exchangedb_signkeys_SOURCES = \
- test_exchangedb_signkeys.c
-test_exchangedb_signkeys_LDADD = \
- libtalerexchangedb.la \
- $(top_srcdir)/src/util/libtalerutil.la \
- -lgnunetutil \
- $(XLIB)
+ test-exchangedb-postgres
test_exchangedb_postgres_SOURCES = \
test_exchangedb.c
diff --git a/src/exchangedb/exchangedb_accounts.c b/src/exchangedb/exchangedb_accounts.c
index 5b74c8369..7e3edf1c8 100644
--- a/src/exchangedb/exchangedb_accounts.c
+++ b/src/exchangedb/exchangedb_accounts.c
@@ -305,7 +305,6 @@ TALER_EXCHANGEDB_unload_accounts (void)
wa_tail,
wa);
TALER_BANK_auth_free (&wa->auth);
- TALER_EXCHANGEDB_fees_free (wa->af);
GNUNET_free (wa->section_name);
GNUNET_free (wa->method);
GNUNET_free (wa);
diff --git a/src/exchangedb/exchangedb_auditorkeys.c b/src/exchangedb/exchangedb_auditorkeys.c
deleted file mode 100644
index 0a0370cfe..000000000
--- a/src/exchangedb/exchangedb_auditorkeys.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014--2019 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/>
-*/
-/**
- * @file exchangedb/exchangedb_auditorkeys.c
- * @brief I/O operations for the Exchange's auditor data
- * @author Florian Dold
- * @author Benedikt Mueller
- * @author Sree Harsha Totakura
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_exchangedb_lib.h"
-
-
-/**
- * Closure for #auditor_iter() and
- */
-struct AuditorIterateContext
-{
-
- /**
- * Function to call with the information for each auditor.
- */
- TALER_EXCHANGEDB_AuditorIterator it;
-
- /**
- * Closure for @e it.
- */
- void *it_cls;
-
- /**
- * Status of the iteration.
- */
- int status;
-};
-
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/**
- * Header of a file with auditing information.
- */
-struct AuditorFileHeaderP
-{
-
- /**
- * Public key of the auditor.
- */
- struct TALER_AuditorPublicKeyP apub;
-
- /**
- * Master public key of the exchange the auditor is signing
- * information for.
- */
- struct TALER_MasterPublicKeyP mpub;
-
- /**
- * Number of signatures and DKI entries in this file.
- */
- uint32_t dki_len;
-
-};
-GNUNET_NETWORK_STRUCT_END
-
-
-/**
- * Load the auditor signature and the information signed by the
- * auditor and call the callback in @a cls with the information.
- *
- * @param cls the `struct AuditorIterateContext *`
- * @param filename name of a file that should contain
- * a denomination key
- * @return #GNUNET_OK to continue to iterate
- * #GNUNET_NO to abort iteration with success
- * #GNUNET_SYSERR to abort iteration with failure
- */
-static int
-auditor_iter (void *cls,
- const char *filename)
-{
- struct AuditorIterateContext *aic = cls;
- uint64_t size;
- struct AuditorFileHeaderP *af;
- const struct TALER_AuditorSignatureP *sigs;
- const struct TALER_DenominationKeyValidityPS *dki;
- const char *auditor_url;
- uint32_t dki_len;
- size_t url_len;
- int iret;
-
- if (GNUNET_OK !=
- GNUNET_DISK_file_size (filename,
- &size,
- GNUNET_YES,
- GNUNET_YES))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Skipping inaccessible auditor information file `%s'\n",
- filename);
- return GNUNET_OK;
- }
- if (size < sizeof (struct AuditorFileHeaderP))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "File size (%llu bytes) too small for file `%s' to contain auditor data. Skipping it.\n",
- (unsigned long long) size,
- filename);
- return GNUNET_OK;
- }
- if (size >= GNUNET_MAX_MALLOC_CHECKED)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "File size (%llu bytes) too large for file `%s' to contain auditor data. Skipping it.\n",
- (unsigned long long) size,
- filename);
- return GNUNET_OK;
- }
- af = GNUNET_malloc (size);
- if (((ssize_t) size) !=
- GNUNET_DISK_fn_read (filename,
- af,
- size))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
- "read",
- filename);
- GNUNET_free (af);
- return GNUNET_OK;
- }
- dki_len = ntohl (af->dki_len);
- if (0 == dki_len)
- {
- GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "No signed keys in %s\n",
- filename);
- GNUNET_free (af);
- return GNUNET_OK;
- }
- size -= sizeof (struct AuditorFileHeaderP);
- if ( (size / dki_len) <
- (sizeof (struct TALER_DenominationKeyValidityPS)
- + sizeof (struct TALER_AuditorSignatureP)) )
- {
- GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Malformed auditor data file %s (file too short for %u keys)\n",
- filename,
- (unsigned int) dki_len);
- GNUNET_free (af);
- return GNUNET_OK;
- }
- url_len = size - dki_len * (sizeof (struct TALER_DenominationKeyValidityPS)
- + sizeof (struct TALER_AuditorSignatureP));
- sigs = (const struct TALER_AuditorSignatureP *) &af[1];
- dki = (const struct TALER_DenominationKeyValidityPS *) &sigs[dki_len];
- auditor_url = (const char *) &dki[dki_len];
- if ( (0 == url_len) ||
- ('\0' != auditor_url[url_len - 1]) )
- {
- GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Malformed auditor data file %s (no 0-terminator)\n",
- filename);
- GNUNET_free (af);
- return GNUNET_OK;
- }
- if (GNUNET_OK !=
- (iret = aic->it (aic->it_cls,
- &af->apub,
- auditor_url,
- &af->mpub,
- dki_len,
- sigs,
- dki)))
- {
- GNUNET_free (af);
- if (GNUNET_SYSERR == iret)
- aic->status = GNUNET_SYSERR;
- return GNUNET_SYSERR;
- }
- aic->status++;
- GNUNET_free (af);
- return GNUNET_OK;
-}
-
-
-/**
- * Call @a it with information for each auditor found in the @a exchange_base_dir.
- *
- * @param cfg configuration to use
- * @param it function to call with auditor information
- * @param it_cls closure for @a it
- * @return -1 on error, 0 if no files were found, otherwise
- * a positive number (however, even with a positive
- * number it is possible that @a it was never called
- * as maybe none of the files were well-formed)
- */
-int
-TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
- TALER_EXCHANGEDB_AuditorIterator it,
- void *it_cls)
-{
- struct AuditorIterateContext aic;
- int ret;
- char *auditor_base_dir;
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "exchangedb",
- "AUDITOR_BASE_DIR",
- &auditor_base_dir))
- return -1;
- aic.it = it;
- aic.it_cls = it_cls;
- aic.status = 0;
- ret = GNUNET_DISK_directory_scan (auditor_base_dir,
- &auditor_iter,
- &aic);
- GNUNET_free (auditor_base_dir);
- if ( (0 != aic.status) ||
- (GNUNET_OK == ret) )
- return aic.status;
- return ret;
-}
-
-
-/**
- * Write auditor information to the given file.
- *
- * @param filename the file where to write the auditor information to
- * @param apub the auditor's public key
- * @param auditor_url the URL of the auditor
- * @param asigs the auditor's signatures, array of length @a dki_len
- * @param mpub the exchange's public key (as expected by the auditor)
- * @param dki_len length of @a dki
- * @param dki array of denomination coin data signed by the auditor
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure.
- */
-int
-TALER_EXCHANGEDB_auditor_write (
- const char *filename,
- const struct TALER_AuditorPublicKeyP *apub,
- const char *auditor_url,
- const struct TALER_AuditorSignatureP *asigs,
- const struct TALER_MasterPublicKeyP *mpub,
- uint32_t dki_len,
- const struct TALER_DenominationKeyValidityPS *dki)
-{
- struct GNUNET_DISK_FileHandle *fh;
- ssize_t wrote;
- size_t wsize;
- int eno;
-
- if (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (filename))
- {
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "mkdir (for file)",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
- }
- if (NULL == (fh = GNUNET_DISK_file_open
- (filename,
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE
- | GNUNET_DISK_OPEN_TRUNCATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE)))
- {
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "open",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
- }
- {
- struct AuditorFileHeaderP af = {
- .apub = *apub,
- .mpub = *mpub,
- .dki_len = htonl (dki_len)
- };
-
- wsize = sizeof (struct AuditorFileHeaderP);
- if ( (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
- &af,
- wsize))) ||
- (wrote != (ssize_t) wsize) )
- goto cleanup;
- }
- wsize = dki_len * sizeof (struct TALER_AuditorSignatureP);
- if (((ssize_t) wsize) !=
- GNUNET_DISK_file_write (fh,
- asigs,
- wsize))
- goto cleanup;
- wsize = dki_len * sizeof (struct TALER_DenominationKeyValidityPS);
- if (((ssize_t) wsize) !=
- GNUNET_DISK_file_write (fh,
- dki,
- wsize))
- goto cleanup;
- wsize = strlen (auditor_url) + 1;
- if (((ssize_t) wsize) !=
- GNUNET_DISK_file_write (fh,
- auditor_url,
- wsize))
- goto cleanup;
- GNUNET_assert (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- return GNUNET_OK;
-cleanup:
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "write",
- filename);
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- /* try to remove the file, as it must be malformed */
- if (0 != unlink (filename))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "unlink",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
-}
-
-
-/* end of exchangedb_auditorkeys.c */
diff --git a/src/exchangedb/exchangedb_denomkeys.c b/src/exchangedb/exchangedb_denomkeys.c
deleted file mode 100644
index 81828aaee..000000000
--- a/src/exchangedb/exchangedb_denomkeys.c
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2019 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/>
-*/
-/**
- * @file exchangedb/exchangedb_denomkeys.c
- * @brief I/O operations for the Exchange's denomination private keys
- * @author Florian Dold
- * @author Benedikt Mueller
- * @author Sree Harsha Totakura
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_crypto_lib.h"
-#include "taler_exchangedb_lib.h"
-
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/**
- * Contents of a file with a revocation certificate.
- */
-struct RevocationFileP
-{
-
- /**
- * Hash of the denomination public key being revoked.
- */
- struct GNUNET_HashCode denom_hash;
-
- /**
- * Master signature over the revocation, must match purpose
- * #TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED.
- */
- struct TALER_MasterSignatureP msig;
-};
-
-GNUNET_NETWORK_STRUCT_END
-
-
-/**
- * Mark the given denomination key as revoked and request the wallets
- * to initiate /recoup.
- *
- * @param revocation_dir where to write the revocation certificate
- * @param denom_hash hash of the denomination key to revoke
- * @param mpriv master private key to sign with
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure.
- */
-int
-TALER_EXCHANGEDB_denomination_key_revoke (
- const char *revocation_dir,
- const struct GNUNET_HashCode *denom_hash,
- const struct TALER_MasterPrivateKeyP *mpriv)
-{
- char *fn;
- int ret;
- struct RevocationFileP rd;
-
- TALER_exchange_offline_denomination_revoke_sign (denom_hash,
- mpriv,
- &rd.msig);
- GNUNET_asprintf (&fn,
- "%s" DIR_SEPARATOR_STR
- "%s.rev",
- revocation_dir,
- GNUNET_h2s_full (denom_hash));
- rd.denom_hash = *denom_hash;
- ret = (sizeof (rd) !=
- GNUNET_DISK_fn_write (fn,
- &rd,
- sizeof (rd),
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE))
- ? GNUNET_SYSERR
- : GNUNET_OK;
- GNUNET_free (fn);
- return ret;
-}
-
-
-/**
- * Import a denomination key from the given file.
- *
- * @param filename the file to import the key from
- * @param[out] dki set to the imported denomination key
- * @return #GNUNET_OK upon success;
- * #GNUNET_SYSERR upon failure
- */
-int
-TALER_EXCHANGEDB_denomination_key_read (
- const char *filename,
- struct TALER_EXCHANGEDB_DenominationKey *dki)
-{
- uint64_t size;
- size_t offset;
- void *data;
- struct GNUNET_CRYPTO_RsaPrivateKey *priv;
-
- if (GNUNET_OK !=
- GNUNET_DISK_file_size (filename,
- &size,
- GNUNET_YES,
- GNUNET_YES))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Skipping inaccessible denomination key file `%s'\n",
- filename);
- return GNUNET_SYSERR;
- }
- offset = sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP);
- if (size <= offset)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "File size (%llu bytes) too small for file `%s' to contain denomination key data. Skipping it.\n",
- (unsigned long long) size,
- filename);
- return GNUNET_SYSERR;
- }
- if (size >= GNUNET_MAX_MALLOC_CHECKED)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "File size (%llu bytes) too large for file `%s' to contain denomination key data. Skipping it.\n",
- (unsigned long long) size,
- filename);
- return GNUNET_OK;
- }
- data = GNUNET_malloc (size);
- if (((ssize_t) size) !=
- GNUNET_DISK_fn_read (filename,
- data,
- size))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
- "read",
- filename);
- GNUNET_free (data);
- return GNUNET_SYSERR;
- }
- if (NULL ==
- (priv = GNUNET_CRYPTO_rsa_private_key_decode (data + offset,
- size - offset)))
- {
- GNUNET_free (data);
- return GNUNET_SYSERR;
- }
- GNUNET_assert (NULL == dki->denom_priv.rsa_private_key);
- dki->denom_priv.rsa_private_key = priv;
- dki->denom_pub.rsa_public_key
- = GNUNET_CRYPTO_rsa_private_key_get_public (priv);
- memcpy (&dki->issue,
- data,
- offset);
- GNUNET_free (data);
- if (0 == GNUNET_TIME_absolute_get_remaining
- (GNUNET_TIME_absolute_ntoh
- (dki->issue.properties.expire_withdraw)).rel_value_us)
- {
- /* key expired for withdrawal, remove private key to
- minimize chance of compromise */
- if (0 != unlink (filename))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "unlink",
- filename);
- /* yes, we had an error, but the file content
- was fine and is being returned */
- return GNUNET_OK;
- }
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Exports a denomination key to the given file.
- *
- * @param filename the file where to write the denomination key
- * @param dki the denomination key
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure.
- */
-int
-TALER_EXCHANGEDB_denomination_key_write (
- const char *filename,
- const struct TALER_EXCHANGEDB_DenominationKey *dki)
-{
- struct GNUNET_DISK_FileHandle *fh;
- ssize_t wrote;
- size_t wsize;
- int eno;
-
- if (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (filename))
- {
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "mkdir (for file)",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
- }
- if (NULL == (fh = GNUNET_DISK_file_open
- (filename,
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE
- | GNUNET_DISK_OPEN_TRUNCATE
- | GNUNET_DISK_OPEN_FAILIFEXISTS,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE)))
- {
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "open",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
- }
- wsize = sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP);
- if ( (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
- &dki->issue,
- wsize))) ||
- (wrote != (ssize_t) wsize) )
- goto cleanup;
- {
- void *priv_enc;
- size_t priv_enc_size;
-
- priv_enc_size
- = GNUNET_CRYPTO_rsa_private_key_encode (dki->denom_priv.rsa_private_key,
- &priv_enc);
- wrote = GNUNET_DISK_file_write (fh,
- priv_enc,
- priv_enc_size);
- GNUNET_free (priv_enc);
- if ( (GNUNET_SYSERR == wrote) ||
- (wrote != (ssize_t) priv_enc_size) )
- goto cleanup;
- }
- GNUNET_assert (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- return GNUNET_OK;
-
-cleanup:
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "write",
- filename);
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- /* try to remove the file, as it must be malformed */
- if (0 != unlink (filename))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "unlink",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
-}
-
-
-/**
- * Closure for #denomkeys_iterate_keydir_iter() and
- * #denomkeys_iterate_topdir_iter().
- */
-struct DenomkeysIterateContext
-{
-
- /**
- * Set to the name of the directory below the top-level directory
- * during the call to #denomkeys_iterate_keydir_iter().
- */
- const char *alias;
-
- /**
- * Function to call on each denomination key.
- */
- TALER_EXCHANGEDB_DenominationKeyIterator it;
-
- /**
- * Closure for @e it.
- */
- void *it_cls;
-};
-
-
-/**
- * Decode the denomination key in the given file @a filename and call
- * the callback in @a cls with the information.
- *
- * @param cls the `struct DenomkeysIterateContext *`
- * @param filename name of a file that should contain
- * a denomination key
- * @return #GNUNET_OK to continue to iterate
- * #GNUNET_NO to abort iteration with success
- * #GNUNET_SYSERR to abort iteration with failure
- */
-static int
-denomkeys_iterate_keydir_iter (void *cls,
- const char *filename)
-{
- struct DenomkeysIterateContext *dic = cls;
- struct TALER_EXCHANGEDB_DenominationKey issue;
- int ret;
-
- memset (&issue, 0, sizeof (issue));
- if (GNUNET_OK !=
- TALER_EXCHANGEDB_denomination_key_read (filename,
- &issue))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Invalid denomkey file: '%s'\n",
- filename);
- return GNUNET_OK;
- }
- ret = dic->it (dic->it_cls,
- dic->alias,
- &issue);
- GNUNET_CRYPTO_rsa_private_key_free (issue.denom_priv.rsa_private_key);
- GNUNET_CRYPTO_rsa_public_key_free (issue.denom_pub.rsa_public_key);
- return ret;
-}
-
-
-/**
- * Function called on each subdirectory in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS. Will
- * call the #denomkeys_iterate_keydir_iter() on each file in the
- * subdirectory.
- *
- * @param cls the `struct DenomkeysIterateContext *`
- * @param filename name of the subdirectory to scan
- * @return #GNUNET_OK on success,
- * #GNUNET_SYSERR if we need to abort
- */
-static int
-denomkeys_iterate_topdir_iter (void *cls,
- const char *filename)
-{
- struct DenomkeysIterateContext *dic = cls;
-
- dic->alias = GNUNET_STRINGS_get_short_name (filename);
- if (0 > GNUNET_DISK_directory_scan (filename,
- &denomkeys_iterate_keydir_iter,
- dic))
- return GNUNET_SYSERR;
- return GNUNET_OK;
-}
-
-
-/**
- * Call @a it for each denomination key found in the @a exchange_base_dir.
- *
- * @param exchange_base_dir base directory for the exchange,
- * the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS
- * subdirectory
- * @param it function to call on each denomination key found
- * @param it_cls closure for @a it
- * @return -1 on error, 0 if no files were found, otherwise
- * a positive number (however, even with a positive
- * number it is possible that @a it was never called
- * as maybe none of the files were well-formed)
- */
-int
-TALER_EXCHANGEDB_denomination_keys_iterate (
- const char *exchange_base_dir,
- TALER_EXCHANGEDB_DenominationKeyIterator it,
- void *it_cls)
-{
- struct DenomkeysIterateContext dic = {
- .it = it,
- .it_cls = it_cls
- };
- char *dir;
- int ret;
-
- GNUNET_asprintf (&dir,
- "%s" DIR_SEPARATOR_STR
- TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS,
- exchange_base_dir);
- ret = GNUNET_DISK_directory_scan (dir,
- &denomkeys_iterate_topdir_iter,
- &dic);
- GNUNET_free (dir);
- return ret;
-}
-
-
-/**
- * Closure for #revocations_iterate_cb().
- */
-struct RevocationsIterateContext
-{
-
- /**
- * Function to call on each revoked denomination key.
- */
- TALER_EXCHANGEDB_RevocationIterator it;
-
- /**
- * Closure for @e it.
- */
- void *it_cls;
-
- /**
- * Master public key to use to validate revocations.
- */
- const struct TALER_MasterPublicKeyP *master_pub;
-
-};
-
-
-/**
- * Decode the revocation certificate in the given file @a filename and call
- * the callback in @a cls with the information.
- *
- * @param cls the `struct RevocationsIterateContext *`
- * @param filename name of a file that should contain
- * a denomination key
- * @return #GNUNET_OK to continue to iterate
- * #GNUNET_NO to abort iteration with success
- * #GNUNET_SYSERR to abort iteration with failure
- */
-static int
-revocations_iterate_cb (void *cls,
- const char *filename)
-{
- struct RevocationsIterateContext *ric = cls;
- struct RevocationFileP rf;
- ssize_t rd;
-
- /* Check if revocation is valid... */
- rd = GNUNET_DISK_fn_read (filename,
- &rf,
- sizeof (rf));
- if (GNUNET_SYSERR == rd)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
- "read",
- filename);
- return GNUNET_OK;
- }
- if (sizeof (rf) != (size_t) rd)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Invalid revocation file `%s' found and ignored (bad size: %llu)\n",
- filename,
- (unsigned long long) rd);
- return GNUNET_OK;
- }
-
- if (GNUNET_OK !=
- TALER_exchange_offline_denomination_revoke_verify (
- &rf.denom_hash,
- ric->master_pub,
- &rf.msig))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Invalid revocation file `%s' found and ignored (bad signature)\n",
- filename);
- return GNUNET_OK;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Denomination key `%s' was revoked!\n",
- GNUNET_h2s (&rf.denom_hash));
- return ric->it (ric->it_cls,
- &rf.denom_hash,
- &rf.msig);
-}
-
-
-/**
- * Call @a it for each revoked denomination key found in the @a revocation_dir.
- *
- * @param revocation_dir base directory where revocations are stored
- * @param master_pub master public key (used to check revocations)
- * @param it function to call on each revoked denomination key found
- * @param it_cls closure for @a it
- * @return -1 on error, 0 if no files were found, otherwise
- * a positive number (however, even with a positive
- * number it is possible that @a it was never called
- * as maybe none of the files were well-formed)
- */
-int
-TALER_EXCHANGEDB_revocations_iterate (const char *revocation_dir,
- const struct
- TALER_MasterPublicKeyP *master_pub,
- TALER_EXCHANGEDB_RevocationIterator it,
- void *it_cls)
-{
- struct RevocationsIterateContext ric = {
- .it = it,
- .it_cls = it_cls,
- .master_pub = master_pub
- };
-
- if (GNUNET_OK !=
- GNUNET_DISK_directory_create (revocation_dir))
- {
- /* directory doesn't exist and we couldn't even create it,
- clearly means there are no revocations there */
- return 0;
- }
- return GNUNET_DISK_directory_scan (revocation_dir,
- &revocations_iterate_cb,
- &ric);
-}
-
-
-/* end of exchangedb_denomkeys.c */
diff --git a/src/exchangedb/exchangedb_fees.c b/src/exchangedb/exchangedb_fees.c
deleted file mode 100644
index 070f16eee..000000000
--- a/src/exchangedb/exchangedb_fees.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2017 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/>
-*/
-/**
- * @file exchangedb/exchangedb_fees.c
- * @brief Logic to read/write/convert aggregation wire fees (not other fees!)
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_exchangedb_lib.h"
-
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/**
- * Structure for wire fees on disk.
- */
-struct TALER_WireFeeDiskP
-{
-
- /**
- * Wire fee details.
- */
- struct TALER_MasterWireFeePS wf;
-
-
- /**
- * Signature affirming the above fee structure.
- */
- struct TALER_MasterSignatureP master_sig;
-
-};
-
-GNUNET_NETWORK_STRUCT_END
-
-
-/**
- * Convert @a wd disk format to host format.
- *
- * @param wd aggregate fees, disk format
- * @return fees in host format
- */
-static struct TALER_EXCHANGEDB_AggregateFees *
-wd2af (const struct TALER_WireFeeDiskP *wd)
-{
- struct TALER_EXCHANGEDB_AggregateFees *af;
-
- af = GNUNET_new (struct TALER_EXCHANGEDB_AggregateFees);
- af->start_date = GNUNET_TIME_absolute_ntoh (wd->wf.start_date);
- af->end_date = GNUNET_TIME_absolute_ntoh (wd->wf.end_date);
- TALER_amount_ntoh (&af->wire_fee,
- &wd->wf.wire_fee);
- TALER_amount_ntoh (&af->closing_fee,
- &wd->wf.closing_fee);
- af->master_sig = wd->master_sig;
- return af;
-}
-
-
-/**
- * Read the current fee structure from disk.
- *
- * @param cfg configuration to use
- * @param wireplugin name of the wire plugin to read fees for
- * @return sorted list of aggregation fees, NULL on error
- */
-struct TALER_EXCHANGEDB_AggregateFees *
-TALER_EXCHANGEDB_fees_read (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *wireplugin)
-{
- char *wirefee_base_dir;
- char *fn;
- struct GNUNET_DISK_FileHandle *fh;
- struct TALER_WireFeeDiskP wd;
- struct TALER_EXCHANGEDB_AggregateFees *af;
- struct TALER_EXCHANGEDB_AggregateFees *endp;
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "exchangedb",
- "WIREFEE_BASE_DIR",
- &wirefee_base_dir))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- "exchangedb",
- "WIREFEE_BASE_DIR");
- return NULL;
- }
- GNUNET_asprintf (&fn,
- "%s/%s.fee",
- wirefee_base_dir,
- wireplugin);
- GNUNET_free (wirefee_base_dir);
- fh = GNUNET_DISK_file_open (fn,
- GNUNET_DISK_OPEN_READ,
- GNUNET_DISK_PERM_NONE);
- if (NULL == fh)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "open",
- fn);
- GNUNET_free (fn);
- return NULL;
- }
-
- af = NULL;
- endp = NULL;
- while (1)
- {
- struct TALER_EXCHANGEDB_AggregateFees *n;
- ssize_t in = GNUNET_DISK_file_read (fh,
- &wd,
- sizeof (wd));
- if (-1 == in)
- {
- /* Unexpected I/O error */
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "read",
- fn);
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- GNUNET_free (fn);
- TALER_EXCHANGEDB_fees_free (af);
- return NULL;
- }
- if (0 == in)
- break; /* EOF, terminate normally */
- if (sizeof (wd) != in)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "File `%s' has wrong size for fee structure\n",
- fn);
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- GNUNET_free (fn);
- TALER_EXCHANGEDB_fees_free (af);
- return NULL;
- }
- n = wd2af (&wd);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Loaded wire fees starting at %s from file\n",
- GNUNET_STRINGS_absolute_time_to_string (n->start_date));
- if ( ( (NULL == af) ||
- (endp->end_date.abs_value_us == n->start_date.abs_value_us) ) &&
- (n->start_date.abs_value_us < n->end_date.abs_value_us) )
- {
- /* append to list */
- if (NULL != endp)
- endp->next = n;
- else
- af = n;
- endp = n;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "File `%s' does not have wire fees in chronological order\n",
- fn);
- GNUNET_DISK_file_close (fh);
- GNUNET_free (n);
- GNUNET_free (fn);
- TALER_EXCHANGEDB_fees_free (af);
- return NULL;
- }
- }
- GNUNET_assert (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- GNUNET_free (fn);
- return af;
-}
-
-
-/**
- * Convert @a af to @a wf.
- *
- * @param wiremethod name of the wire method the fees are for
- * @param[in,out] af aggregate fees, host format (updated to round time)
- * @param[out] wf aggregate fees, disk / signature format
- */
-void
-TALER_EXCHANGEDB_fees_2_wf (const char *wiremethod,
- struct TALER_EXCHANGEDB_AggregateFees *af,
- struct TALER_MasterWireFeePS *wf)
-{
- (void) GNUNET_TIME_round_abs (&af->start_date);
- (void) GNUNET_TIME_round_abs (&af->end_date);
- wf->purpose.size = htonl (sizeof (*wf));
- wf->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES);
- GNUNET_CRYPTO_hash (wiremethod,
- strlen (wiremethod) + 1,
- &wf->h_wire_method);
- wf->start_date = GNUNET_TIME_absolute_hton (af->start_date);
- wf->end_date = GNUNET_TIME_absolute_hton (af->end_date);
- TALER_amount_hton (&wf->wire_fee,
- &af->wire_fee);
- TALER_amount_hton (&wf->closing_fee,
- &af->closing_fee);
-}
-
-
-/**
- * Write given fee structure to disk.
- *
- * @param filename where to write the fees
- * @param wireplugin which plugin the fees are about
- * @param af fee structure to write
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-TALER_EXCHANGEDB_fees_write (const char *filename,
- const char *wireplugin,
- struct TALER_EXCHANGEDB_AggregateFees *af)
-{
- struct GNUNET_DISK_FileHandle *fh;
- struct TALER_WireFeeDiskP wd;
- struct TALER_EXCHANGEDB_AggregateFees *last;
-
- if (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (filename))
- {
- int eno;
-
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "mkdir (for file)",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
- }
-
- fh = GNUNET_DISK_file_open (filename,
- GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_TRUNCATE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE);
- if (NULL == fh)
- {
- int eno;
-
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "open",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
- }
-
- last = NULL;
- while (NULL != af)
- {
- if ( ( (NULL != last) &&
- (last->end_date.abs_value_us != af->start_date.abs_value_us) ) ||
- (af->start_date.abs_value_us >= af->end_date.abs_value_us) )
- {
- /* @a af malformed, refusing to write file that will be rejected */
- GNUNET_break (0);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- /* try to remove the file, as it would be malformed */
- if (0 != unlink (filename))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "unlink",
- filename);
- errno = EINVAL; /* invalid inputs */
- return GNUNET_SYSERR;
- }
- TALER_EXCHANGEDB_fees_2_wf (wireplugin,
- af,
- &wd.wf);
- wd.master_sig = af->master_sig;
- last = af;
- af = af->next;
- if (sizeof (wd) !=
- GNUNET_DISK_file_write (fh,
- &wd,
- sizeof (wd)))
- {
- int eno = errno;
-
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- /* try to remove the file, as it must be malformed */
- if (0 != unlink (filename))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "unlink",
- filename);
- errno = eno;
- return GNUNET_SYSERR;
- }
- }
- GNUNET_assert (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
- return GNUNET_OK;
-}
-
-
-/**
- * Free @a af data structure
- *
- * @param af list to free
- */
-void
-TALER_EXCHANGEDB_fees_free (struct TALER_EXCHANGEDB_AggregateFees *af)
-{
- while (NULL != af)
- {
- struct TALER_EXCHANGEDB_AggregateFees *next;
-
- next = af->next;
- GNUNET_free (af);
- af = next;
- }
-}
-
-
-/**
- * Find the record valid at time @a now in the fee structure.
- *
- * @param wa wire transfer fee data structure to update
- * @param now timestamp to update fees to
- * @return fee valid at @a now, or NULL if unknown
- */
-static struct TALER_EXCHANGEDB_AggregateFees *
-advance_fees (struct TALER_EXCHANGEDB_WireAccount *wa,
- struct GNUNET_TIME_Absolute now)
-{
- struct TALER_EXCHANGEDB_AggregateFees *af;
-
- af = wa->af;
- while ( (NULL != af) &&
- (af->end_date.abs_value_us < now.abs_value_us) )
- af = af->next;
- return af;
-}
-
-
-/**
- * Update wire transfer fee data structure in @a wa.
- *
- * @param cfg configuration to use
- * @param db_plugin database plugin to use
- * @param wa wire account data structure to update
- * @param now timestamp to update fees to
- * @param session DB session to use
- * @return fee valid at @a now, or NULL if unknown
- */
-struct TALER_EXCHANGEDB_AggregateFees *
-TALER_EXCHANGEDB_update_fees (const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct TALER_EXCHANGEDB_Plugin *db_plugin,
- struct TALER_EXCHANGEDB_WireAccount *wa,
- struct GNUNET_TIME_Absolute now,
- struct TALER_EXCHANGEDB_Session *session)
-{
- enum GNUNET_DB_QueryStatus qs;
- struct TALER_EXCHANGEDB_AggregateFees *af;
-
- af = advance_fees (wa,
- now);
- if (NULL != af)
- return af;
- /* Let's try to load it from disk... */
- wa->af = TALER_EXCHANGEDB_fees_read (cfg,
- wa->method);
- for (struct TALER_EXCHANGEDB_AggregateFees *p = wa->af;
- NULL != p;
- p = p->next)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Persisting fees starting at %s in database\n",
- GNUNET_STRINGS_absolute_time_to_string (p->start_date));
- qs = db_plugin->insert_wire_fee (db_plugin->cls,
- session,
- wa->method,
- p->start_date,
- p->end_date,
- &p->wire_fee,
- &p->closing_fee,
- &p->master_sig);
- if (qs < 0)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- TALER_EXCHANGEDB_fees_free (wa->af);
- wa->af = NULL;
- return NULL;
- }
- }
- af = advance_fees (wa,
- now);
- if (NULL != af)
- return af;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to find current wire transfer fees for `%s' at %s\n",
- wa->method,
- GNUNET_STRINGS_absolute_time_to_string (now));
- return NULL;
-}
-
-
-/* end of exchangedb_fees.c */
diff --git a/src/exchangedb/exchangedb_signkeys.c b/src/exchangedb/exchangedb_signkeys.c
deleted file mode 100644
index b1e8aad54..000000000
--- a/src/exchangedb/exchangedb_signkeys.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014, 2015, 2016, 2020 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/>
-*/
-/**
- * @file exchangedb/exchangedb_signkeys.c
- * @brief I/O operations for the Exchange's private online signing keys
- * @author Florian Dold
- * @author Benedikt Mueller
- * @author Sree Harsha Totakura
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_exchangedb_lib.h"
-
-
-/**
- * Closure for the #signkeys_iterate_dir_iter().
- */
-struct SignkeysIterateContext
-{
-
- /**
- * Function to call on each signing key.
- */
- TALER_EXCHANGEDB_SigningKeyIterator it;
-
- /**
- * Closure for @e it.
- */
- void *it_cls;
-};
-
-
-/**
- * Function called on each file in the directory with our signing
- * keys. Parses the file and calls the iterator from @a cls.
- *
- * @param cls the `struct SignkeysIterateContext *`
- * @param filename name of the file to parse
- * @return #GNUNET_OK to continue,
- * #GNUNET_NO to stop iteration without error,
- * #GNUNET_SYSERR to stop iteration with error
- */
-static int
-signkeys_iterate_dir_iter (void *cls,
- const char *filename)
-{
- struct SignkeysIterateContext *skc = cls;
- ssize_t nread;
- struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP issue;
-
- nread = GNUNET_DISK_fn_read (filename,
- &issue,
- sizeof (struct
- TALER_EXCHANGEDB_PrivateSigningKeyInformationP));
- if (nread != sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Invalid signkey file `%s': wrong size (%d, expected %u)\n",
- filename,
- (int) nread,
- (unsigned int) sizeof (struct
- TALER_EXCHANGEDB_PrivateSigningKeyInformationP));
- return GNUNET_OK;
- }
- if (0 == GNUNET_TIME_absolute_get_remaining
- (GNUNET_TIME_absolute_ntoh (issue.issue.expire)).rel_value_us)
- {
- if (0 != unlink (filename))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "unlink",
- filename);
- return GNUNET_OK; /* yes, we had an error, but continue to iterate anyway */
- }
- /* Expired file deleted, continue to iterate -without- calling iterator
- as this key is expired */
- return GNUNET_OK;
- }
- return skc->it (skc->it_cls,
- filename,
- &issue);
-}
-
-
-/**
- * Call @a it for each signing key found in the @a exchange_base_dir.
- *
- * @param exchange_base_dir base directory for the exchange,
- * the signing keys must be in the #TALER_EXCHANGEDB_DIR_SIGNING_KEYS
- * subdirectory
- * @param it function to call on each signing key
- * @param it_cls closure for @a it
- * @return number of files found (may not match
- * number of keys given to @a it as malformed
- * files are simply skipped), -1 on error
- */
-int
-TALER_EXCHANGEDB_signing_keys_iterate (const char *exchange_base_dir,
- TALER_EXCHANGEDB_SigningKeyIterator it,
- void *it_cls)
-{
- struct SignkeysIterateContext skc = {
- .it = it,
- .it_cls = it_cls
- };
- char *signkey_dir;
- int ret;
-
- GNUNET_asprintf (&signkey_dir,
- "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS,
- exchange_base_dir);
- ret = GNUNET_DISK_directory_scan (signkey_dir,
- &signkeys_iterate_dir_iter,
- &skc);
- GNUNET_free (signkey_dir);
- return ret;
-}
-
-
-/**
- * Exports a signing key to the given file.
- *
- * @param exchange_base_dir base directory for the keys
- * @param start start time of the validity for the key
- * @param ski the signing key
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure.
- */
-int
-TALER_EXCHANGEDB_signing_key_write (
- const char *exchange_base_dir,
- struct GNUNET_TIME_Absolute start,
- const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski)
-{
- char *skf;
- ssize_t nwrite;
-
- GNUNET_asprintf (&skf,
- "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS
- DIR_SEPARATOR_STR "%llu",
- exchange_base_dir,
- (unsigned long long) start.abs_value_us);
- if (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (skf))
- {
- int eno;
-
- eno = errno;
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "mkdir (for file)",
- skf);
- errno = eno;
- return GNUNET_SYSERR;
- }
- nwrite = GNUNET_DISK_fn_write (skf,
- ski,
- sizeof (struct
- TALER_EXCHANGEDB_PrivateSigningKeyInformationP),
- GNUNET_DISK_PERM_USER_WRITE
- | GNUNET_DISK_PERM_USER_READ);
- if (sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP) !=
- (size_t) nwrite)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "write",
- skf);
- GNUNET_free (skf);
- return GNUNET_SYSERR;
- }
- GNUNET_free (skf);
- return GNUNET_OK;
-}
-
-
-/* end of exchangedb_signkeys.c */
diff --git a/src/exchangedb/test_exchangedb_auditors.c b/src/exchangedb/test_exchangedb_auditors.c
deleted file mode 100644
index 2af1776aa..000000000
--- a/src/exchangedb/test_exchangedb_auditors.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2016 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/>
-*/
-/**
- * @file exchangedb/test_exchangedb_auditors.c
- * @brief test cases for some functions in exchangedb/exchangedb_auditorkeys.c
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet/gnunet_util_lib.h"
-#include "taler_signatures.h"
-#include "taler_exchangedb_lib.h"
-
-
-#define RSA_KEY_SIZE 1024
-
-
-#define EXITIF(cond) \
- do { \
- if (cond) { GNUNET_break (0); goto EXITIF_exit; } \
- } while (0)
-
-
-static struct TALER_AuditorPublicKeyP want_apub;
-
-static struct TALER_AuditorSignatureP want_asigs;
-
-static struct TALER_MasterPublicKeyP want_mpub;
-
-static struct TALER_DenominationKeyValidityPS want_dki;
-
-
-/**
- * @brief Function called with auditor information.
- *
- * @param cls NULL
- * @param apub the auditor's public key
- * @param auditor_url URL of the auditor
- * @param mpub the exchange's public key (as expected by the auditor)
- * @param dki_len length of @a asig and @a dki arrays
- * @param asigs array of the auditor's signatures over the @a dks, of length @a dki_len
- * @param dki array of denomination coin data signed by the auditor, of length @a dki_len
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_NO to stop iteration with no error,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-auditor_cb (void *cls,
- const struct TALER_AuditorPublicKeyP *apub,
- const char *auditor_url,
- const struct TALER_MasterPublicKeyP *mpub,
- unsigned int dki_len,
- const struct TALER_AuditorSignatureP *asigs,
- const struct TALER_DenominationKeyValidityPS *dki)
-{
- GNUNET_assert (NULL == cls);
- if (0 != strcmp (auditor_url,
- "http://auditor/"))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (1 != dki_len)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 != GNUNET_memcmp (&want_apub,
- apub))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 != GNUNET_memcmp (&want_mpub,
- mpub))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 != GNUNET_memcmp (&want_asigs,
- asigs))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 != GNUNET_memcmp (&want_dki,
- dki))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-int
-main (int argc,
- const char *const argv[])
-{
- char *tmpfile = NULL;
- char *tmpdir;
- struct GNUNET_CONFIGURATION_Handle *cfg = NULL;
- int ret;
-
- (void) argc;
- (void) argv;
- ret = 1;
- GNUNET_log_setup ("test-exchangedb-auditors",
- "WARNING",
- NULL);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &want_apub,
- sizeof (want_apub));
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &want_asigs,
- sizeof (want_asigs));
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &want_mpub,
- sizeof (want_mpub));
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &want_dki,
- sizeof (struct TALER_DenominationKeyValidityPS));
- EXITIF (NULL == (tmpdir = GNUNET_DISK_mkdtemp ("test_exchangedb_auditors")));
- GNUNET_asprintf (&tmpfile,
- "%s/%s",
- tmpdir,
- "testauditor");
- EXITIF (GNUNET_OK !=
- TALER_EXCHANGEDB_auditor_write (tmpfile,
- &want_apub,
- "http://auditor/",
- &want_asigs,
- &want_mpub,
- 1,
- &want_dki));
- cfg = GNUNET_CONFIGURATION_create ();
-
- GNUNET_CONFIGURATION_set_value_string (cfg,
- "exchangedb",
- "AUDITOR_BASE_DIR",
- tmpdir);
- EXITIF (1 !=
- TALER_EXCHANGEDB_auditor_iterate (cfg,
- &auditor_cb,
- NULL));
- ret = 0;
-EXITIF_exit:
- if (NULL != tmpdir)
- {
- (void) GNUNET_DISK_directory_remove (tmpdir);
- GNUNET_free (tmpdir);
- }
- if (NULL != cfg)
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (tmpfile);
- return ret;
-}
diff --git a/src/exchangedb/test_exchangedb_denomkeys.c b/src/exchangedb/test_exchangedb_denomkeys.c
deleted file mode 100644
index 6a653c7f5..000000000
--- a/src/exchangedb/test_exchangedb_denomkeys.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2017 Taler Systems SA (and other contributing authors)
-
- 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/>
-*/
-/**
- * @file exchangedb/test_exchangedb_denomkeys.c
- * @brief test cases for some functions in exchangedb/exchangedb_denomkeys.c
- * @author Sree Harsha Totakura <sreeharsha@totakura.in>
- */
-#include "platform.h"
-#include "gnunet/gnunet_util_lib.h"
-#include "taler_signatures.h"
-#include "taler_exchangedb_lib.h"
-
-#define RSA_KEY_SIZE 1024
-
-
-#define EXITIF(cond) \
- do { \
- if (cond) { GNUNET_break (0); goto EXITIF_exit; } \
- } while (0)
-
-
-/**
- * @brief Iterator called on denomination key.
- *
- * @param cls closure with expected DKI
- * @param dki the denomination key
- * @param alias coin alias
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_NO to stop iteration with no error,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-dki_iter (void *cls,
- const char *alias,
- const struct TALER_EXCHANGEDB_DenominationKey *dki)
-{
- const struct TALER_EXCHANGEDB_DenominationKey *exp = cls;
-
- (void) alias;
- if (0 != GNUNET_memcmp (&exp->issue,
- &dki->issue))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 !=
- GNUNET_CRYPTO_rsa_private_key_cmp (exp->denom_priv.rsa_private_key,
- dki->denom_priv.rsa_private_key))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 !=
- GNUNET_CRYPTO_rsa_public_key_cmp (exp->denom_pub.rsa_public_key,
- dki->denom_pub.rsa_public_key))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
- * @brief Iterator called on revoked denomination key.
- *
- * @param cls closure with expected DKI
- * @param denom_hash hash of the revoked denomination key
- * @param revocation_master_sig non-NULL if @a dki was revoked
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_NO to stop iteration with no error,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-dki_iter_revoked (void *cls,
- const struct GNUNET_HashCode *denom_hash,
- const struct TALER_MasterSignatureP *revocation_master_sig)
-{
- const struct TALER_EXCHANGEDB_DenominationKey *exp = cls;
-
- if (NULL == revocation_master_sig)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 != GNUNET_memcmp (denom_hash,
- &exp->issue.properties.denom_hash))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-int
-main (int argc,
- const char *const argv[])
-{
- struct TALER_EXCHANGEDB_DenominationKey dki;
- void *enc;
- size_t enc_size;
- struct TALER_EXCHANGEDB_DenominationKey dki_read;
- struct TALER_MasterPrivateKeyP master_priv;
- struct TALER_MasterPublicKeyP master_pub;
- void *enc_read;
- size_t enc_read_size;
- char *tmpfile;
- char *tmpdir;
- char *revdir;
- int ret;
- struct GNUNET_TIME_Absolute start;
-
- (void) argc;
- (void) argv;
- ret = 1;
- GNUNET_log_setup ("test-exchangedb-denomkeys",
- "WARNING",
- NULL);
- enc = NULL;
- enc_read = NULL;
- tmpfile = NULL;
- dki.denom_priv.rsa_private_key = NULL;
- dki_read.denom_priv.rsa_private_key = NULL;
- GNUNET_CRYPTO_eddsa_key_create (&master_priv.eddsa_priv);
- GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv,
- &master_pub.eddsa_pub);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &dki.issue,
- sizeof (struct
- TALER_EXCHANGEDB_DenominationKeyInformationP));
- dki.denom_priv.rsa_private_key
- = GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE);
- dki.denom_pub.rsa_public_key
- = GNUNET_CRYPTO_rsa_private_key_get_public (dki.denom_priv.rsa_private_key);
- enc_size = GNUNET_CRYPTO_rsa_private_key_encode (
- dki.denom_priv.rsa_private_key,
- &enc);
- EXITIF (NULL == (tmpdir = GNUNET_DISK_mkdtemp ("test_exchangedb_dki")));
- start = GNUNET_TIME_absolute_ntoh (dki.issue.properties.start);
- GNUNET_asprintf (&tmpfile,
- "%s/%s/%s/%llu",
- tmpdir,
- TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS,
- "cur-unit-uuid",
- (unsigned long long) start.abs_value_us);
- GNUNET_asprintf (&revdir,
- "%s/revocations/",
- tmpdir);
- EXITIF (GNUNET_OK !=
- TALER_EXCHANGEDB_denomination_key_write (tmpfile,
- &dki));
- EXITIF (GNUNET_OK !=
- TALER_EXCHANGEDB_denomination_key_read (tmpfile,
- &dki_read));
- EXITIF (1 !=
- TALER_EXCHANGEDB_denomination_keys_iterate (tmpdir,
- &dki_iter,
- &dki));
-
- EXITIF (GNUNET_OK !=
- TALER_EXCHANGEDB_denomination_key_revoke (revdir,
- &dki.issue.properties.
- denom_hash,
- &master_priv));
- EXITIF (1 !=
- TALER_EXCHANGEDB_revocations_iterate (revdir,
- &master_pub,
- &dki_iter_revoked,
- &dki));
- GNUNET_free (revdir);
-
- enc_read_size = GNUNET_CRYPTO_rsa_private_key_encode (
- dki_read.denom_priv.rsa_private_key,
- &enc_read);
- EXITIF (enc_size != enc_read_size);
- EXITIF (0 != memcmp (enc,
- enc_read,
- enc_size));
- ret = 0;
-
-EXITIF_exit:
- GNUNET_free (enc);
- GNUNET_free (tmpfile);
- if (NULL != tmpdir)
- {
- (void) GNUNET_DISK_directory_remove (tmpdir);
- GNUNET_free (tmpdir);
- }
- GNUNET_free (enc_read);
- if (NULL != dki.denom_priv.rsa_private_key)
- GNUNET_CRYPTO_rsa_private_key_free (dki.denom_priv.rsa_private_key);
- if (NULL != dki.denom_pub.rsa_public_key)
- GNUNET_CRYPTO_rsa_public_key_free (dki.denom_pub.rsa_public_key);
- if (NULL != dki_read.denom_priv.rsa_private_key)
- GNUNET_CRYPTO_rsa_private_key_free (dki_read.denom_priv.rsa_private_key);
- if (NULL != dki_read.denom_pub.rsa_public_key)
- GNUNET_CRYPTO_rsa_public_key_free (dki_read.denom_pub.rsa_public_key);
- return ret;
-}
diff --git a/src/exchangedb/test_exchangedb_fees.c b/src/exchangedb/test_exchangedb_fees.c
deleted file mode 100644
index f86dfe5c5..000000000
--- a/src/exchangedb/test_exchangedb_fees.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2017 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/>
-*/
-/**
- * @file exchangedb/test_exchangedb_fees.c
- * @brief test cases for functions in exchangedb/exchangedb_fees.c
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet/gnunet_util_lib.h"
-#include "taler_signatures.h"
-#include "taler_exchangedb_lib.h"
-
-
-/**
- * Sign @a af with @a priv
- *
- * @param[in|out] af fee structure to sign
- * @param priv private key to use for signing
- */
-static void
-sign_af (struct TALER_EXCHANGEDB_AggregateFees *af,
- const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
-{
- struct TALER_MasterWireFeePS wf;
-
- TALER_EXCHANGEDB_fees_2_wf ("test",
- af,
- &wf);
- GNUNET_CRYPTO_eddsa_sign (priv,
- &wf,
- &af->master_sig.eddsa_signature);
-}
-
-
-int
-main (int argc,
- const char *const argv[])
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- struct TALER_EXCHANGEDB_AggregateFees *af;
- struct TALER_EXCHANGEDB_AggregateFees *n;
- struct TALER_MasterPublicKeyP master_pub;
- struct GNUNET_CRYPTO_EddsaPrivateKey priv;
- char *tmpdir;
- char *tmpfile = NULL;
- int ret;
- unsigned int year;
-
- (void) argc;
- (void) argv;
- GNUNET_log_setup ("test-exchangedb-fees",
- "WARNING",
- NULL);
- tmpdir = GNUNET_DISK_mkdtemp ("test_exchangedb_fees");
- if (NULL == tmpdir)
- return 77; /* skip test */
- GNUNET_CRYPTO_eddsa_key_create (&priv);
- GNUNET_CRYPTO_eddsa_key_get_public (&priv,
- &master_pub.eddsa_pub);
- cfg = GNUNET_CONFIGURATION_create ();
- GNUNET_CONFIGURATION_set_value_string (cfg,
- "exchangedb",
- "WIREFEE_BASE_DIR",
- tmpdir);
- GNUNET_asprintf (&tmpfile,
- "%s/%s.fee",
- tmpdir,
- "test");
- ret = 0;
- af = GNUNET_new (struct TALER_EXCHANGEDB_AggregateFees);
- year = GNUNET_TIME_get_current_year ();
- af->start_date = GNUNET_TIME_year_to_time (year);
- af->end_date = GNUNET_TIME_year_to_time (year + 1);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount ("EUR:1.0",
- &af->wire_fee));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount ("EUR:1.0",
- &af->closing_fee));
- sign_af (af,
- &priv);
- n = GNUNET_new (struct TALER_EXCHANGEDB_AggregateFees);
- n->start_date = GNUNET_TIME_year_to_time (year + 1);
- n->end_date = GNUNET_TIME_year_to_time (year + 2);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount ("EUR:0.1",
- &n->wire_fee));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount ("EUR:0.1",
- &n->closing_fee));
- sign_af (n,
- &priv);
- af->next = n;
-
- if (GNUNET_OK !=
- TALER_EXCHANGEDB_fees_write (tmpfile,
- "test",
- af))
- {
- GNUNET_break (0);
- ret = 1;
- }
- TALER_EXCHANGEDB_fees_free (af);
- GNUNET_free (tmpfile);
- af = TALER_EXCHANGEDB_fees_read (cfg,
- "test");
- if (NULL == af)
- {
- GNUNET_break (0);
- ret = 1;
- }
- else
- {
- for (struct TALER_EXCHANGEDB_AggregateFees *p = af;
- NULL != p;
- p = p->next)
- {
- struct TALER_MasterWireFeePS wf;
-
- TALER_EXCHANGEDB_fees_2_wf ("test",
- p,
- &wf);
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_WIRE_FEES,
- &wf,
- &p->master_sig.eddsa_signature,
- &master_pub.eddsa_pub))
- {
- GNUNET_break (0);
- ret = 1;
- }
- }
- TALER_EXCHANGEDB_fees_free (af);
- }
-
- (void) GNUNET_DISK_directory_remove (tmpdir);
- GNUNET_free (tmpdir);
- GNUNET_CONFIGURATION_destroy (cfg);
- return ret;
-}
diff --git a/src/exchangedb/test_exchangedb_signkeys.c b/src/exchangedb/test_exchangedb_signkeys.c
deleted file mode 100644
index 3969c9708..000000000
--- a/src/exchangedb/test_exchangedb_signkeys.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2016 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/>
-*/
-/**
- * @file exchangedb/test_exchangedb_signkeys.c
- * @brief test cases for some functions in exchangedb/exchangedb_signkeys.c
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet/gnunet_util_lib.h"
-#include "taler_signatures.h"
-#include "taler_exchangedb_lib.h"
-
-
-#define EXITIF(cond) \
- do { \
- if (cond) { GNUNET_break (0); goto EXITIF_exit; } \
- } while (0)
-
-
-/**
- * @brief Iterator over signing keys.
- *
- * @param cls closure
- * @param filename name of the file the key came from
- * @param ski the sign key
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_NO to stop iteration with no error,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-ski_iter (void *cls,
- const char *filename,
- const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski)
-{
- const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *exp = cls;
-
- (void) filename;
- if (0 != GNUNET_memcmp (ski,
- exp))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-int
-main (int argc,
- const char *const argv[])
-{
- struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP ski;
- struct GNUNET_TIME_Absolute now;
- char *tmpfile;
- int ret;
-
- (void) argc;
- (void) argv;
- ret = 1;
- tmpfile = NULL;
- GNUNET_log_setup ("test-exchangedb-signkeys",
- "WARNING",
- NULL);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &ski,
- sizeof (struct
- TALER_EXCHANGEDB_PrivateSigningKeyInformationP));
- now = GNUNET_TIME_absolute_get ();
- EXITIF (NULL == (tmpfile = GNUNET_DISK_mkdtemp ("test_exchangedb_ski")));
- EXITIF (GNUNET_OK !=
- TALER_EXCHANGEDB_signing_key_write (tmpfile,
- now,
- &ski));
- EXITIF (1 !=
- TALER_EXCHANGEDB_signing_keys_iterate (tmpfile,
- &ski_iter,
- &ski));
- ret = 0;
-EXITIF_exit:
- if (NULL != tmpfile)
- {
- (void) GNUNET_DISK_directory_remove (tmpfile);
- GNUNET_free (tmpfile);
- }
- return ret;
-}