Merge branch 'master' of ssh://taler.net:/var/git/exchange

This commit is contained in:
Christian Grothoff 2016-04-15 15:00:26 +02:00
commit 74e237164c
2282 changed files with 10715 additions and 12284 deletions

26
.gitignore vendored
View File

@ -27,16 +27,24 @@ GPATH
GRTAGS
GTAGS
*.swp
src/lib/test_mint_api
src/lib/test_exchange_api
doc/doxygen/doxygen_sqlite3.db
src/mint-lib/test_mint_api
src/mint-tools/taler-auditor-sign
src/mint-tools/taler-mint-dbinit
src/mint-tools/taler-mint-keycheck
src/mint-tools/taler-mint-keyup
src/mint-tools/taler-mint-reservemod
src/mint-tools/taler-mint-sepa
src/mintdb/perf-mintdb
src/bank-lib/test_bank_api
src/exchange-lib/test_exchange_api
src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/live-keys/
src/exchange/taler-exchange-aggregator
src/exchange/test_taler_exchange_aggregator-postgres
src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/live-keys/
src/exchange-tools/taler-auditor-sign
src/exchange-tools/taler-exchange-dbinit
src/exchange-tools/taler-exchange-keycheck
src/exchange-tools/taler-exchange-keyup
src/exchange-tools/taler-exchange-reservemod
src/exchange-tools/taler-exchange-wire
src/exchangedb/perf-exchangedb
src/json/test_json
src/wire/test_sepa_wireformat
src/wire/test_wire_plugin
src/pq/test_pq
src/util/test_amount
src/util/test_crypto

View File

@ -2,3 +2,10 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/include
SUBDIRS = src doc
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = AUTHORS
app:
mkdir -p $(PACKAGE)-$(VERSION)-app
tar cf - configure.ac AUTHORS README doc/*.1 doc/*.5 doc/Makefile.am Makefile.am `find src/ -name "*.c" -o -name "*.h" -o -name Makefile.am` | (cd $(PACKAGE)-$(VERSION)-app ; tar xf -)
tar cf $(PACKAGE)-$(VERSION)-app.tgz $(PACKAGE)-$(VERSION)-app
rm -rf $(PACKAGE)-$(VERSION)-app

48
README
View File

@ -6,7 +6,7 @@ What is Taler?
Taler is an electronic payment system providing the ability to pay
anonymously using digital cash. Taler consists of a network protocol
definition (using a RESTful API over HTTP), a Mint (which creates
definition (using a RESTful API over HTTP), a Exchange (which creates
digital coins), a Wallet (which allows customers to manage, store and
spend digital coins), and a Merchant website which allows customers to
spend their digital coins. Naturally, each Merchant is different, but
@ -19,7 +19,7 @@ is free software and a GNU package (http://www.gnu.org/).
This is not even a release yet, but some raw development prototype
that does not work yet. This package also only includes the Taler
mint, not the other components of the system.
exchange, not the other components of the system.
Documentation about Taler can be found at http://taler.net/.
@ -27,7 +27,7 @@ Documentation about Taler can be found at http://taler.net/.
Dependencies:
=============
These are the direct dependencies for running a Taler mint:
These are the direct dependencies for running a Taler exchange:
- GNUnet >= 0.10.2
- GNU libmicrohttpd >= 0.9.38
@ -48,50 +48,50 @@ src/util/
src/pq/
-- Postgres-specific utility functions
src/mintdb/
-- Mint database backend (with DB-specific plugins)
src/exchangedb/
-- Exchange database backend (with DB-specific plugins)
src/mint/
-- taler mint server
src/exchange/
-- taler exchange server
src/mint-tools/
-- taler mint helper programs
src/exchange-tools/
-- taler exchange helper programs
src/mint-lib/
-- libtalermint: C API to issue HTTP requests to mint
src/exchange-lib/
-- libtalerexchange: C API to issue HTTP requests to exchange
Getting Started
==============
The following steps illustrate how to set up a mint HTTP server.
They take as a stub for configuring the mint the content of 'contrib/mint-template/config/'.
The following steps illustrate how to set up a exchange HTTP server.
They take as a stub for configuring the exchange the content of 'contrib/exchange-template/config/'.
1) Create a 'test/' directory and copy the stubs in it:
mkdir -p test/config/
cp mint/contrib/mint-template/config/* test/config/
cp exchange/contrib/exchange-template/config/* test/config/
cd test/
2) Create the mint's master with the tool 'gnunet-ecc':
2) Create the exchange's master with the tool 'gnunet-ecc':
gnunet-ecc -g1 master.priv
3) Edit config/mint-common.conf by replacing the right value on the line with the
3) Edit config/exchange-common.conf by replacing the right value on the line with the
MASTER_PUBLIC_KEY entry with the fresh generated (ASCII version of) master.priv.
This ASCII version is obtained by issuing:
gnunet-ecc -p master.priv
4) Generate other mint related keys ('denomination' and 'signing' keys), by issuing:
4) Generate other exchange related keys ('denomination' and 'signing' keys), by issuing:
taler-mint-keyup -d `pwd` -m master.priv
taler-exchange-keyup -d `pwd` -m master.priv
5) Check with:
taler-mint-keycheck -d `pwd`
taler-exchange-keycheck -d `pwd`
6) A mint needs a database to operate, so the following instructions relate to
6) A exchange needs a database to operate, so the following instructions relate to
how to set up PostgreSQL. On debian, the two packages needed are:
* postgresql
@ -99,8 +99,8 @@ how to set up PostgreSQL. On debian, the two packages needed are:
For other operating systems, please refer to the relevant documentation.
In this settlement, the mint wll use a database called 'talercheck' and will
run under the username through which 'taler-mint-httpd' is launched. Thus assuming
In this settlement, the exchange wll use a database called 'talercheck' and will
run under the username through which 'taler-exchange-httpd' is launched. Thus assuming
that this user is 'demo', we need to create a 'demo' role for postgresql and make
him the owner of 'talercheck' database.
@ -117,7 +117,7 @@ CREATE DATABASE talercheck OWNER demo;
# quit with CTRL-D
7) If any previous step has been successful, it is now possbile to start up the
mint web server (by default it will listen on port 4241); issue:
exchange web server (by default it will listen on port 4241); issue:
taler-mint-httpd -d `pwd` # assuming we did not move outside of the 'test' directory
taler-exchange-httpd -d `pwd` # assuming we did not move outside of the 'test' directory

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
#
# This file is part of TALER
# Copyright (C) 2014, 2015 GNUnet e.V.
# Copyright (C) 2014, 2015, 2016 GNUnet e.V. and Inria
#
# 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
@ -17,8 +17,8 @@
#
#
AC_PREREQ([2.69])
AC_INIT([taler-mint], [0.0.0], [taler-bug@gnunet.org])
AC_CONFIG_SRCDIR([src/util/json.c])
AC_INIT([taler-exchange], [0.0.0], [taler-bug@gnunet.org])
AC_CONFIG_SRCDIR([src/util/util.c])
AC_CONFIG_HEADERS([taler_config.h])
# support for non-recursive builds
AM_INIT_AUTOMAKE([subdir-objects])
@ -354,14 +354,15 @@ AC_CONFIG_FILES([Makefile
doc/Makefile
doc/doxygen/Makefile
src/Makefile
src/include/Makefile
src/util/Makefile
src/pq/Makefile
src/bank-lib/Makefile
src/exchangedb/Makefile
src/exchange/Makefile
src/exchange-tools/Makefile
src/exchange-lib/Makefile
src/include/Makefile
src/json/Makefile
src/pq/Makefile
src/util/Makefile
src/wire/Makefile
src/mintdb/Makefile
src/mint/Makefile
src/mint-tools/Makefile
src/mint-lib/Makefile
])
AC_OUTPUT

2
contrib/coverage.sh Executable file → Normal file
View File

@ -1,5 +1,5 @@
#!/bin/sh
# Run from 'taler-mint/' top-level directory to generate
# Run from 'taler-exchange/' top-level directory to generate
# code coverage data.
TOP=`pwd`
mkdir -p doc/coverage/

View File

@ -0,0 +1 @@
This directory is a template for the exchange directory.

View File

@ -0,0 +1,43 @@
[exchange]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
# Wire format supported by the exchange, case-insensitive.
# Examples for formats include 'test' for testing and 'sepa' (for EU IBAN).
WIREFORMAT = SEPA
# HTTP port the exchange listens to
PORT = 4241
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = NEGTF62MNGVPZNW19V7S3CRS9D7K04MAHDGX3N6WY2NXREN26J80
# How to access our database
DB = postgres
# Is this for testing, or for real?
TESTRUN = YES
[exchangedb-postgres]
DB_CONN_STR = "postgres:///talercheck"
[wire-incoming-sepa]
SEPA_RESPONSE_FILE = "sepa.json"
[wire-outgoing-sepa]
SEPA_RESPONSE_FILE = "sepa.json"
[wire-incoming-test]
# What is the main website of the bank?
BANK_URI = "https://bank/"
# Into which account at the 'bank' should incoming
# wire transfers be made?
BANK_ACCOUNT_NUMBER = 2
[wire-outgoing-test]
# What is the main website of the bank?
BANK_URI = "https://bank/"
# From which account at the 'bank' should outgoing
# wire transfers be made?
BANK_ACCOUNT_NUMBER = 2

View File

@ -1,4 +1,4 @@
[mint_keys]
[exchange_keys]
# how long is one signkey valid?
signkey_duration = 4 weeks

View File

@ -1 +0,0 @@
This directory is a template for the mint directory.

View File

@ -1,28 +0,0 @@
[mint]
# Currency supported by the mint (can only be one)
CURRENCY = EUR
# Wire format supported by the mint, case-insensitive.
# Examples for formats include 'test' for testing and 'sepa' (for EU IBAN).
WIREFORMAT = SEPA
# HTTP port the mint listens to
PORT = 4241
# Master public key used to sign the mint's various keys
MASTER_PUBLIC_KEY = NEGTF62MNGVPZNW19V7S3CRS9D7K04MAHDGX3N6WY2NXREN26J80
# How to access our database
DB = postgres
TESTRUN = YES
[mintdb-postgres]
DB_CONN_STR = "postgres:///talercheck"
[mint-wire-sepa]
SEPA_RESPONSE_FILE = "sepa.json"
[mint-wire-test]
REDIRECT_URL = "http://test/"

View File

@ -4,11 +4,13 @@ SUBDIRS = . doxygen
man_MANS = \
taler-auditor-sign.1 \
taler-mint-dbinit.1 \
taler-mint-httpd.1 \
taler-mint-keyup.1 \
taler-mint-keycheck.1 \
taler-mint-reservemod.1 \
taler-exchange-aggregator.1 \
taler-exchange-dbinit.1 \
taler-exchange-httpd.1 \
taler-exchange-keyup.1 \
taler-exchange-keycheck.1 \
taler-exchange-reservemod.1 \
taler-exchange-wire.1 \
taler.conf.5
EXTRA_DIST = \

View File

@ -14,10 +14,10 @@ Naming conventions:
SHOULD NOT be included from outside of their own directory
+ end in "_lib" for "simple" libraries
+ end in "_plugin" for plugins
+ end in "_service" for libraries accessing a service, i.e. the mint
+ end in "_service" for libraries accessing a service, i.e. the exchange
* binaries:
+ taler-mint-xxx: mint programs
+ taler-exchange-xxx: exchange programs
+ taler-merchant-xxx: merchant programs (demos)
+ taler-wallet-xxx: wallet programs
+ plugins should be libtaler_plugin_xxx_yyy.so: plugin yyy for API xxx
@ -25,16 +25,16 @@ Naming conventions:
* logging
+ tools use their full name in GNUNET_log_setup
(i.e. 'taler-mint-keyup') and log using plain 'GNUNET_log'.
(i.e. 'taler-exchange-keyup') and log using plain 'GNUNET_log'.
+ pure libraries (without associated service) use 'GNUNET_log_from'
with the component set to their library name (without lib or '.so'),
which should also be their directory name (i.e. 'util')
+ plugin libraries (without associated service) use 'GNUNET_log_from'
with the component set to their type and plugin name (without lib or '.so'),
which should also be their directory name (i.e. 'mintdb-postgres')
which should also be their directory name (i.e. 'exchangedb-postgres')
+ libraries with associated service) use 'GNUNET_log_from'
with the name of the service, which should also be their
directory name (i.e. 'mint')
directory name (i.e. 'exchange')
* configuration
+ same rules as for GNUnet
@ -44,7 +44,7 @@ Naming conventions:
MUST match the subdirectory of src/ in which the symbol is defined
+ from libtalerutil start just with TALER_, without subsystemname
+ if scope is ONE binary and symbols are not in a shared library,
use binary-specific prefix (such as TMH = taler-mint-httpd) for
use binary-specific prefix (such as TMH = taler-exchange-httpd) for
globals, possibly followed by the subsystem (TMH_DB_xxx).
* structs:

View File

@ -5,14 +5,14 @@ all:
"\tmake full - full documentation with dependency graphs (slow)\n" \
"\tmake fast - fast mode without dependency graphs"
full: taler-mint.doxy
full: taler-exchange.doxy
doxygen $<
fast: taler-mint.doxy
fast: taler-exchange.doxy
sed 's/\(HAVE_DOT.*=\).*/\1 NO/' $< | doxygen -
clean:
rm -rf html
EXTRA_DIST = taler-mint.doxy
EXTRA_DIST = taler-exchange.doxy

View File

@ -4,7 +4,7 @@
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "GNU Taler: Mint"
PROJECT_NAME = "GNU Taler: Exchange"
PROJECT_NUMBER = 0.0
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = YES

0
doc/logos/fonts/OldNewspaperTypes.ttf Executable file → Normal file
View File

View File

@ -9025,7 +9025,7 @@
organization="Internet Engineering Task Force",
year=1978,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc748.txt",
}
@ -13671,7 +13671,7 @@
organization="Internet Engineering Task Force",
year=1989,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1097.txt",
}
@ -14377,7 +14377,7 @@
organization="Internet Engineering Task Force",
year=1990,
month=apr,
day="1",
day="1",
note="Updated by RFCs 2549, 6214",
url="http://www.ietf.org/rfc/rfc1149.txt",
}
@ -15260,7 +15260,7 @@
organization="Internet Engineering Task Force",
year=1991,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1216.txt",
}
@ -15274,7 +15274,7 @@
organization="Internet Engineering Task Force",
year=1991,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1217.txt",
}
@ -16551,7 +16551,7 @@
organization="Internet Engineering Task Force",
year=1992,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1313.txt",
}
@ -18223,7 +18223,7 @@
organization="Internet Engineering Task Force",
year=1993,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1437.txt",
}
@ -18237,7 +18237,7 @@
organization="Internet Engineering Task Force",
year=1993,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1438.txt",
}
@ -20478,7 +20478,7 @@
organization="Internet Engineering Task Force",
year=1994,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1605.txt",
}
@ -20492,7 +20492,7 @@
organization="Internet Engineering Task Force",
year=1994,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1606.txt",
}
@ -20506,7 +20506,7 @@
organization="Internet Engineering Task Force",
year=1994,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1607.txt",
}
@ -22753,7 +22753,7 @@
organization="Internet Engineering Task Force",
year=1995,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1776.txt",
}
@ -24716,7 +24716,7 @@
organization="Internet Engineering Task Force",
year=1996,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1924.txt",
}
@ -24730,7 +24730,7 @@
organization="Internet Engineering Task Force",
year=1996,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1925.txt",
}
@ -24744,7 +24744,7 @@
organization="Internet Engineering Task Force",
year=1996,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1926.txt",
}
@ -24758,7 +24758,7 @@
organization="Internet Engineering Task Force",
year=1996,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc1927.txt",
}
@ -27077,7 +27077,7 @@
organization="Internet Engineering Task Force",
year=1997,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2100.txt",
}
@ -30038,7 +30038,7 @@
organization="Internet Engineering Task Force",
year=1998,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2321.txt",
}
@ -30052,7 +30052,7 @@
organization="Internet Engineering Task Force",
year=1998,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2322.txt",
}
@ -30066,7 +30066,7 @@
organization="Internet Engineering Task Force",
year=1998,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2323.txt",
}
@ -30080,7 +30080,7 @@
organization="Internet Engineering Task Force",
year=1998,
month=apr,
day="1",
day="1",
note="Updated by RFC 7168",
url="http://www.ietf.org/rfc/rfc2324.txt",
}
@ -30095,7 +30095,7 @@
organization="Internet Engineering Task Force",
year=1998,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2325.txt",
}
@ -33099,7 +33099,7 @@
organization="Internet Engineering Task Force",
year=1999,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2549.txt",
}
@ -33113,7 +33113,7 @@
organization="Internet Engineering Task Force",
year=1999,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2550.txt",
}
@ -33127,7 +33127,7 @@
organization="Internet Engineering Task Force",
year=1999,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2551.txt",
}
@ -36388,7 +36388,7 @@
organization="Internet Engineering Task Force",
year=2000,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc2795.txt",
}
@ -40323,7 +40323,7 @@
organization="Internet Engineering Task Force",
year=2001,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc3091.txt",
}
@ -40337,7 +40337,7 @@
organization="Internet Engineering Task Force",
year=2001,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc3092.txt",
}
@ -40351,7 +40351,7 @@
organization="Internet Engineering Task Force",
year=2001,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc3093.txt",
}
@ -42397,7 +42397,7 @@
organization="Internet Engineering Task Force",
year=2002,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc3251.txt",
}
@ -42411,7 +42411,7 @@
organization="Internet Engineering Task Force",
year=2002,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc3252.txt",
}
@ -45820,7 +45820,7 @@
organization="Internet Engineering Task Force",
year=2003,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc3514.txt",
}
@ -48951,7 +48951,7 @@
organization="Internet Engineering Task Force",
year=2004,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc3751.txt",
}
@ -52675,7 +52675,7 @@
organization="Internet Engineering Task Force",
year=2005,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc4041.txt",
}
@ -52689,7 +52689,7 @@
organization="Internet Engineering Task Force",
year=2005,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc4042.txt",
}
@ -62743,7 +62743,7 @@
organization="Internet Engineering Task Force",
year=2007,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc4824.txt",
}
@ -68094,7 +68094,7 @@
organization="Internet Engineering Task Force",
year=2008,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc5241.txt",
}
@ -68108,7 +68108,7 @@
organization="Internet Engineering Task Force",
year=2008,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc5242.txt",
}
@ -71194,7 +71194,7 @@
@misc{rfc5486,
author="D. Malas and D. Meyer",
title="{Session Peering for Multimedia Interconnect (SPEERMINT) Terminology}",
title="{Session Peering for Multimedia Interconnect (SPEEREXCHANGE) Terminology}",
series="Request for Comments",
number="5486",
howpublished="RFC 5486 (Informational)",
@ -71529,7 +71529,7 @@
organization="Internet Engineering Task Force",
year=2009,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc5513.txt",
}
@ -71543,7 +71543,7 @@
organization="Internet Engineering Task Force",
year=2009,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc5514.txt",
}
@ -75706,7 +75706,7 @@
organization="Internet Engineering Task Force",
year=2010,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc5841.txt",
}
@ -77555,7 +77555,7 @@
organization="Internet Engineering Task Force",
year=2011,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc5984.txt",
}
@ -80463,7 +80463,7 @@
organization="Internet Engineering Task Force",
year=2011,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc6214.txt",
}
@ -80503,7 +80503,7 @@
organization="Internet Engineering Task Force",
year=2011,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc6217.txt",
}
@ -82898,7 +82898,7 @@
@misc{rfc6404,
author="J. Seedorf and S. Niccolini and E. Chen and H. Scholz",
title="{Session PEERing for Multimedia INTerconnect (SPEERMINT) Security Threats and Suggested Countermeasures}",
title="{Session PEERing for Multimedia INTerconnect (SPEEREXCHANGE) Security Threats and Suggested Countermeasures}",
series="Request for Comments",
number="6404",
howpublished="RFC 6404 (Informational)",
@ -82924,7 +82924,7 @@
@misc{rfc6406,
author="D. Malas and J. Livingood",
title="{Session PEERing for Multimedia INTerconnect (SPEERMINT) Architecture}",
title="{Session PEERing for Multimedia INTerconnect (SPEEREXCHANGE) Architecture}",
series="Request for Comments",
number="6406",
howpublished="RFC 6406 (Informational)",
@ -85310,7 +85310,7 @@
organization="Internet Engineering Task Force",
year=2012,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc6592.txt",
}
@ -85324,7 +85324,7 @@
organization="Internet Engineering Task Force",
year=2012,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc6593.txt",
}
@ -89460,7 +89460,7 @@
organization="Internet Engineering Task Force",
year=2013,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc6919.txt",
}
@ -89487,7 +89487,7 @@
organization="Internet Engineering Task Force",
year=2013,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc6921.txt",
}
@ -92639,7 +92639,7 @@
organization="Internet Engineering Task Force",
year=2014,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc7168.txt",
}
@ -92653,7 +92653,7 @@
organization="Internet Engineering Task Force",
year=2014,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc7169.txt",
}
@ -97095,7 +97095,7 @@
organization="Internet Engineering Task Force",
year=2015,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc7511.txt",
}
@ -97135,7 +97135,7 @@
organization="Internet Engineering Task Force",
year=2015,
month=apr,
day="1",
day="1",
url="http://www.ietf.org/rfc/rfc7514.txt",
}
@ -98711,4 +98711,3 @@
month=sep,
url="http://www.ietf.org/rfc/rfc7651.txt",
}

View File

@ -173,3 +173,77 @@
www_pdf_url = {https://www.torproject.org/svn/trunk/doc/design-paper/tor-design.pdf},
www_section = {Anonymous communication},
}
@inbook{BellareRogaway1996,
author="Bellare, Mihir and Rogaway, Phillip",
editor="Maurer, Ueli",
chapter="The Exact Security of Digital Signatures-How to Sign with RSA and Rabin",
title="Advances in Cryptology --- EUROCRYPT '96: International Conference on the Theory and Application of Cryptographic Techniques Saragossa, Spain, May 12--16, 1996 Proceedings",
year="1996",
publisher="Springer Berlin Heidelberg",
address="Berlin, Heidelberg",
pages="399--416",
isbn="978-3-540-68339-1",
doi="10.1007/3-540-68339-9_34",
url_doi="http://dx.doi.org/10.1007/3-540-68339-9_34",
url="http://web.cs.ucdavis.edu/~rogaway/papers/exact.pdf"
}
@article{OneMoreInversion,
author="Bellare and Namprempre and Pointcheval and Semanko",
title="The One-More-RSA-Inversion Problems and the Security of Chaum's Blind Signature Scheme ",
journal="Journal of Cryptology",
volume="16",
number="3",
pages="185--215",
abstract="We introduce a new class of computational problems which we call the ``one-more-RSA-inversion'' problems. Our main result is that two problems in this class, which we call the chosen-target and known-target inversion problems, respectively, have polynomially equivalent computational complexity. We show how this leads to a proof of security for Chaum's RSA-based blind signature scheme in the random oracle model based on the assumed hardness of either of these problems. We define and prove analogous results for ``one-more-discrete-logarithm'' problems. Since the appearence of the preliminary version of this paper, the new problems we have introduced have found other uses as well.",
issn="1432-1378",
doi="10.1007/s00145-002-0120-1",
doi_url="http://dx.doi.org/10.1007/s00145-002-0120-1",
url="https://eprint.iacr.org/2001/002"
}
@misc{cryptoeprint:2001:002,
author = {M. Bellare and C. Namprempre and D. Pointcheval and M. Semanko},
title = {The One-More-RSA-Inversion Problems and the Security of Chaum's Blind Signature Scheme},
howpublished = {Cryptology ePrint Archive, Report 2001/002},
year = {2001},
note = {\url{http://eprint.iacr.org/}},
}
@inbook{RSA-KTIvCTI,
author="Bellare, Mihir and Namprempre, Chanathip and Pointcheval, David and Semanko, Michael",
editor="Syverson, Paul",
chapter="The Power of RSA Inversion Oracles and the Security of Chaum's RSA-Based Blind Signature Scheme",
title="Financial Cryptography: 5th International Conference, FC 2001 Grand Cayman, British West Indies, February 19--22, 2001 Proceedings",
year="2002",
publisher="Springer Berlin Heidelberg",
address="Berlin, Heidelberg",
pages="319--338",
isbn="978-3-540-46088-6",
doi="10.1007/3-540-46088-8_25",
url="https://www.di.ens.fr/~pointche/Documents/Papers/2001_fcA.pdf"
}
@inbook{Coron2000,
author="Coron, Jean-S{\'e}bastien",
editor="Bellare, Mihir",
chapter="On the Exact Security of Full Domain Hash",
title="Advances in Cryptology --- CRYPTO 2000: 20th Annual International Cryptology Conference Santa Barbara, California, USA, August 20--24, 2000 Proceedings",
year="2000",
publisher="Springer Berlin Heidelberg",
address="Berlin, Heidelberg",
pages="229--235",
isbn="978-3-540-44598-2",
doi="10.1007/3-540-44598-6_14",
doi_url="http://dx.doi.org/10.1007/3-540-44598-6_14",
url="https://www.iacr.org/archive/crypto2000/18800229/18800229.pdf"
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
.TH TALER\-AUDITOR\-SIGN 1 "Sep 15, 2015" "GNU Taler"
.TH TALER\-AUDITOR\-SIGN 1 "Mar 15, 2016" "GNU Taler"
.SH NAME
taler\-auditor\-sign \- Sign mint denomination as auditor.
taler\-auditor\-sign \- Sign exchange denomination as auditor.
.SH SYNOPSIS
.B taler\-auditor\-sign
@ -9,7 +9,7 @@ taler\-auditor\-sign \- Sign mint denomination as auditor.
.br
.SH DESCRIPTION
\fBtaler\-auditor\-sign\fP is a command line tool to be used by an auditor to sign that he is aware of certain keys being used by a mint. Using this signature, the auditor affirms that he will verify that the mint is properly accounting for those coins.
\fBtaler\-auditor\-sign\fP is a command line tool to be used by an auditor to sign that he is aware of certain keys being used by a exchange. Using this signature, the auditor affirms that he will verify that the exchange is properly accounting for those coins.
.SH OPTIONS
.B
@ -19,11 +19,14 @@ Location of the private EdDSA auditor key. If it does not exist, it will be cre
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-m KEY, \-\-mint-key=KEY"
Public key of the mint in Crockford base32 encoding, for example as generated by gnunet\-ecc \-p.
.IP "\-m KEY, \-\-exchange-key=KEY"
Public key of the exchange in Crockford base32 encoding, for example as generated by gnunet\-ecc \-p.
.B
.IP "\-r FILE, \-\-mint-request=FILE"
File with the mint's denomination key signing request as generated by taler\-mint\-keyup \-o.
.IP "\-u URL, \-\-auditor-url=URL"
URL of the auditor. Provides informative link for the user to learn more about the auditor.
.B
.IP "\-r FILE, \-\-exchange-request=FILE"
File with the exchange's denomination key signing request as generated by taler\-exchange\-keyup \-o.
.B
.IP "\-o FILE, \-\-output=FILE"
File where the auditor should write the EdDSA signature.
@ -32,4 +35,4 @@ File where the auditor should write the EdDSA signature.
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-keyup\fP(1), \fBgnunet\-ecc\fP(1), \fBtaler.conf\fP(5)
\fBtaler\-exchange\-keyup\fP(1), \fBgnunet\-ecc\fP(1), \fBtaler.conf\fP(5)

View File

@ -0,0 +1,35 @@
.TH TALER\-EXCHANGE\-AGGREGATOR 1 "Mar 30, 2016" "GNU Taler"
.SH NAME
taler\-exchange\-aggregator \- Aggregate and execute exchange transactions
.SH SYNOPSIS
.B taler\-exchange\-aggregator
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-exchange\-aggregator\fP is a command line tool to run pending transactions from the Taler exchange.
.SH OPTIONS
.B
.IP "\-d DIRNAME, \-\-exchange-dir=DIRNAME"
Use the configuration and other resources for the exchange to operate from DIRNAME.
.B
.IP "\-f WIREFORMAT, \-\-format=WIREFORMAT"
Overrides WIREFORMAT option from the configuation file.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-t, \-\-test"
Run in test mode (use temporary tables). Only useful for testcases.
.B
.IP "\-v, \-\-version"
Print version information.
.B
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-exchange\-dbinit\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-httpd\fP(1), \fBtaler.conf\fP(5)

View File

@ -0,0 +1,29 @@
.TH TALER\-EXCHANGE\-DBINIT 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-exchange\-dbinit \- Initialize Taler exchange database.
.SH SYNOPSIS
.B taler\-exchange\-dbinit
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-exchange\-dbinit\fP is a command line tool to initialize the Taler exchange database. It creates the necessary tables and indices for the Taler exchange to operate.
.SH OPTIONS
.B
.IP "\-d DIRNAME, \-\-exchange-dir=DIRNAME"
Use the configuration and other resources for the exchange to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-exchange\-httpd\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-reservemod\fP(1), \fBtaler.conf\fP(5)

View File

@ -0,0 +1,39 @@
.TH TALER\-EXCHANGE\-HTTPD 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-exchange\-httpd \- Run Taler exchange (with RESTful API)
.SH SYNOPSIS
.B taler\-exchange\-httpd
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-exchange\-httpd\fP is a command line tool to run the Taler exchange (HTTP server). The required configuration, keys and database must exist before running this command.
.SH OPTIONS
.B
.IP "\-C, \-\-connection-close"
Force each HTTP connection to be closed after each request (useful in combination with \-f to avoid having to wait for nc to time out).
.B
.IP "\-d DIRNAME, \-\-exchange-dir=DIRNAME"
Use the configuration and other resources for the exchange to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.B
.IP "\-f FILENAME, \-\-file\-input=FILENAME"
This option is only available if the exchange was compiled with the configure option
\-\-enable\-developer\-mode. It is used for generating test cases against the exchange using AFL. When this option is present, the HTTP server will (1) terminate after the first client's HTTP connection is completed, and (2) automatically start such a client using a helper process based on the 'nc' or 'ncat' binary using FILENAME as the standard input to the helper process. As a result, the process will effectively run with FILENAME as the input from an HTTP client and then immediately exit. This is useful to test taler\-exchange\-httpd against many different possible inputs in a controlled way.
.B
.IP \"-t SECONDS, \-\-timeout=SECONDS"
Specifies the number of SECONDS after which the HTTPD should close (idle) HTTP connections.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-exchange\-dbinit\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-reservemod\fP(1), \fBtaler.conf\fP(5)

View File

@ -0,0 +1,29 @@
.TH TALER\-EXCHANGE\-KEYCHECK 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-exchange\-keycheck \- Check validity of Taler signing and denomination keys.
.SH SYNOPSIS
.B taler\-exchange\-keycheck
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-exchange\-keycheck\fP can be used to check if the signing and denomination keys in the operation directory are well-formed. This can be useful after importing fresh keys from the offline system to ensure that the files are correct.
.SH OPTIONS
.B
.IP "\-d DIRNAME, \-\-exchange-dir=DIRNAME"
Use the configuration and other resources for the exchange to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-exchange\-httpd\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-dbinit\fP(1), \fBtaler.conf\fP(5)

View File

@ -0,0 +1,38 @@
.TH TALER\-EXCHANGE\-KEYUP 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-exchange\-keyup \- Setup Taler exchange denomination and signing keys.
.SH SYNOPSIS
.B taler\-exchange\-keyup
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-exchange\-keyup\fP is a command line tool to setup Taler denomination and signing keys. This tool requires access to the exchange's long-term offline signing key and should be run in a secure (offline) environment under strict controls. The resulting keys can then be copied to the main online directory where the Taler HTTP server operates.
.SH OPTIONS
.B
.IP "\-d DIRNAME, \-\-exchange-dir=DIRNAME"
Use the configuration and other resources for the exchange to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-m FILE, \-\-master-key=FILE"
Location of the private EdDSA offline master key of the exchange.
.B
.IP "\-o FILE, \-\-ouptut=FILE"
Where to write a denomination key signing request file to be given to the auditor.
.B
.IP "\-t TIMESTAMP, \-\-time=TIMESTAMP"
Operate as if the current time was TIMESTAMP.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-exchange\-httpd\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-keycheck\fP(1), \fBtaler.conf\fP(5)

View File

@ -0,0 +1,35 @@
.TH TALER\-EXCHANGE\-RESERVEMOD 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-exchange\-reservemod \- Modify reserve balance in the Taler exchange database.
.SH SYNOPSIS
.B taler\-exchange\-reservemod
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-exchange\-reservemod\fP is a command line tool to modify reserves in the Taler exchange database. Basically, it can be used to import deposits, either for testing or as part of the import from the list of incoming transactions.
.SH OPTIONS
.B
.IP "\-a DENOM, \-\-add=DENOM"
Amount to add to the reserve.
.B
.IP "\-d DIRNAME, \-\-exchange-dir=DIRNAME"
Use the configuration and other resources for the exchange to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-R KEY, \-\-reserve=KEY"
Public EdDSA key of the reserve to modify.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-exchange\-httpd\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-dbinit\fP(1), \fBtaler.conf\fP(5)

38
doc/taler-exchange-wire.1 Normal file
View File

@ -0,0 +1,38 @@
.TH TALER\-EXCHANGE\-WIRE 1 "Apr 2, 2016" "GNU Taler"
.SH NAME
taler\-exchange\-wire \- Create the master-key signed responses to /wire.
.SH SYNOPSIS
.B taler\-exchange\-wire
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-exchange\-wire\fP is used to create the exchange's reply to a /wire request. It converts the bank details into the appropriate signed response. This needs to be done using the long-term offline master key.
.SH OPTIONS
.B
.IP "\-j JSON, \-\-json=JSON"
Gives JSON with all of the relevant account details in a method-specific format.
.B
.IP "\-t METHOD, \-\-type=METHOD"
Specifies the wire transfer method to use. Common are 'test' and 'sepa'.
.B
.IP "\-m MASTERKEYFILE, \-\-master=MASTERKEYFILE"
Specifies the name of the file containing the exchange's master key.
.B
.IP "\-o FILENAME, \-\-output=FILENAME"
Where to write the SEPA_RESPONSE_FILE.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-exchange\-httpd\fP(1), \fBtaler.conf\fP(5)

View File

@ -1,29 +0,0 @@
.TH TALER\-MINT\-DBINIT 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-mint\-dbinit \- Initialize Taler mint database.
.SH SYNOPSIS
.B taler\-mint\-dbinit
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-mint\-dbinit\fP is a command line tool to initialize the Taler mint database. It creates the necessary tables and indices for the Taler mint to operate.
.SH OPTIONS
.B
.IP "\-d DIRNAME, \-\-mint-dir=DIRNAME"
Use the configuration and other resources for the mint to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-httpd\fP(1), \fBtaler\-mint\-keyup\fP(1), \fBtaler\-mint\-reservemod\fP(1), \fBtaler.conf\fP(5)

View File

@ -1,39 +0,0 @@
.TH TALER\-MINT\-HTTPD 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-mint\-httpd \- Run Taler mint (with RESTful API)
.SH SYNOPSIS
.B taler\-mint\-httpd
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-mint\-httpd\fP is a command line tool to run the Taler mint (HTTP server). The required configuration, keys and database must exist before running this command.
.SH OPTIONS
.B
.IP "\-C, \-\-connection-close"
Force each HTTP connection to be closed after each request (useful in combination with \-f to avoid having to wait for nc to time out).
.B
.IP "\-d DIRNAME, \-\-mint-dir=DIRNAME"
Use the configuration and other resources for the mint to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.B
.IP "\-f FILENAME, \-\-file\-input=FILENAME"
This option is only available if the mint was compiled with the configure option
\-\-enable\-developer\-mode. It is used for generating test cases against the mint using AFL. When this option is present, the HTTP server will (1) terminate after the first client's HTTP connection is completed, and (2) automatically start such a client using a helper process based on the 'nc' or 'ncat' binary using FILENAME as the standard input to the helper process. As a result, the process will effectively run with FILENAME as the input from an HTTP client and then immediately exit. This is useful to test taler\-mint\-httpd against many different possible inputs in a controlled way.
.B
.IP \"-t SECONDS, \-\-timeout=SECONDS"
Specifies the number of SECONDS after which the HTTPD should close (idle) HTTP connections.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-dbinit\fP(1), \fBtaler\-mint\-keyup\fP(1), \fBtaler\-mint\-reservemod\fP(1), \fBtaler.conf\fP(5)

View File

@ -1,29 +0,0 @@
.TH TALER\-MINT\-KEYCHECK 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-mint\-keycheck \- Check validity of Taler signing and denomination keys.
.SH SYNOPSIS
.B taler\-mint\-keycheck
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-mint\-keycheck\fP can be used to check if the signing and denomination keys in the operation directory are well-formed. This can be useful after importing fresh keys from the offline system to ensure that the files are correct.
.SH OPTIONS
.B
.IP "\-d DIRNAME, \-\-mint-dir=DIRNAME"
Use the configuration and other resources for the mint to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-httpd\fP(1), \fBtaler\-mint\-keyup\fP(1), \fBtaler\-mint\-dbinit\fP(1), \fBtaler.conf\fP(5)

View File

@ -1,38 +0,0 @@
.TH TALER\-MINT\-KEYUP 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-mint\-keyup \- Setup Taler mint denomination and signing keys.
.SH SYNOPSIS
.B taler\-mint\-keyup
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-mint\-keyup\fP is a command line tool to setup Taler denomination and signing keys. This tool requires access to the mint's long-term offline signing key and should be run in a secure (offline) environment under strict controls. The resulting keys can then be copied to the main online directory where the Taler HTTP server operates.
.SH OPTIONS
.B
.IP "\-d DIRNAME, \-\-mint-dir=DIRNAME"
Use the configuration and other resources for the mint to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-m FILE, \-\-master-key=FILE"
Location of the private EdDSA offline master key of the mint.
.B
.IP "\-o FILE, \-\-ouptut=FILE"
Where to write a denomination key signing request file to be given to the auditor.
.B
.IP "\-t TIMESTAMP, \-\-time=TIMESTAMP"
Operate as if the current time was TIMESTAMP.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-httpd\fP(1), \fBtaler\-mint\-keyup\fP(1), \fBtaler\-mint\-keycheck\fP(1), \fBtaler.conf\fP(5)

View File

@ -1,35 +0,0 @@
.TH TALER\-MINT\-RESERVEMOD 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-mint\-reservemod \- Modify reserve balance in the Taler mint database.
.SH SYNOPSIS
.B taler\-mint\-reservemod
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-mint\-reservemod\fP is a command line tool to modify reserves in the Taler mint database. Basically, it can be used to import deposits, either for testing or as part of the import from the list of incoming transactions.
.SH OPTIONS
.B
.IP "\-a DENOM, \-\-add=DENOM"
Amount to add to the reserve.
.B
.IP "\-d DIRNAME, \-\-mint-dir=DIRNAME"
Use the configuration and other resources for the mint to operate from DIRNAME.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-R KEY, \-\-reserve=KEY"
Public EdDSA key of the reserve to modify.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-httpd\fP(1), \fBtaler\-mint\-keyup\fP(1), \fBtaler\-mint\-dbinit\fP(1), \fBtaler.conf\fP(5)

View File

@ -1,41 +0,0 @@
.TH TALER\-MINT\-SEPA 1 "Apr 22, 2015" "GNU Taler"
.SH NAME
taler\-mint\-sepa \- Create the master-key signed response to /wire/sepa.
.SH SYNOPSIS
.B taler\-mint\-sepa
.RI [ options ]
.br
.SH DESCRIPTION
\fBtaler\-mint\-sepa\fP is used to create the mint's reply to a /wire/sepa request. It converts the bank details into the appropriate signed response. This needs to be done using the long-term offline master key.
.SH OPTIONS
.B
.IP "\-b BIC, \-\-bic=BIC"
Specifies the BIC code to use.
.B
.IP "\-i IBAN, \-\-iban=IBAN"
Specifies the IBAN to use.
.B
.IP "\-n NAME, \-\-name=NAME"
Specifies the name of the account holder.
.B
.IP "\-m MASTERKEYFILE, \-\-master=MASTERKEYFILE"
Specifies the name of the file containing the mint's master key.
.B
.IP "\-o FILENAME, \-\-output=FILENAME"
Where to write the SEPA_RESPONSE_FILE.
.B
.IP "\-h, \-\-help"
Print short help on options.
.B
.IP "\-v, \-\-version"
Print version information.
.SH BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-httpd\fP(1), \fBtaler.conf\fP(5)

View File

@ -1,18 +1,18 @@
.TH TALER.CONF 5 "Aug 11, 2015" "GNU Taler"
.TH TALER.CONF 5 "Apr 11, 2016" "GNU Taler"
.SH NAME
taler.conf \- Taler configuration file.
.SH SYNOPSIS
.B DIRNAME/taler.conf
.B taler.conf
.SH DESCRIPTION
The basic structure of the configuration file is the following. The file is split into sections. Every section begins with "[SECTIONNAME]" and contains a number of options of the form "OPTION=VALUE". Empty lines and lines beginning with a "#" are treated as comments.
The basic structure of the configuration file is the following. The file is split into sections. Every section begins with "[SECTIONNAME]" and contains a number of options of the form "OPTION=VALUE". Empty lines and lines beginning with a "#" are treated as comments. Files containing default values for many of the options described below are installed under \$TALER\_PREFIX/share/taler/config.d/. The configuration file given with \-c to Taler binaries overrides these defaults.
.SH MINT OPTIONS
.SH EXCHANGE OPTIONS
The following options are from the "[mint]" section and used by most mint tools:
The following options are from the "[exchange]" section and used by most exchange tools:
.IP CURRENCY
Name of the currency, i.e. "EUR" for Euro.
@ -23,32 +23,35 @@ The following options are from the "[mint]" section and used by most mint tools:
.IP PORT
Port on which the HTTP server listens, i.e. 8080.
.IP MASTER_PUBLIC_KEY
Crockford Base32-encoded master public key, public version of the mint\'s long\-time offline signing key.
Crockford Base32-encoded master public key, public version of the exchange\'s long\-time offline signing key.
.SH WIRE transfer details
The following options must be in section "[mint-wire-test]":
The following options must be in section "[wire\-incoming\-test]" and "[wire\-outgoing\-test]":
.IP REDIRECT_URL
URL to redirect /wire/test to. Should contain a Web form the user can use to charge his wallet with coins in a "test" currency for testing. If this option is not provided, /wire/test will return "501 NOT IMPLEMENTED".
.IP BANK_URI
URL of the Taler bank.
The following options must be in section "[mint-wire-sepa]":
.IP BANK_ACCOUNT_NUMBER
Number of the bank account of the exchange.
The following options must be in section "[wire\-incoming\-sepa]" and "[wire\-outgoing\-sepa]":
.IP SEPA_RESPONSE_FILE
Filename with the JSON body for the /wire/sepa response, signed using the mint's long-term offline master key. If this option is not provided, /wire/test will return "501 NOT IMPLEMENTED". Use "taler-mint-sepa" to create the SEPA_RESPONSE_FILE.
Filename with the JSON body for the /wire response, signed using the exchange\'s long-term offline master key. Use taler\-exchange\-sepa to create the SEPA_RESPONSE_FILE.
.SH Postgres database options
The following options must be in section "[mintdb-postgres]":
The following options must be in section "[exchangedb\-postgres]":
.IP DB_CONN_STR
How to access the database, i.e. "postgres:///taler" to use the "taler" database. Testcases use "talercheck".
.SH COIN OPTIONS
The following options must be in sections starting with "[coin_]" and are used by taler\-mint\-keyup to create denomination keys:
The following options must be in sections starting with "[coin_]" and are used by taler\-exchange\-keyup to create denomination keys:
.IP VALUE
Value of the coin, i.e. "EUR:1.50" for 1 Euro and 50 Cents (per coin).
@ -69,7 +72,7 @@ The following options must be in sections starting with "[coin_]" and are used b
.SH KEY OPTIONS
The following options are from the "[mint_keys]" section and used by most taler\-mint\-keyup to create keys:
The following options are from the "[exchange_keys]" section and used by most taler\-exchange\-keyup to create keys:
.IP SIGNKEY_DURATION
For how long is a signing key valid?
@ -85,5 +88,4 @@ The following options are from the "[mint_keys]" section and used by most taler\
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <taler@gnu.org>
.SH "SEE ALSO"
\fBtaler\-mint\-httpd\fP(1), \fBtaler\-mint\-keyup\fP(1), \fBtaler\-mint\-reservemod\fP(1), \fBtaler\-mint\-dbinit\fP(1), \fBtaler\-mint\-sepa(1)
\fBtaler\-exchange\-httpd\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-reservemod\fP(1), \fBtaler\-exchange\-dbinit\fP(1), \fBtaler\-exchange\-sepa(1)

View File

@ -3,16 +3,24 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include
if HAVE_POSTGRESQL
PQ_DIR = pq
endif
if HAVE_LIBCURL
BANK_LIB = bank-lib
else
if HAVE_LIBGNURL
BANK_LIB = bank-lib
endif
endif
if WALLET_ONLY
SUBDIRS = include util
else
SUBDIRS = include util $(PQ_DIR) bank-lib wire mintdb mint mint-tools
SUBDIRS = include util json $(PQ_DIR) $(BANK_LIB) wire exchangedb exchange exchange-tools
if HAVE_LIBCURL
SUBDIRS += mint-lib
SUBDIRS += exchange-lib
else
if HAVE_LIBGNURL
SUBDIRS += mint-lib
SUBDIRS += exchange-lib
endif
endif

View File

@ -15,10 +15,11 @@ libtalerbank_la_LDFLAGS = \
libtalerbank_la_SOURCES = \
bank_api_context.c bank_api_context.h \
bank_api_json.c bank_api_json.h \
bank_api_admin.c
libtalerbank_la_LIBADD = \
$(top_builddir)/src/json/libtalerjson.la \
-lgnunetjson \
-lgnunetutil \
-ljansson \
$(XLIB)
@ -42,4 +43,5 @@ test_bank_api_SOURCES = \
test_bank_api_LDADD = \
libtalerbank.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil
-lgnunetutil \
-ljansson

View File

@ -24,8 +24,9 @@
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
#include "taler_bank_service.h"
#include "bank_api_json.h"
#include "taler_json_lib.h"
#include "bank_api_context.h"
#include "taler_signatures.h"
@ -134,7 +135,8 @@ handle_admin_add_incoming_finished (void *cls,
break;
}
aai->cb (aai->cb_cls,
response_code);
response_code,
json);
json_decref (json);
TALER_BANK_admin_add_incoming_cancel (aai);
}
@ -150,7 +152,8 @@ handle_admin_add_incoming_finished (void *cls,
* @param reserve_pub public key of the reserve
* @param amount amount that was deposited
* @param execution_date when did we receive the amount
* @param account_no account number (53 bits at most)
* @param debit_account_no account number to withdraw from (53 bits at most)
* @param credit_account_no account number to deposit into (53 bits at most)
* @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback
* @return NULL
@ -161,7 +164,8 @@ struct TALER_BANK_AdminAddIncomingHandle *
TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_Amount *amount,
uint64_t account_no,
uint64_t debit_account_no,
uint64_t credit_account_no,
TALER_BANK_AdminAddIncomingResultCallback res_cb,
void *res_cb_cls)
{
@ -169,12 +173,13 @@ TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank,
json_t *admin_obj;
CURL *eh;
admin_obj = json_pack ("{s:o, s:o," /* reserve_pub/amount */
" s:I}", /* execution_Date/wire */
"wtid", TALER_json_from_data (wtid,
sizeof (*wtid)),
"amount", TALER_json_from_amount (amount),
"account", (json_int_t) account_no);
admin_obj = json_pack ("{s:o, s:o,"
" s:I, s:I}",
"wtid", GNUNET_JSON_from_data (wtid,
sizeof (*wtid)), /* #4340 */
"amount", TALER_JSON_from_amount (amount),
"debit_account", (json_int_t) debit_account_no,
"credit_account", (json_int_t) credit_account_no);
aai = GNUNET_new (struct TALER_BANK_AdminAddIncomingHandle);
aai->bank = bank;
aai->cb = res_cb;

View File

@ -390,7 +390,7 @@ TALER_BANK_fini (struct TALER_BANK_Context *ctx)
/**
* Obtain the URL to use for an API request.
*
* @param h the mint handle to query
* @param h the exchange handle to query
* @param path Taler API path (i.e. "/reserve/withdraw")
* @return the full URI to use with cURL
*/

View File

@ -21,6 +21,7 @@
* @author Christian Grothoff
*/
#include "platform.h"
#include <jansson.h>
#include <curl/curl.h>
#include <gnunet/gnunet_util_lib.h>
#include "taler_bank_service.h"

View File

@ -1,525 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file bank-lib/bank_api_json.c
* @brief functions to parse incoming requests (JSON snippets)
* @author Florian Dold
* @author Benedikt Mueller
* @author Christian Grothoff
*/
#include "platform.h"
#include "bank_api_json.h"
/**
* Navigate and parse data in a JSON tree.
*
* @param root the JSON node to start the navigation at.
* @param spec parse specification array
* @return offset in @a spec where parsing failed, -1 on success (!)
*/
static int
parse_json (json_t *root,
struct BAJ_Specification *spec)
{
int i;
json_t *pos; /* what's our current position? */
pos = root;
for (i=0;BAJ_CMD_END != spec[i].cmd;i++)
{
pos = json_object_get (root,
spec[i].field);
if (NULL == pos)
{
GNUNET_break_op (0);
return i;
}
switch (spec[i].cmd)
{
case BAJ_CMD_END:
GNUNET_assert (0);
return i;
case BAJ_CMD_AMOUNT:
if (GNUNET_OK !=
TALER_json_to_amount (pos,
spec[i].details.amount))
{
GNUNET_break_op (0);
return i;
}
break;
case BAJ_CMD_TIME_ABSOLUTE:
if (GNUNET_OK !=
TALER_json_to_abs (pos,
spec[i].details.abs_time))
{
GNUNET_break_op (0);
return i;
}
break;
case BAJ_CMD_STRING:
{
const char *str;
str = json_string_value (pos);
if (NULL == str)
{
GNUNET_break_op (0);
return i;
}
*spec[i].details.strptr = str;
}
break;
case BAJ_CMD_BINARY_FIXED:
{
const char *str;
int res;
str = json_string_value (pos);
if (NULL == str)
{
GNUNET_break_op (0);
return i;
}
res = GNUNET_STRINGS_string_to_data (str, strlen (str),
spec[i].details.fixed_data.dest,
spec[i].details.fixed_data.dest_size);
if (GNUNET_OK != res)
{
GNUNET_break_op (0);
return i;
}
}
break;
case BAJ_CMD_BINARY_VARIABLE:
{
const char *str;
size_t size;
void *data;
int res;
str = json_string_value (pos);
if (NULL == str)
{
GNUNET_break_op (0);
return i;
}
size = (strlen (str) * 5) / 8;
if (size >= 1024)
{
GNUNET_break_op (0);
return i;
}
data = GNUNET_malloc (size);
res = GNUNET_STRINGS_string_to_data (str,
strlen (str),
data,
size);
if (GNUNET_OK != res)
{
GNUNET_break_op (0);
GNUNET_free (data);
return i;
}
*spec[i].details.variable_data.dest_p = data;
*spec[i].details.variable_data.dest_size_p = size;
}
break;
case BAJ_CMD_RSA_PUBLIC_KEY:
{
size_t size;
const char *str;
int res;
void *buf;
str = json_string_value (pos);
if (NULL == str)
{
GNUNET_break_op (0);
return i;
}
size = (strlen (str) * 5) / 8;
buf = GNUNET_malloc (size);
res = GNUNET_STRINGS_string_to_data (str,
strlen (str),
buf,
size);
if (GNUNET_OK != res)
{
GNUNET_free (buf);
GNUNET_break_op (0);
return i;
}
*spec[i].details.rsa_public_key
= GNUNET_CRYPTO_rsa_public_key_decode (buf,
size);
GNUNET_free (buf);
if (NULL == spec[i].details.rsa_public_key)
{
GNUNET_break_op (0);
return i;
}
}
break;
case BAJ_CMD_RSA_SIGNATURE:
{
size_t size;
const char *str;
int res;
void *buf;
str = json_string_value (pos);
if (NULL == str)
{
GNUNET_break_op (0);
return i;
}
size = (strlen (str) * 5) / 8;
buf = GNUNET_malloc (size);
res = GNUNET_STRINGS_string_to_data (str,
strlen (str),
buf,
size);
if (GNUNET_OK != res)
{
GNUNET_free (buf);
GNUNET_break_op (0);
return i;
}
*spec[i].details.rsa_signature
= GNUNET_CRYPTO_rsa_signature_decode (buf,
size);
GNUNET_free (buf);
if (NULL == spec[i].details.rsa_signature)
return i;
}
break;
case BAJ_CMD_UINT16:
{
json_int_t val;
if (! json_is_integer (pos))
{
GNUNET_break_op (0);
return i;
}
val = json_integer_value (pos);
if ( (0 > val) || (val > UINT16_MAX) )
{
GNUNET_break_op (0);
return i;
}
*spec[i].details.u16 = (uint16_t) val;
}
break;
case BAJ_CMD_UINT64:
{
json_int_t val;
if (! json_is_integer (pos))
{
GNUNET_break_op (0);
return i;
}
val = json_integer_value (pos);
*spec[i].details.u64 = (uint64_t) val;
}
break;
case BAJ_CMD_JSON_OBJECT:
{
if (! (json_is_object (pos) || json_is_array (pos)) )
{
GNUNET_break_op (0);
return i;
}
json_incref (pos);
*spec[i].details.obj = pos;
}
break;
default:
GNUNET_break (0);
return i;
}
}
return -1; /* all OK! */
}
/**
* Free all elements allocated during a
* #BAJ_parse_json() operation.
*
* @param spec specification of the parse operation
* @param end number of elements in @a spec to process
*/
static void
parse_free (struct BAJ_Specification *spec,
int end)
{
int i;
for (i=0;i<end;i++)
{
switch (spec[i].cmd)
{
case BAJ_CMD_END:
GNUNET_assert (0);
return;
case BAJ_CMD_AMOUNT:
break;
case BAJ_CMD_TIME_ABSOLUTE:
break;
case BAJ_CMD_BINARY_FIXED:
break;
case BAJ_CMD_STRING:
break;
case BAJ_CMD_BINARY_VARIABLE:
GNUNET_free (*spec[i].details.variable_data.dest_p);
*spec[i].details.variable_data.dest_p = NULL;
*spec[i].details.variable_data.dest_size_p = 0;
break;
case BAJ_CMD_RSA_PUBLIC_KEY:
GNUNET_CRYPTO_rsa_public_key_free (*spec[i].details.rsa_public_key);
*spec[i].details.rsa_public_key = NULL;
break;
case BAJ_CMD_RSA_SIGNATURE:
GNUNET_CRYPTO_rsa_signature_free (*spec[i].details.rsa_signature);
*spec[i].details.rsa_signature = NULL;
break;
case BAJ_CMD_JSON_OBJECT:
json_decref (*spec[i].details.obj);
*spec[i].details.obj = NULL;
break;
default:
GNUNET_break (0);
break;
}
}
}
/**
* Navigate and parse data in a JSON tree.
*
* @param root the JSON node to start the navigation at.
* @param spec parse specification array
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
BAJ_parse_json (const json_t *root,
struct BAJ_Specification *spec)
{
int ret;
ret = parse_json ((json_t *) root,
spec);
if (-1 == ret)
return GNUNET_OK;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"JSON field `%s` (%d) had unexpected value\n",
spec[ret].field,
ret);
parse_free (spec, ret);
return GNUNET_SYSERR;
}
/**
* Free all elements allocated during a
* #BAJ_parse_json() operation.
*
* @param spec specification of the parse operation
*/
void
BAJ_parse_free (struct BAJ_Specification *spec)
{
int i;
for (i=0;BAJ_CMD_END != spec[i].cmd;i++) ;
parse_free (spec, i);
}
/**
* The expected field stores a string.
*
* @param name name of the JSON field
* @param strptr where to store a pointer to the field
*/
struct BAJ_Specification
BAJ_spec_string (const char *name,
const char **strptr)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_STRING,
.field = name,
.details.strptr = strptr
};
return ret;
}
/**
* Specification for parsing an absolute time value.
*
* @param name name of the JSON field
* @param at where to store the absolute time found under @a name
*/
struct BAJ_Specification
BAJ_spec_absolute_time (const char *name,
struct GNUNET_TIME_Absolute *at)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_TIME_ABSOLUTE,
.field = name,
.details.abs_time = at
};
return ret;
}
/**
* Specification for parsing an amount value.
*
* @param name name of the JSON field
* @param amount where to store the amount found under @a name
*/
struct BAJ_Specification
BAJ_spec_amount (const char *name,
struct TALER_Amount *amount)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_AMOUNT,
.field = name,
.details.amount = amount
};
return ret;
}
/**
* 16-bit integer.
*
* @param name name of the JSON field
* @param[out] u16 where to store the integer found under @a name
*/
struct BAJ_Specification
BAJ_spec_uint16 (const char *name,
uint16_t *u16)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_UINT16,
.field = name,
.details.u16 = u16
};
return ret;
}
/**
* 64-bit integer.
*
* @param name name of the JSON field
* @param[out] u64 where to store the integer found under @a name
*/
struct BAJ_Specification
BAJ_spec_uint64 (const char *name,
uint64_t *u64)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_UINT64,
.field = name,
.details.u64 = u64
};
return ret;
}
/**
* JSON object.
*
* @param name name of the JSON field
* @param[out] jsonp where to store the JSON found under @a name
*/
struct BAJ_Specification
BAJ_spec_json (const char *name,
json_t **jsonp)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_JSON_OBJECT,
.field = name,
.details.obj = jsonp
};
return ret;
}
/**
* Specification for parsing an RSA public key.
*
* @param name name of the JSON field
* @param pk where to store the RSA key found under @a name
*/
struct BAJ_Specification
BAJ_spec_rsa_public_key (const char *name,
struct GNUNET_CRYPTO_rsa_PublicKey **pk)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_RSA_PUBLIC_KEY,
.field = name,
.details.rsa_public_key = pk
};
return ret;
}
/**
* Specification for parsing an RSA signature.
*
* @param name name of the JSON field
* @param sig where to store the RSA signature found under @a name
*/
struct BAJ_Specification
BAJ_spec_rsa_signature (const char *name,
struct GNUNET_CRYPTO_rsa_Signature **sig)
{
struct BAJ_Specification ret =
{
.cmd = BAJ_CMD_RSA_SIGNATURE,
.field = name,
.details.rsa_signature = sig
};
return ret;
}
/* end of bank_api_json.c */

View File

@ -1,352 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_json.h
* @brief functions to parse incoming requests (JSON snippets)
* @author Florian Dold
* @author Benedikt Mueller
* @author Christian Grothoff
*/
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include "taler_util.h"
#include <jansson.h>
/**
* Enumeration with the various commands for the
* #BAJ_parse_json interpreter.
*/
enum BAJ_Command
{
/**
* End of command list.
*/
BAJ_CMD_END,
/**
* Parse amount at current position.
*/
BAJ_CMD_AMOUNT,
/**
* Parse absolute time at current position.
*/
BAJ_CMD_TIME_ABSOLUTE,
/**
* Parse fixed binary value at current position.
*/
BAJ_CMD_BINARY_FIXED,
/**
* Parse variable-size binary value at current position.
*/
BAJ_CMD_BINARY_VARIABLE,
/**
* Parse RSA public key at current position.
*/
BAJ_CMD_RSA_PUBLIC_KEY,
/**
* Parse RSA signature at current position.
*/
BAJ_CMD_RSA_SIGNATURE,
/**
* Parse `const char *` JSON string at current position.
*/
BAJ_CMD_STRING,
/**
* Parse `uint16_t` integer at the current position.
*/
BAJ_CMD_UINT16,
/**
* Parse `uint64_t` integer at the current position.
*/
BAJ_CMD_UINT64,
/**
* Parse JSON object at the current position.
*/
BAJ_CMD_JSON_OBJECT,
/**
* Parse ??? at current position.
*/
BAJ_CMD_C
};
/**
* @brief Entry in parser specification for #BAJ_parse_json.
*/
struct BAJ_Specification
{
/**
* Command to execute.
*/
enum BAJ_Command cmd;
/**
* Name of the field to access.
*/
const char *field;
/**
* Further details for the command.
*/
union {
/**
* Where to store amount for #BAJ_CMD_AMOUNT.
*/
struct TALER_Amount *amount;
/**
* Where to store time, for #BAJ_CMD_TIME_ABSOLUTE.
*/
struct GNUNET_TIME_Absolute *abs_time;
/**
* Where to write binary data, for #BAJ_CMD_BINARY_FIXED.
*/
struct {
/**
* Where to write the data.
*/
void *dest;
/**
* How many bytes to write to @e dest.
*/
size_t dest_size;
} fixed_data;
/**
* Where to write binary data, for #BAJ_CMD_BINARY_VARIABLE.
*/
struct {
/**
* Where to store the pointer with the data (is allocated).
*/
void **dest_p;
/**
* Where to store the number of bytes allocated at `*dest`.
*/
size_t *dest_size_p;
} variable_data;
/**
* Where to store the RSA public key for #BAJ_CMD_RSA_PUBLIC_KEY
*/
struct GNUNET_CRYPTO_rsa_PublicKey **rsa_public_key;
/**
* Where to store the RSA signature for #BAJ_CMD_RSA_SIGNATURE
*/
struct GNUNET_CRYPTO_rsa_Signature **rsa_signature;
/**
* Details for #BAJ_CMD_EDDSA_SIGNATURE
*/
struct {
/**
* Where to store the purpose.
*/
struct GNUNET_CRYPTO_EccSignaturePurpose **purpose_p;
/**
* Key to verify the signature against.
*/
const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key;
} eddsa_signature;
/**
* Where to store a pointer to the string.
*/
const char **strptr;
/**
* Where to store 16-bit integer.
*/
uint16_t *u16;
/**
* Where to store 64-bit integer.
*/
uint64_t *u64;
/**
* Where to store a JSON object.
*/
json_t **obj;
} details;
};
/**
* Navigate and parse data in a JSON tree.
*
* @param root the JSON node to start the navigation at.
* @param spec parse specification array
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
BAJ_parse_json (const json_t *root,
struct BAJ_Specification *spec);
/**
* Free all elements allocated during a
* #BAJ_parse_json() operation.
*
* @param spec specification of the parse operation
*/
void
BAJ_parse_free (struct BAJ_Specification *spec);
/**
* End of a parser specification.
*/
#define BAJ_spec_end { .cmd = BAJ_CMD_END }
/**
* Fixed size object (in network byte order, encoded using Crockford
* Base32hex encoding).
*
* @param name name of the JSON field
* @param obj pointer where to write the data (type of `*obj` will determine size)
*/
#define BAJ_spec_fixed_auto(name,obj) { .cmd = BAJ_CMD_BINARY_FIXED, .field = name, .details.fixed_data.dest = obj, .details.fixed_data.dest_size = sizeof (*obj) }
/**
* Variable size object (in network byte order, encoded using Crockford
* Base32hex encoding).
*
* @param name name of the JSON field
* @param obj pointer where to write the data (a `void **`)
* @param size where to store the number of bytes allocated for @a obj (of type `size_t *`
*/
#define BAJ_spec_varsize(name,obj,size) { .cmd = BAJ_CMD_BINARY_VARIABLE, .field = name, .details.variable_data.dest_p = obj, .details.variable_data.dest_size_p = size }
/**
* The expected field stores a string.
*
* @param name name of the JSON field
* @param strptr where to store a pointer to the field
*/
struct BAJ_Specification
BAJ_spec_string (const char *name,
const char **strptr);
/**
* Absolute time.
*
* @param name name of the JSON field
* @param[out] at where to store the absolute time found under @a name
*/
struct BAJ_Specification
BAJ_spec_absolute_time (const char *name,
struct GNUNET_TIME_Absolute *at);
/**
* 16-bit integer.
*
* @param name name of the JSON field
* @param[out] u16 where to store the integer found under @a name
*/
struct BAJ_Specification
BAJ_spec_uint16 (const char *name,
uint16_t *u16);
/**
* 64-bit integer.
*
* @param name name of the JSON field
* @param[out] u64 where to store the integer found under @a name
*/
struct BAJ_Specification
BAJ_spec_uint64 (const char *name,
uint64_t *u64);
/**
* JSON object.
*
* @param name name of the JSON field
* @param[out] jsonp where to store the JSON found under @a name
*/
struct BAJ_Specification
BAJ_spec_json (const char *name,
json_t **jsonp);
/**
* Specification for parsing an amount value.
*
* @param name name of the JSON field
* @param amount where to store the amount under @a name
*/
struct BAJ_Specification
BAJ_spec_amount (const char *name,
struct TALER_Amount *amount);
/**
* Specification for parsing an RSA public key.
*
* @param name name of the JSON field
* @param pk where to store the RSA key found under @a name
*/
struct BAJ_Specification
BAJ_spec_rsa_public_key (const char *name,
struct GNUNET_CRYPTO_rsa_PublicKey **pk);
/**
* Specification for parsing an RSA signature.
*
* @param name name of the JSON field
* @param sig where to store the RSA signature found under @a name
*/
struct BAJ_Specification
BAJ_spec_rsa_signature (const char *name,
struct GNUNET_CRYPTO_rsa_Signature **sig);
/* end of mint_api_json.h */

View File

@ -103,9 +103,14 @@ struct Command
const char *amount;
/**
* Account number.
* Credited account number.
*/
uint64_t account_no;
uint64_t credit_account_no;
/**
* Debited account number.
*/
uint64_t debit_account_no;
/**
* Wire transfer identifier to use. Initialized to
@ -158,11 +163,9 @@ struct InterpreterState
* Task that runs the context's event loop with the GNUnet scheduler.
*
* @param cls unused
* @param tc scheduler context (unused)
*/
static void
context_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc);
context_task (void *cls);
/**
@ -228,11 +231,9 @@ find_command (const struct InterpreterState *is,
* Run the main interpreter loop that performs bank operations.
*
* @param cls contains the `struct InterpreterState`
* @param tc scheduler context
*/
static void
interpreter_run (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc);
interpreter_run (void *cls);
/**
@ -241,10 +242,12 @@ interpreter_run (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the bank's reply is bogus (fails to follow the protocol)
* @param json detailed response from the HTTPD, or NULL if reply was not in JSON
*/
static void
add_incoming_cb (void *cls,
unsigned int http_status)
unsigned int http_status,
json_t *json)
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
@ -253,6 +256,14 @@ add_incoming_cb (void *cls,
if (cmd->expected_response_code != http_status)
{
GNUNET_break (0);
if (NULL != json)
{
fprintf (stderr,
"Unexpected response code %u:\n",
http_status);
json_dumpf (json, stderr, 0);
fprintf (stderr, "\n");
}
fail (is);
return;
}
@ -266,17 +277,17 @@ add_incoming_cb (void *cls,
* Run the main interpreter loop that performs bank operations.
*
* @param cls contains the `struct InterpreterState`
* @param tc scheduler context
*/
static void
interpreter_run (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
interpreter_run (void *cls)
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
struct TALER_Amount amount;
const struct GNUNET_SCHEDULER_TaskContext *tc;
is->task = NULL;
tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
fprintf (stderr,
@ -310,7 +321,8 @@ interpreter_run (void *cls,
= TALER_BANK_admin_add_incoming (ctx,
&cmd->details.admin_add_incoming.wtid,
&amount,
cmd->details.admin_add_incoming.account_no,
cmd->details.admin_add_incoming.debit_account_no,
cmd->details.admin_add_incoming.credit_account_no,
&add_incoming_cb,
is);
if (NULL == cmd->details.admin_add_incoming.aih)
@ -338,11 +350,9 @@ interpreter_run (void *cls,
* Cleans up our state.
*
* @param cls the interpreter state.
* @param tc unused
*/
static void
do_shutdown (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
do_shutdown (void *cls)
{
struct InterpreterState *is = cls;
struct Command *cmd;
@ -399,11 +409,9 @@ do_shutdown (void *cls,
* Task that runs the context's event loop with the GNUnet scheduler.
*
* @param cls unused
* @param tc scheduler context (unused)
*/
static void
context_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
context_task (void *cls)
{
long timeout;
int max_fd;
@ -455,13 +463,9 @@ context_task (void *cls,
* Main function that will be run by the scheduler.
*
* @param cls closure
* @param args remaining command-line arguments
* @param cfgfile name of the configuration file used (for saving, can be NULL!)
* @param config configuration
*/
static void
run (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
run (void *cls)
{
struct InterpreterState *is;
static struct Command commands[] =
@ -470,8 +474,9 @@ run (void *cls,
{ .oc = OC_ADMIN_ADD_INCOMING,
.label = "deposit-1",
.expected_response_code = MHD_HTTP_OK,
.details.admin_add_incoming.account_no = 42,
.details.admin_add_incoming.amount = "EUR:5.01" },
.details.admin_add_incoming.credit_account_no = 1,
.details.admin_add_incoming.debit_account_no = 2,
.details.admin_add_incoming.amount = "PUDOS:5.01" },
{ .oc = OC_END }
};
@ -503,6 +508,7 @@ main (int argc,
char * const *argv)
{
struct GNUNET_OS_Process *bankd;
unsigned int cnt;
GNUNET_log_setup ("test-bank-api",
"WARNING",
@ -510,32 +516,43 @@ main (int argc,
bankd = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-bank-httpd",
"taler-bank-httpd",
"-d", "test-bank-home",
"taler-bank-manage",
"taler-bank-manage",
"serve-http", "--port", "8081",
NULL);
if (NULL == bankd)
{
fprintf (stderr,
"taler-bank-httpd not found, skipping test\n");
"taler-bank-manage not found, skipping test\n");
return 77; /* report 'skip' */
}
/* give child time to start and bind against the socket */
fprintf (stderr,
"Waiting for taler-bank-httpd to be ready");
"Waiting for taler-bank-manage to be ready\n");
cnt = 0;
do
{
fprintf (stderr, ".");
sleep (1);
cnt++;
if (cnt > 30)
break;
}
while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8081/keys -o /dev/null -O /dev/null"));
while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8081/ -o /dev/null -O /dev/null"));
fprintf (stderr, "\n");
result = GNUNET_SYSERR;
GNUNET_SCHEDULER_run (&run, NULL);
if (cnt <= 30)
GNUNET_SCHEDULER_run (&run, NULL);
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_wait (bankd);
GNUNET_OS_process_destroy (bankd);
if (cnt > 30)
{
fprintf (stderr,
"taler-bank-manage failed to start properly.\n");
return 77;
}
return (GNUNET_OK == result) ? 0 : 1;
}

View File

@ -0,0 +1,67 @@
# This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include
if USE_COVERAGE
AM_CFLAGS = --coverage -O0
XLIB = -lgcov
endif
lib_LTLIBRARIES = \
libtalerexchange.la
libtalerexchange_la_LDFLAGS = \
-version-info 0:0:0 \
-no-undefined
libtalerexchange_la_SOURCES = \
exchange_api_common.c exchange_api_common.h \
exchange_api_context.c exchange_api_context.h \
exchange_api_handle.c exchange_api_handle.h \
exchange_api_admin.c \
exchange_api_deposit.c \
exchange_api_deposit_wtid.c \
exchange_api_refresh.c \
exchange_api_refresh_link.c \
exchange_api_reserve.c \
exchange_api_wire.c \
exchange_api_wire_deposits.c
libtalerexchange_la_LIBADD = \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetjson \
-lgnunetutil \
-ljansson \
$(XLIB)
if HAVE_LIBCURL
libtalerexchange_la_LIBADD += -lcurl
else
if HAVE_LIBGNURL
libtalerexchange_la_LIBADD += -lgnurl
endif
endif
check_PROGRAMS = \
test_exchange_api
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
$(check_PROGRAMS)
test_exchange_api_SOURCES = \
test_exchange_api.c
test_exchange_api_LDADD = \
libtalerexchange.la \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil \
-ljansson
EXTRA_DIST = \
test_taler_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv \
test_taler_exchange_api_home/.config/taler/test.json \
test_taler_exchange_api_home/.config/taler/sepa.json \
test_taler_exchange_api.conf

View File

@ -16,9 +16,9 @@
#
#
# This will generate testcases in a directory 'afl-tests', which can then
# be moved into src/mint/afl-tests/ to be run during mint-testing.
# be moved into src/exchange/afl-tests/ to be run during exchange-testing.
#
# This script uses American Fuzzy Loop (AFL) to fuzz the mint to
# This script uses American Fuzzy Loop (AFL) to fuzz the exchange to
# automatically create tests with good coverage. You must install
# AFL and set AFL_HOME to the directory where AFL is installed
# before running. Also, a directory "baseline/" should exist with
@ -31,4 +31,4 @@
#
# Must be run from this directory.
#
$AFL_HOME/afl-fuzz -i baseline/ -m 250 -o afl-tests/ -f /tmp/afl-input taler-mint-httpd -f /tmp/afl-input -d test-mint-home/ -C
$AFL_HOME/afl-fuzz -i baseline/ -m 250 -o afl-tests/ -f /tmp/afl-input taler-exchange-httpd -f /tmp/afl-input -d test-exchange-home/ -C

View File

@ -15,8 +15,8 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_admin.c
* @brief Implementation of the /admin/ requests of the mint's HTTP API
* @file exchange-lib/exchange_api_admin.c
* @brief Implementation of the /admin/ requests of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
@ -24,23 +24,24 @@
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include <gnunet/gnunet_json_lib.h>
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
/**
* @brief An admin/add/incoming Handle
*/
struct TALER_MINT_AdminAddIncomingHandle
struct TALER_EXCHANGE_AdminAddIncomingHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -65,7 +66,7 @@ struct TALER_MINT_AdminAddIncomingHandle
/**
* Function to call with the result.
*/
TALER_MINT_AdminAddIncomingResultCallback cb;
TALER_EXCHANGE_AdminAddIncomingResultCallback cb;
/**
* Closure for @a cb.
@ -84,14 +85,14 @@ struct TALER_MINT_AdminAddIncomingHandle
* Function called when we're done processing the
* HTTP /admin/add/incoming request.
*
* @param cls the `struct TALER_MINT_AdminAddIncomingHandle`
* @param cls the `struct TALER_EXCHANGE_AdminAddIncomingHandle`
* @param eh the curl request handle
*/
static void
handle_admin_add_incoming_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_AdminAddIncomingHandle *aai = cls;
struct TALER_EXCHANGE_AdminAddIncomingHandle *aai = cls;
long response_code;
json_t *json;
@ -106,14 +107,14 @@ handle_admin_add_incoming_finished (void *cls,
case MHD_HTTP_OK:
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_FORBIDDEN:
/* Access denied */
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, mint says one of the signatures is
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
@ -138,17 +139,17 @@ handle_admin_add_incoming_finished (void *cls,
response_code,
json);
json_decref (json);
TALER_MINT_admin_add_incoming_cancel (aai);
TALER_EXCHANGE_admin_add_incoming_cancel (aai);
}
/**
* Notify the mint that we have received an incoming transaction
* Notify the exchange that we have received an incoming transaction
* which fills a reserve. Note that this API is an administrative
* API and thus not accessible to typical mint clients, but only
* to the operators of the mint.
* API and thus not accessible to typical exchange clients, but only
* to the operators of the exchange.
*
* @param mint the mint handle; the mint must be ready to operate
* @param exchange the exchange handle; the exchange must be ready to operate
* @param reserve_pub public key of the reserve
* @param amount amount that was deposited
* @param execution_date when did we receive the amount
@ -159,40 +160,40 @@ handle_admin_add_incoming_finished (void *cls,
* if the inputs are invalid (i.e. invalid amount).
* In this case, the callback is not called.
*/
struct TALER_MINT_AdminAddIncomingHandle *
TALER_MINT_admin_add_incoming (struct TALER_MINT_Handle *mint,
struct TALER_EXCHANGE_AdminAddIncomingHandle *
TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute execution_date,
const json_t *wire,
TALER_MINT_AdminAddIncomingResultCallback res_cb,
TALER_EXCHANGE_AdminAddIncomingResultCallback res_cb,
void *res_cb_cls)
{
struct TALER_MINT_AdminAddIncomingHandle *aai;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_AdminAddIncomingHandle *aai;
struct TALER_EXCHANGE_Context *ctx;
json_t *admin_obj;
CURL *eh;
GNUNET_assert (GNUNET_OK ==
TALER_round_abs_time (&execution_date));
GNUNET_TIME_round_abs (&execution_date));
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
}
admin_obj = json_pack ("{s:o, s:o," /* reserve_pub/amount */
" s:o, s:O}", /* execution_Date/wire */
"reserve_pub", TALER_json_from_data (reserve_pub,
"reserve_pub", GNUNET_JSON_from_data (reserve_pub,
sizeof (*reserve_pub)),
"amount", TALER_json_from_amount (amount),
"execution_date", TALER_json_from_abs (execution_date),
"amount", TALER_JSON_from_amount (amount),
"execution_date", GNUNET_JSON_from_time_abs (execution_date),
"wire", wire);
aai = GNUNET_new (struct TALER_MINT_AdminAddIncomingHandle);
aai->mint = mint;
aai = GNUNET_new (struct TALER_EXCHANGE_AdminAddIncomingHandle);
aai->exchange = exchange;
aai->cb = res_cb;
aai->cb_cls = res_cb_cls;
aai->url = MAH_path_to_url (mint, "/admin/add/incoming");
aai->url = MAH_path_to_url (exchange, "/admin/add/incoming");
eh = curl_easy_init ();
GNUNET_assert (NULL != (aai->json_enc =
@ -219,7 +220,7 @@ TALER_MINT_admin_add_incoming (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&aai->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
aai->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -236,7 +237,7 @@ TALER_MINT_admin_add_incoming (struct TALER_MINT_Handle *mint,
* @param aai the admin add incoming request handle
*/
void
TALER_MINT_admin_add_incoming_cancel (struct TALER_MINT_AdminAddIncomingHandle *aai)
TALER_EXCHANGE_admin_add_incoming_cancel (struct TALER_EXCHANGE_AdminAddIncomingHandle *aai)
{
if (NULL != aai->job)
{
@ -251,4 +252,4 @@ TALER_MINT_admin_add_incoming_cancel (struct TALER_MINT_AdminAddIncomingHandle *
}
/* end of mint_api_admin.c */
/* end of exchange_api_admin.c */

View File

@ -15,20 +15,20 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_common.c
* @brief common functions for the mint API
* @file exchange-lib/exchange_api_common.c
* @brief common functions for the exchange API
* @author Christian Grothoff
*/
#include "platform.h"
#include "mint_api_common.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include "exchange_api_common.h"
#include "taler_json_lib.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
/**
* Verify a coins transaction history as returned by the mint.
* Verify a coins transaction history as returned by the exchange.
*
* @param currency expected currency for the coin
* @param coin_pub public key of the coin
@ -37,10 +37,10 @@
* @return #GNUNET_OK if @a history is valid, #GNUNET_SYSERR if not
*/
int
TALER_MINT_verify_coin_history_ (const char *currency,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
json_t *history,
struct TALER_Amount *total)
TALER_EXCHANGE_verify_coin_history_ (const char *currency,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
json_t *history,
struct TALER_Amount *total)
{
size_t len;
size_t off;
@ -66,24 +66,25 @@ TALER_MINT_verify_coin_history_ (const char *currency,
void *details;
size_t details_size;
const char *type;
struct MAJ_Specification spec[] = {
MAJ_spec_amount ("amount",
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("amount",
&amount),
MAJ_spec_string ("type",
GNUNET_JSON_spec_string ("type",
&type),
MAJ_spec_fixed_auto ("signature",
GNUNET_JSON_spec_fixed_auto ("signature",
&sig),
MAJ_spec_varsize ("details",
GNUNET_JSON_spec_varsize ("details",
&details,
&details_size),
MAJ_spec_end
GNUNET_JSON_spec_end()
};
transaction = json_array_get (history,
off);
if (GNUNET_OK !=
MAJ_parse_json (transaction,
spec))
GNUNET_JSON_parse (transaction,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -97,14 +98,14 @@ TALER_MINT_verify_coin_history_ (const char *currency,
if (details_size != sizeof (struct TALER_DepositRequestPS))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
dr = (const struct TALER_DepositRequestPS *) details;
if (details_size != ntohl (dr->purpose.size))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -114,18 +115,17 @@ TALER_MINT_verify_coin_history_ (const char *currency,
&coin_pub->eddsa_pub))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
// FIXME: check sig!
TALER_amount_ntoh (&dr_amount,
&dr->amount_with_fee);
if (0 != TALER_amount_cmp (&dr_amount,
&amount))
{
GNUNET_break (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
@ -138,14 +138,14 @@ TALER_MINT_verify_coin_history_ (const char *currency,
if (details_size != sizeof (struct TALER_RefreshMeltCoinAffirmationPS))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
rm = (const struct TALER_RefreshMeltCoinAffirmationPS *) details;
if (details_size != ntohl (rm->purpose.size))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -155,7 +155,7 @@ TALER_MINT_verify_coin_history_ (const char *currency,
&coin_pub->eddsa_pub))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
TALER_amount_ntoh (&rm_amount,
@ -164,7 +164,7 @@ TALER_MINT_verify_coin_history_ (const char *currency,
&amount))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
@ -172,7 +172,7 @@ TALER_MINT_verify_coin_history_ (const char *currency,
{
/* signature not supported, new version on server? */
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -180,15 +180,15 @@ TALER_MINT_verify_coin_history_ (const char *currency,
total,
&amount))
{
/* overflow in history already!? inconceivable! Bad mint! */
/* overflow in history already!? inconceivable! Bad exchange! */
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
}
return GNUNET_OK;
}
/* end of mint_api_common.c */
/* end of exchange_api_common.c */

View File

@ -15,16 +15,16 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_common.h
* @brief common functions for the mint API
* @file exchange-lib/exchange_api_common.h
* @brief common functions for the exchange API
* @author Christian Grothoff
*/
#include <jansson.h>
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "taler_exchange_service.h"
/**
* Verify a coins transaction history as returned by the mint.
* Verify a coins transaction history as returned by the exchange.
*
* @param currency expected currency for the coin
* @param coin_pub public key of the coin
@ -33,9 +33,9 @@
* @return #GNUNET_OK if @a history is valid, #GNUNET_SYSERR if not
*/
int
TALER_MINT_verify_coin_history_ (const char *currency,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
json_t *history,
struct TALER_Amount *total);
TALER_EXCHANGE_verify_coin_history_ (const char *currency,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
json_t *history,
struct TALER_Amount *total);
/* end of mint_api_common.h */
/* end of exchange_api_common.h */

View File

@ -15,15 +15,15 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_context.c
* @brief Implementation of the context part of the mint's HTTP API
* @file exchange-lib/exchange_api_context.c
* @brief Implementation of the context part of the exchange's HTTP API
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff
*/
#include "platform.h"
#include <curl/curl.h>
#include "taler_mint_service.h"
#include "mint_api_context.h"
#include "taler_exchange_service.h"
#include "exchange_api_context.h"
/**
@ -51,11 +51,11 @@
* Failsafe flag. Raised if our constructor fails to initialize
* the Curl library.
*/
static int TALER_MINT_curl_fail;
static int TALER_EXCHANGE_curl_fail;
/**
* Jobs are CURL requests running within a `struct TALER_MINT_Context`.
* Jobs are CURL requests running within a `struct TALER_EXCHANGE_Context`.
*/
struct MAC_Job
{
@ -78,7 +78,7 @@ struct MAC_Job
/**
* Context this job runs in.
*/
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_Context *ctx;
/**
* Function to call upon completion.
@ -96,7 +96,7 @@ struct MAC_Job
/**
* Context
*/
struct TALER_MINT_Context
struct TALER_EXCHANGE_Context
{
/**
* Curl multi handle
@ -133,14 +133,14 @@ struct TALER_MINT_Context
*
* @return library context
*/
struct TALER_MINT_Context *
TALER_MINT_init ()
struct TALER_EXCHANGE_Context *
TALER_EXCHANGE_init ()
{
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_Context *ctx;
CURLM *multi;
CURLSH *share;
if (TALER_MINT_curl_fail)
if (TALER_EXCHANGE_curl_fail)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Curl was not initialised properly\n");
@ -158,7 +158,7 @@ TALER_MINT_init ()
"Failed to create a Curl share handle\n");
return NULL;
}
ctx = GNUNET_new (struct TALER_MINT_Context);
ctx = GNUNET_new (struct TALER_EXCHANGE_Context);
ctx->multi = multi;
ctx->share = share;
GNUNET_assert (NULL != (ctx->json_header =
@ -186,7 +186,7 @@ TALER_MINT_init ()
* @param jcc_cls closure for @a jcc
*/
struct MAC_Job *
MAC_job_add (struct TALER_MINT_Context *ctx,
MAC_job_add (struct TALER_EXCHANGE_Context *ctx,
CURL *eh,
int add_json,
MAC_JobCompletionCallback jcc,
@ -252,7 +252,7 @@ MAC_easy_to_closure (CURL *eh)
void
MAC_job_cancel (struct MAC_Job *job)
{
struct TALER_MINT_Context *ctx = job->ctx;
struct TALER_EXCHANGE_Context *ctx = job->ctx;
GNUNET_CONTAINER_DLL_remove (ctx->jobs_head,
ctx->jobs_tail,
@ -271,7 +271,7 @@ MAC_job_cancel (struct MAC_Job *job)
* @param ctx the library context
*/
void
TALER_MINT_perform (struct TALER_MINT_Context *ctx)
TALER_EXCHANGE_perform (struct TALER_EXCHANGE_Context *ctx)
{
CURLMsg *cmsg;
struct MAC_Job *job;
@ -299,12 +299,12 @@ TALER_MINT_perform (struct TALER_MINT_Context *ctx)
/**
* Obtain the information for a select() call to wait until
* #TALER_MINT_perform() is ready again. Note that calling
* any other TALER_MINT-API may also imply that the library
* is again ready for #TALER_MINT_perform().
* #TALER_EXCHANGE_perform() is ready again. Note that calling
* any other TALER_EXCHANGE-API may also imply that the library
* is again ready for #TALER_EXCHANGE_perform().
*
* Basically, a client should use this API to prepare for select(),
* then block on select(), then call #TALER_MINT_perform() and then
* then block on select(), then call #TALER_EXCHANGE_perform() and then
* start again until the work with the context is done.
*
* This function will NOT zero out the sets and assumes that @a max_fd
@ -323,15 +323,15 @@ TALER_MINT_perform (struct TALER_MINT_Context *ctx)
* to be passed to select().)
* @param timeout set to the timeout in milliseconds (!); -1 means
* no timeout (NULL, blocking forever is OK), 0 means to
* proceed immediately with #TALER_MINT_perform().
* proceed immediately with #TALER_EXCHANGE_perform().
*/
void
TALER_MINT_get_select_info (struct TALER_MINT_Context *ctx,
fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *except_fd_set,
int *max_fd,
long *timeout)
TALER_EXCHANGE_get_select_info (struct TALER_EXCHANGE_Context *ctx,
fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *except_fd_set,
int *max_fd,
long *timeout)
{
long to;
int m;
@ -368,7 +368,7 @@ TALER_MINT_get_select_info (struct TALER_MINT_Context *ctx,
* @param ctx the library context
*/
void
TALER_MINT_fini (struct TALER_MINT_Context *ctx)
TALER_EXCHANGE_fini (struct TALER_EXCHANGE_Context *ctx)
{
/* all jobs must have been cancelled at this time, assert this */
GNUNET_assert (NULL == ctx->jobs_head);
@ -508,7 +508,7 @@ MAC_download_get_result (struct MAC_DownloadBuffer *db,
*/
__attribute__ ((constructor))
void
TALER_MINT_constructor__ (void)
TALER_EXCHANGE_constructor__ (void)
{
CURLcode ret;
@ -517,7 +517,7 @@ TALER_MINT_constructor__ (void)
CURL_STRERROR (GNUNET_ERROR_TYPE_ERROR,
"curl_global_init",
ret);
TALER_MINT_curl_fail = 1;
TALER_EXCHANGE_curl_fail = 1;
}
}
@ -527,11 +527,11 @@ TALER_MINT_constructor__ (void)
*/
__attribute__ ((destructor))
void
TALER_MINT_destructor__ (void)
TALER_EXCHANGE_destructor__ (void)
{
if (TALER_MINT_curl_fail)
if (TALER_EXCHANGE_curl_fail)
return;
curl_global_cleanup ();
}
/* end of mint_api_context.c */
/* end of exchange_api_context.c */

View File

@ -15,15 +15,15 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_context.h
* @brief Internal interface to the context part of the mint's HTTP API
* @file exchange-lib/exchange_api_context.h
* @brief Internal interface to the context part of the exchange's HTTP API
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff
*/
#include "platform.h"
#include <curl/curl.h>
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "taler_exchange_service.h"
#include "taler_signatures.h"
@ -61,7 +61,7 @@ typedef void
* @param jcc_cls closure for @a jcc
*/
struct MAC_Job *
MAC_job_add (struct TALER_MINT_Context *ctx,
MAC_job_add (struct TALER_EXCHANGE_Context *ctx,
CURL *eh,
int add_json,
MAC_JobCompletionCallback jcc,
@ -166,4 +166,4 @@ MAC_download_get_result (struct MAC_DownloadBuffer *db,
long *response_code);
/* end of mint_api_context.h */
/* end of exchange_api_context.h */

View File

@ -15,8 +15,8 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_deposit.c
* @brief Implementation of the /deposit request of the mint's HTTP API
* @file exchange-lib/exchange_api_deposit.c
* @brief Implementation of the /deposit request of the exchange's HTTP API
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff
*/
@ -25,24 +25,25 @@
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "mint_api_common.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include <gnunet/gnunet_json_lib.h>
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
#include "exchange_api_common.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
/**
* @brief A Deposit Handle
*/
struct TALER_MINT_DepositHandle
struct TALER_EXCHANGE_DepositHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -62,7 +63,7 @@ struct TALER_MINT_DepositHandle
/**
* Function to call with the result.
*/
TALER_MINT_DepositResultCallback cb;
TALER_EXCHANGE_DepositResultCallback cb;
/**
* Closure for @a cb.
@ -75,7 +76,7 @@ struct TALER_MINT_DepositHandle
struct MAC_DownloadBuffer db;
/**
* Information the mint should sign in response.
* Information the exchange should sign in response.
*/
struct TALER_DepositConfirmationPS depconf;
@ -94,45 +95,46 @@ struct TALER_MINT_DepositHandle
/**
* Verify that the signature on the "200 OK" response
* from the mint is valid.
* from the exchange is valid.
*
* @param dh deposit handle
* @param json json reply with the signature
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
*/
static int
verify_deposit_signature_ok (const struct TALER_MINT_DepositHandle *dh,
verify_deposit_signature_ok (const struct TALER_EXCHANGE_DepositHandle *dh,
json_t *json)
{
struct TALER_MintSignatureP mint_sig;
struct TALER_MintPublicKeyP mint_pub;
const struct TALER_MINT_Keys *key_state;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("sig", &mint_sig),
MAJ_spec_fixed_auto ("pub", &mint_pub),
MAJ_spec_end
struct TALER_ExchangeSignatureP exchange_sig;
struct TALER_ExchangePublicKeyP exchange_pub;
const struct TALER_EXCHANGE_Keys *key_state;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("sig", &exchange_sig),
GNUNET_JSON_spec_fixed_auto ("pub", &exchange_pub),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
key_state = TALER_MINT_get_keys (dh->mint);
key_state = TALER_EXCHANGE_get_keys (dh->exchange);
if (GNUNET_OK !=
TALER_MINT_test_signing_key (key_state,
&mint_pub))
TALER_EXCHANGE_test_signing_key (key_state,
&exchange_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_CONFIRM_DEPOSIT,
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT,
&dh->depconf.purpose,
&mint_sig.eddsa_signature,
&mint_pub.eddsa_pub))
&exchange_sig.eddsa_signature,
&exchange_pub.eddsa_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -143,14 +145,14 @@ verify_deposit_signature_ok (const struct TALER_MINT_DepositHandle *dh,
/**
* Verify that the signatures on the "403 FORBIDDEN" response from the
* mint demonstrating customer double-spending are valid.
* exchange demonstrating customer double-spending are valid.
*
* @param dh deposit handle
* @param json json reply with the signature(s) and transaction history
* @return #GNUNET_OK if the signature(s) is valid, #GNUNET_SYSERR if not
*/
static int
verify_deposit_signature_forbidden (const struct TALER_MINT_DepositHandle *dh,
verify_deposit_signature_forbidden (const struct TALER_EXCHANGE_DepositHandle *dh,
json_t *json)
{
json_t *history;
@ -159,7 +161,7 @@ verify_deposit_signature_forbidden (const struct TALER_MINT_DepositHandle *dh,
history = json_object_get (json,
"history");
if (GNUNET_OK !=
TALER_MINT_verify_coin_history_ (dh->coin_value.currency,
TALER_EXCHANGE_verify_coin_history_ (dh->coin_value.currency,
&dh->depconf.coin_pub,
history,
&total))
@ -193,14 +195,14 @@ verify_deposit_signature_forbidden (const struct TALER_MINT_DepositHandle *dh,
* Function called when we're done processing the
* HTTP /deposit request.
*
* @param cls the `struct TALER_MINT_DepositHandle`
* @param cls the `struct TALER_EXCHANGE_DepositHandle`
* @param eh the curl request handle
*/
static void
handle_deposit_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_DepositHandle *dh = cls;
struct TALER_EXCHANGE_DepositHandle *dh = cls;
long response_code;
json_t *json;
@ -222,7 +224,7 @@ handle_deposit_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_FORBIDDEN:
@ -236,7 +238,7 @@ handle_deposit_finished (void *cls,
}
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, mint says one of the signatures is
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
@ -261,7 +263,7 @@ handle_deposit_finished (void *cls,
response_code,
json);
json_decref (json);
TALER_MINT_deposit_cancel (dh);
TALER_EXCHANGE_deposit_cancel (dh);
}
@ -271,19 +273,19 @@ handle_deposit_finished (void *cls,
* @param dki public key information
* @param amount the amount to be deposited
* @param h_wire hash of the merchants account details
* @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint)
* @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the exchange)
* @param coin_pub coins public key
* @param denom_pub denomination key with which the coin is signed
* @param denom_sig mints unblinded signature of the coin
* @param timestamp timestamp when the contract was finalized, must match approximately the current time of the mint
* @param denom_sig exchanges unblinded signature of the coin
* @param timestamp timestamp when the contract was finalized, must match approximately the current time of the exchange
* @param transaction_id transaction id for the transaction between merchant and customer
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
* @param refund_deadline date until which the merchant can issue a refund to the customer via the mint (can be zero if refunds are not allowed)
* @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed)
* @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT made by the customer with the coins private key.
* @return #GNUNET_OK if signatures are OK, #GNUNET_SYSERR if not
*/
static int
verify_signatures (const struct TALER_MINT_DenomPublicKey *dki,
verify_signatures (const struct TALER_EXCHANGE_DenomPublicKey *dki,
const struct TALER_Amount *amount,
const struct GNUNET_HashCode *h_wire,
const struct GNUNET_HashCode *h_contract,
@ -353,40 +355,40 @@ verify_signatures (const struct TALER_MINT_DenomPublicKey *dki,
/**
* Submit a deposit permission to the mint and get the mint's response.
* Submit a deposit permission to the exchange and get the exchange's response.
* Note that while we return the response verbatim to the caller for
* further processing, we do already verify that the response is
* well-formed (i.e. that signatures included in the response are all
* valid). If the mint's reply is not well-formed, we return an
* valid). If the exchange's reply is not well-formed, we return an
* HTTP status code of zero to @a cb.
*
* We also verify that the @a coin_sig is valid for this deposit
* request, and that the @a ub_sig is a valid signature for @a
* coin_pub. Also, the @a mint must be ready to operate (i.e. have
* coin_pub. Also, the @a exchange must be ready to operate (i.e. have
* finished processing the /keys reply). If either check fails, we do
* NOT initiate the transaction with the mint and instead return NULL.
* NOT initiate the transaction with the exchange and instead return NULL.
*
* @param mint the mint handle; the mint must be ready to operate
* @param exchange the exchange handle; the exchange must be ready to operate
* @param amount the amount to be deposited
* @param wire_deadline date until which the merchant would like the mint to settle the balance (advisory, the mint cannot be
* forced to settle in the past or upon very short notice, but of course a well-behaved mint will limit aggregation based on the advice received)
* @param wire_details the merchants account details, in a format supported by the mint
* @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint)
* @param wire_deadline date until which the merchant would like the exchange to settle the balance (advisory, the exchange cannot be
* forced to settle in the past or upon very short notice, but of course a well-behaved exchange will limit aggregation based on the advice received)
* @param wire_details the merchants account details, in a format supported by the exchange
* @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the exchange)
* @param coin_pub coins public key
* @param denom_pub denomination key with which the coin is signed
* @param denom_sig mints unblinded signature of the coin
* @param timestamp timestamp when the contract was finalized, must match approximately the current time of the mint
* @param denom_sig exchanges unblinded signature of the coin
* @param timestamp timestamp when the contract was finalized, must match approximately the current time of the exchange
* @param transaction_id transaction id for the transaction between merchant and customer
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
* @param refund_deadline date until which the merchant can issue a refund to the customer via the mint (can be zero if refunds are not allowed)
* @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed)
* @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT made by the customer with the coins private key.
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
* signatures fail to verify). In this case, the callback is not called.
*/
struct TALER_MINT_DepositHandle *
TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
struct TALER_EXCHANGE_DepositHandle *
TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute wire_deadline,
json_t *wire_details,
@ -399,39 +401,39 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
const struct TALER_MerchantPublicKeyP *merchant_pub,
struct GNUNET_TIME_Absolute refund_deadline,
const struct TALER_CoinSpendSignatureP *coin_sig,
TALER_MINT_DepositResultCallback cb,
TALER_EXCHANGE_DepositResultCallback cb,
void *cb_cls)
{
const struct TALER_MINT_Keys *key_state;
const struct TALER_MINT_DenomPublicKey *dki;
struct TALER_MINT_DepositHandle *dh;
struct TALER_MINT_Context *ctx;
const struct TALER_EXCHANGE_Keys *key_state;
const struct TALER_EXCHANGE_DenomPublicKey *dki;
struct TALER_EXCHANGE_DepositHandle *dh;
struct TALER_EXCHANGE_Context *ctx;
json_t *deposit_obj;
CURL *eh;
struct GNUNET_HashCode h_wire;
struct TALER_Amount amount_without_fee;
(void) TALER_round_abs_time (&wire_deadline);
(void) GNUNET_TIME_round_abs (&wire_deadline);
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
}
/* initialize h_wire */
if (GNUNET_OK !=
TALER_hash_json (wire_details,
TALER_JSON_hash (wire_details,
&h_wire))
{
GNUNET_break (0);
return NULL;
}
key_state = TALER_MINT_get_keys (mint);
dki = TALER_MINT_get_denomination_key (key_state,
key_state = TALER_EXCHANGE_get_keys (exchange);
dki = TALER_EXCHANGE_get_denomination_key (key_state,
denom_pub);
if (NULL == dki)
{
TALER_LOG_WARNING ("Denomination key unknown to mint\n");
TALER_LOG_WARNING ("Denomination key unknown to exchange\n");
return NULL;
}
if (GNUNET_SYSERR ==
@ -468,33 +470,33 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
" s:I, s:o," /* transaction id, merchant_pub */
" s:o, s:o," /* refund_deadline, wire_deadline */
" s:o}", /* coin_sig */
"f", TALER_json_from_amount (amount),
"f", TALER_JSON_from_amount (amount),
"wire", wire_details,
"H_wire", TALER_json_from_data (&h_wire,
"H_wire", GNUNET_JSON_from_data (&h_wire,
sizeof (h_wire)),
"H_contract", TALER_json_from_data (h_contract,
"H_contract", GNUNET_JSON_from_data (h_contract,
sizeof (struct GNUNET_HashCode)),
"coin_pub", TALER_json_from_data (coin_pub,
"coin_pub", GNUNET_JSON_from_data (coin_pub,
sizeof (*coin_pub)),
"denom_pub", TALER_json_from_rsa_public_key (denom_pub->rsa_public_key),
"ub_sig", TALER_json_from_rsa_signature (denom_sig->rsa_signature),
"timestamp", TALER_json_from_abs (timestamp),
"denom_pub", GNUNET_JSON_from_rsa_public_key (denom_pub->rsa_public_key),
"ub_sig", GNUNET_JSON_from_rsa_signature (denom_sig->rsa_signature),
"timestamp", GNUNET_JSON_from_time_abs (timestamp),
"transaction_id", (json_int_t) transaction_id,
"merchant_pub", TALER_json_from_data (merchant_pub,
"merchant_pub", GNUNET_JSON_from_data (merchant_pub,
sizeof (*merchant_pub)),
"refund_deadline", TALER_json_from_abs (refund_deadline),
"edate", TALER_json_from_abs (wire_deadline),
"coin_sig", TALER_json_from_data (coin_sig,
"refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline),
"edate", GNUNET_JSON_from_time_abs (wire_deadline),
"coin_sig", GNUNET_JSON_from_data (coin_sig,
sizeof (*coin_sig))
);
dh = GNUNET_new (struct TALER_MINT_DepositHandle);
dh->mint = mint;
dh = GNUNET_new (struct TALER_EXCHANGE_DepositHandle);
dh->exchange = exchange;
dh->cb = cb;
dh->cb_cls = cb_cls;
dh->url = MAH_path_to_url (mint, "/deposit");
dh->url = MAH_path_to_url (exchange, "/deposit");
dh->depconf.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS));
dh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_MINT_CONFIRM_DEPOSIT);
dh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT);
dh->depconf.h_contract = *h_contract;
dh->depconf.h_wire = h_wire;
dh->depconf.transaction_id = GNUNET_htonll (transaction_id);
@ -535,7 +537,7 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&dh->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
dh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -552,7 +554,7 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
* @param deposit the deposit permission request handle
*/
void
TALER_MINT_deposit_cancel (struct TALER_MINT_DepositHandle *deposit)
TALER_EXCHANGE_deposit_cancel (struct TALER_EXCHANGE_DepositHandle *deposit)
{
if (NULL != deposit->job)
{
@ -566,4 +568,4 @@ TALER_MINT_deposit_cancel (struct TALER_MINT_DepositHandle *deposit)
}
/* end of mint_api_deposit.c */
/* end of exchange_api_deposit.c */

View File

@ -15,8 +15,8 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_deposit_wtid.c
* @brief Implementation of the /deposit/wtid request of the mint's HTTP API
* @file exchange-lib/exchange_api_deposit_wtid.c
* @brief Implementation of the /deposit/wtid request of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
@ -24,24 +24,25 @@
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "mint_api_common.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include <gnunet/gnunet_json_lib.h>
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
#include "exchange_api_common.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
/**
* @brief A Deposit Wtid Handle
*/
struct TALER_MINT_DepositWtidHandle
struct TALER_EXCHANGE_DepositWtidHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -61,7 +62,7 @@ struct TALER_MINT_DepositWtidHandle
/**
* Function to call with the result.
*/
TALER_MINT_DepositWtidCallback cb;
TALER_EXCHANGE_DepositWtidCallback cb;
/**
* Closure for @a cb.
@ -74,7 +75,7 @@ struct TALER_MINT_DepositWtidHandle
struct MAC_DownloadBuffer db;
/**
* Information the mint should sign in response.
* Information the exchange should sign in response.
* (with pre-filled fields from the request).
*/
struct TALER_ConfirmWirePS depconf;
@ -84,45 +85,46 @@ struct TALER_MINT_DepositWtidHandle
/**
* Verify that the signature on the "200 OK" response
* from the mint is valid.
* from the exchange is valid.
*
* @param dwh deposit wtid handle
* @param json json reply with the signature
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
*/
static int
verify_deposit_wtid_signature_ok (const struct TALER_MINT_DepositWtidHandle *dwh,
verify_deposit_wtid_signature_ok (const struct TALER_EXCHANGE_DepositWtidHandle *dwh,
json_t *json)
{
struct TALER_MintSignatureP mint_sig;
struct TALER_MintPublicKeyP mint_pub;
const struct TALER_MINT_Keys *key_state;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("mint_sig", &mint_sig),
MAJ_spec_fixed_auto ("mint_pub", &mint_pub),
MAJ_spec_end
struct TALER_ExchangeSignatureP exchange_sig;
struct TALER_ExchangePublicKeyP exchange_pub;
const struct TALER_EXCHANGE_Keys *key_state;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
key_state = TALER_MINT_get_keys (dwh->mint);
key_state = TALER_EXCHANGE_get_keys (dwh->exchange);
if (GNUNET_OK !=
TALER_MINT_test_signing_key (key_state,
&mint_pub))
TALER_EXCHANGE_test_signing_key (key_state,
&exchange_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_CONFIRM_WIRE,
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE,
&dwh->depconf.purpose,
&mint_sig.eddsa_signature,
&mint_pub.eddsa_pub))
&exchange_sig.eddsa_signature,
&exchange_pub.eddsa_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -135,14 +137,14 @@ verify_deposit_wtid_signature_ok (const struct TALER_MINT_DepositWtidHandle *dwh
* Function called when we're done processing the
* HTTP /deposit/wtid request.
*
* @param cls the `struct TALER_MINT_DepositWtidHandle`
* @param cls the `struct TALER_EXCHANGE_DepositWtidHandle`
* @param eh the curl request handle
*/
static void
handle_deposit_wtid_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_DepositWtidHandle *dwh = cls;
struct TALER_EXCHANGE_DepositWtidHandle *dwh = cls;
long response_code;
json_t *json;
const struct TALER_WireTransferIdentifierRawP *wtid = NULL;
@ -160,16 +162,17 @@ handle_deposit_wtid_finished (void *cls,
break;
case MHD_HTTP_OK:
{
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("wtid", &dwh->depconf.wtid),
MAJ_spec_absolute_time ("execution_time", &execution_time),
MAJ_spec_amount ("coin_contribution", &coin_contribution_s),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid),
GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time),
TALER_JSON_spec_amount ("coin_contribution", &coin_contribution_s),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
response_code = 0;
@ -192,14 +195,15 @@ handle_deposit_wtid_finished (void *cls,
case MHD_HTTP_ACCEPTED:
{
/* Transaction known, but not executed yet */
struct MAJ_Specification spec[] = {
MAJ_spec_absolute_time ("execution_time", &execution_time),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
response_code = 0;
@ -208,16 +212,16 @@ handle_deposit_wtid_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, mint says one of the signatures is
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
/* Mint does not know about transaction;
/* Exchange does not know about transaction;
we should pass the reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
@ -240,14 +244,14 @@ handle_deposit_wtid_finished (void *cls,
execution_time,
coin_contribution);
json_decref (json);
TALER_MINT_deposit_wtid_cancel (dwh);
TALER_EXCHANGE_deposit_wtid_cancel (dwh);
}
/**
* Obtain wire transfer details about an existing deposit operation.
*
* @param mint the mint to query
* @param exchange the exchange to query
* @param merchant_priv the merchant's private key
* @param h_wire hash of merchant's wire transfer details
* @param h_contract hash of the contract
@ -257,25 +261,25 @@ handle_deposit_wtid_finished (void *cls,
* @param cb_cls closure for @a cb
* @return handle to abort request
*/
struct TALER_MINT_DepositWtidHandle *
TALER_MINT_deposit_wtid (struct TALER_MINT_Handle *mint,
struct TALER_EXCHANGE_DepositWtidHandle *
TALER_EXCHANGE_deposit_wtid (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_MerchantPrivateKeyP *merchant_priv,
const struct GNUNET_HashCode *h_wire,
const struct GNUNET_HashCode *h_contract,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
uint64_t transaction_id,
TALER_MINT_DepositWtidCallback cb,
TALER_EXCHANGE_DepositWtidCallback cb,
void *cb_cls)
{
struct TALER_DepositTrackPS dtp;
struct TALER_MerchantSignatureP merchant_sig;
struct TALER_MINT_DepositWtidHandle *dwh;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_DepositWtidHandle *dwh;
struct TALER_EXCHANGE_Context *ctx;
json_t *deposit_wtid_obj;
CURL *eh;
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
@ -296,25 +300,25 @@ TALER_MINT_deposit_wtid (struct TALER_MINT_Handle *mint,
deposit_wtid_obj = json_pack ("{s:o, s:o," /* H_wire, H_contract */
" s:o, s:I," /* coin_pub, transaction_id */
" s:o, s:o}", /* merchant_pub, merchant_sig */
"H_wire", TALER_json_from_data (h_wire,
"H_wire", GNUNET_JSON_from_data (h_wire,
sizeof (struct GNUNET_HashCode)),
"H_contract", TALER_json_from_data (h_contract,
"H_contract", GNUNET_JSON_from_data (h_contract,
sizeof (struct GNUNET_HashCode)),
"coin_pub", TALER_json_from_data (coin_pub,
"coin_pub", GNUNET_JSON_from_data (coin_pub,
sizeof (*coin_pub)),
"transaction_id", (json_int_t) transaction_id,
"merchant_pub", TALER_json_from_data (&dtp.merchant,
"merchant_pub", GNUNET_JSON_from_data (&dtp.merchant,
sizeof (struct TALER_MerchantPublicKeyP)),
"merchant_sig", TALER_json_from_data (&merchant_sig,
"merchant_sig", GNUNET_JSON_from_data (&merchant_sig,
sizeof (merchant_sig)));
dwh = GNUNET_new (struct TALER_MINT_DepositWtidHandle);
dwh->mint = mint;
dwh = GNUNET_new (struct TALER_EXCHANGE_DepositWtidHandle);
dwh->exchange = exchange;
dwh->cb = cb;
dwh->cb_cls = cb_cls;
dwh->url = MAH_path_to_url (mint, "/deposit/wtid");
dwh->url = MAH_path_to_url (exchange, "/deposit/wtid");
dwh->depconf.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS));
dwh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_MINT_CONFIRM_WIRE);
dwh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE);
dwh->depconf.h_wire = *h_wire;
dwh->depconf.h_contract = *h_contract;
dwh->depconf.coin_pub = *coin_pub;
@ -345,7 +349,7 @@ TALER_MINT_deposit_wtid (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&dwh->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
dwh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -362,7 +366,7 @@ TALER_MINT_deposit_wtid (struct TALER_MINT_Handle *mint,
* @param dwh the wire deposits request handle
*/
void
TALER_MINT_deposit_wtid_cancel (struct TALER_MINT_DepositWtidHandle *dwh)
TALER_EXCHANGE_deposit_wtid_cancel (struct TALER_EXCHANGE_DepositWtidHandle *dwh)
{
if (NULL != dwh->job)
{
@ -376,4 +380,4 @@ TALER_MINT_deposit_wtid_cancel (struct TALER_MINT_DepositWtidHandle *dwh)
}
/* end of mint_api_deposit_wtid.c */
/* end of exchange_api_deposit_wtid.c */

View File

@ -15,21 +15,19 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_handle.c
* @brief Implementation of the "handle" component of the mint's HTTP API
* @file exchange-lib/exchange_api_handle.c
* @brief Implementation of the "handle" component of the exchange's HTTP API
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff
*/
#include "platform.h"
#include <curl/curl.h>
#include <jansson.h>
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
#include "taler_mint_service.h"
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
#include "taler_signatures.h"
#include "mint_api_context.h"
#include "mint_api_json.h"
#include "mint_api_handle.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
/**
@ -45,9 +43,9 @@
/**
* Stages of initialization for the `struct TALER_MINT_Handle`
* Stages of initialization for the `struct TALER_EXCHANGE_Handle`
*/
enum MintHandleState
enum ExchangeHandleState
{
/**
* Just allocated.
@ -55,7 +53,7 @@ enum MintHandleState
MHS_INIT = 0,
/**
* Obtained the mint's certification data and keys.
* Obtained the exchange's certification data and keys.
*/
MHS_CERT = 1,
@ -67,31 +65,31 @@ enum MintHandleState
/**
* Data for the request to get the /keys of a mint.
* Data for the request to get the /keys of a exchange.
*/
struct KeysRequest;
/**
* Handle to the mint
* Handle to the exchange
*/
struct TALER_MINT_Handle
struct TALER_EXCHANGE_Handle
{
/**
* The context of this handle
*/
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_Context *ctx;
/**
* The URL of the mint (i.e. "http://mint.taler.net/")
* The URL of the exchange (i.e. "http://exchange.taler.net/")
*/
char *url;
/**
* Function to call with the mint's certification data,
* Function to call with the exchange's certification data,
* NULL if this has already been done.
*/
TALER_MINT_CertificationCallback cert_cb;
TALER_EXCHANGE_CertificationCallback cert_cb;
/**
* Closure to pass to @e cert_cb.
@ -99,21 +97,21 @@ struct TALER_MINT_Handle
void *cert_cb_cls;
/**
* Data for the request to get the /keys of a mint,
* Data for the request to get the /keys of a exchange,
* NULL once we are past stage #MHS_INIT.
*/
struct KeysRequest *kr;
/**
* Key data of the mint, only valid if
* Key data of the exchange, only valid if
* @e handshake_complete is past stage #MHS_CERT.
*/
struct TALER_MINT_Keys key_data;
struct TALER_EXCHANGE_Keys key_data;
/**
* Stage of the mint's initialization routines.
* Stage of the exchange's initialization routines.
*/
enum MintHandleState state;
enum ExchangeHandleState state;
};
@ -121,14 +119,14 @@ struct TALER_MINT_Handle
/* ***************** Internal /keys fetching ************* */
/**
* Data for the request to get the /keys of a mint.
* Data for the request to get the /keys of a exchange.
*/
struct KeysRequest
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this handle
@ -136,7 +134,7 @@ struct KeysRequest
char *url;
/**
* Entry for this request with the `struct TALER_MINT_Context`.
* Entry for this request with the `struct TALER_EXCHANGE_Context`.
*/
struct MAC_Job *job;
@ -171,7 +169,7 @@ free_keys_request (struct KeysRequest *kr)
/**
* Parse a mint's signing key encoded in JSON.
* Parse a exchange's signing key encoded in JSON.
*
* @param[out] sign_key where to return the result
* @param[in] sign_key_obj json to parse
@ -180,32 +178,33 @@ free_keys_request (struct KeysRequest *kr)
* invalid or the json malformed.
*/
static int
parse_json_signkey (struct TALER_MINT_SigningPublicKey *sign_key,
parse_json_signkey (struct TALER_EXCHANGE_SigningPublicKey *sign_key,
json_t *sign_key_obj,
const struct TALER_MasterPublicKeyP *master_key)
{
struct TALER_MintSigningKeyValidityPS sign_key_issue;
struct TALER_ExchangeSigningKeyValidityPS sign_key_issue;
struct GNUNET_CRYPTO_EddsaSignature sig;
struct GNUNET_TIME_Absolute valid_from;
struct GNUNET_TIME_Absolute valid_until;
struct GNUNET_TIME_Absolute valid_legal;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("master_sig",
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("master_sig",
&sig),
MAJ_spec_fixed_auto ("key",
GNUNET_JSON_spec_fixed_auto ("key",
&sign_key_issue.signkey_pub),
MAJ_spec_absolute_time ("stamp_start",
GNUNET_JSON_spec_absolute_time ("stamp_start",
&valid_from),
MAJ_spec_absolute_time ("stamp_expire",
GNUNET_JSON_spec_absolute_time ("stamp_expire",
&valid_until),
MAJ_spec_absolute_time ("stamp_end",
GNUNET_JSON_spec_absolute_time ("stamp_end",
&valid_legal),
MAJ_spec_end
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (sign_key_obj,
spec))
GNUNET_JSON_parse (sign_key_obj,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -213,8 +212,8 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey *sign_key,
sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY);
sign_key_issue.purpose.size =
htonl (sizeof (struct TALER_MintSigningKeyValidityPS)
- offsetof (struct TALER_MintSigningKeyValidityPS,
htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)
- offsetof (struct TALER_ExchangeSigningKeyValidityPS,
purpose));
sign_key_issue.master_public_key = *master_key;
sign_key_issue.start = GNUNET_TIME_absolute_hton (valid_from);
@ -237,7 +236,7 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey *sign_key,
/**
* Parse a mint's denomination key encoded in JSON.
* Parse a exchange's denomination key encoded in JSON.
*
* @param[out] denom_key where to return the result
* @param[in] denom_key_obj json to parse
@ -247,7 +246,7 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey *sign_key,
* invalid or the json malformed.
*/
static int
parse_json_denomkey (struct TALER_MINT_DenomPublicKey *denom_key,
parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
json_t *denom_key_obj,
struct TALER_MasterPublicKeyP *master_key,
struct GNUNET_HashContext *hash_context)
@ -261,36 +260,36 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey *denom_key,
struct TALER_Amount fee_deposit;
struct TALER_Amount fee_refresh;
struct TALER_DenominationKeyValidityPS denom_key_issue;
struct GNUNET_CRYPTO_rsa_PublicKey *pk;
struct GNUNET_CRYPTO_RsaPublicKey *pk;
struct GNUNET_CRYPTO_EddsaSignature sig;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("master_sig",
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("master_sig",
&sig),
MAJ_spec_absolute_time ("stamp_expire_deposit",
GNUNET_JSON_spec_absolute_time ("stamp_expire_deposit",
&deposit_valid_until),
MAJ_spec_absolute_time ("stamp_expire_withdraw",
GNUNET_JSON_spec_absolute_time ("stamp_expire_withdraw",
&withdraw_valid_until),
MAJ_spec_absolute_time ("stamp_start",
GNUNET_JSON_spec_absolute_time ("stamp_start",
&valid_from),
MAJ_spec_absolute_time ("stamp_expire_legal",
GNUNET_JSON_spec_absolute_time ("stamp_expire_legal",
&expire_legal),
MAJ_spec_amount ("value",
TALER_JSON_spec_amount ("value",
&value),
MAJ_spec_amount ("fee_withdraw",
TALER_JSON_spec_amount ("fee_withdraw",
&fee_withdraw),
MAJ_spec_amount ("fee_deposit",
TALER_JSON_spec_amount ("fee_deposit",
&fee_deposit),
MAJ_spec_amount ("fee_refresh",
TALER_JSON_spec_amount ("fee_refresh",
&fee_refresh),
MAJ_spec_rsa_public_key ("denom_pub",
GNUNET_JSON_spec_rsa_public_key ("denom_pub",
&pk),
MAJ_spec_end
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (denom_key_obj,
spec))
GNUNET_JSON_parse (denom_key_obj,
spec, NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -337,13 +336,13 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey *denom_key,
return GNUNET_OK;
EXITIF_exit:
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
/**
* Parse a mint's auditor information encoded in JSON.
* Parse a exchange's auditor information encoded in JSON.
*
* @param[out] auditor where to return the result
* @param[in] auditor_obj json to parse
@ -352,56 +351,64 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey *denom_key,
* invalid or the json malformed.
*/
static int
parse_json_auditor (struct TALER_MINT_AuditorInformation *auditor,
parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
json_t *auditor_obj,
const struct TALER_MINT_Keys *key_data)
const struct TALER_EXCHANGE_Keys *key_data)
{
json_t *keys;
json_t *key;
unsigned int len;
unsigned int off;
unsigned int i;
struct TALER_MintKeyValidityPS kv;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("auditor_pub",
&auditor->auditor_pub),
MAJ_spec_json ("denomination_keys",
&keys),
MAJ_spec_end
const char *auditor_url;
struct TALER_ExchangeKeyValidityPS kv;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("auditor_pub",
&auditor->auditor_pub),
GNUNET_JSON_spec_string ("auditor_url",
&auditor_url),
GNUNET_JSON_spec_json ("denomination_keys",
&keys),
GNUNET_JSON_spec_end()
};
auditor->auditor_url = NULL; /* #3987 */
if (GNUNET_OK !=
MAJ_parse_json (auditor_obj,
spec))
GNUNET_JSON_parse (auditor_obj,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
kv.purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_MINT_KEYS);
kv.purpose.size = htonl (sizeof (struct TALER_MintKeyValidityPS));
auditor->auditor_url = GNUNET_strdup (auditor_url);
kv.purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS);
kv.purpose.size = htonl (sizeof (struct TALER_ExchangeKeyValidityPS));
GNUNET_CRYPTO_hash (auditor_url,
strlen (auditor_url) + 1,
&kv.auditor_url_hash);
kv.master = key_data->master_pub;
len = json_array_size (keys);
auditor->denom_keys = GNUNET_new_array (len,
const struct TALER_MINT_DenomPublicKey *);
const struct TALER_EXCHANGE_DenomPublicKey *);
i = 0;
off = 0;
json_array_foreach (keys, i, key) {
struct TALER_AuditorSignatureP auditor_sig;
struct GNUNET_HashCode denom_h;
const struct TALER_MINT_DenomPublicKey *dk;
const struct TALER_EXCHANGE_DenomPublicKey *dk;
unsigned int j;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("denom_pub_h",
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("denom_pub_h",
&denom_h),
MAJ_spec_fixed_auto ("auditor_sig",
GNUNET_JSON_spec_fixed_auto ("auditor_sig",
&auditor_sig),
MAJ_spec_end
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (key,
spec))
GNUNET_JSON_parse (key,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
continue;
@ -436,7 +443,7 @@ parse_json_auditor (struct TALER_MINT_AuditorInformation *auditor,
&dk->fee_refresh);
kv.denom_hash = dk->h_key;
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_MINT_KEYS,
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS,
&kv.purpose,
&auditor_sig.eddsa_sig,
&auditor->auditor_pub.eddsa_pub))
@ -462,13 +469,13 @@ parse_json_auditor (struct TALER_MINT_AuditorInformation *auditor,
*/
static int
decode_keys_json (json_t *resp_obj,
struct TALER_MINT_Keys *key_data)
struct TALER_EXCHANGE_Keys *key_data)
{
struct GNUNET_TIME_Absolute list_issue_date;
struct TALER_MintSignatureP sig;
struct TALER_MintKeySetPS ks;
struct TALER_ExchangeSignatureP sig;
struct TALER_ExchangeKeySetPS ks;
struct GNUNET_HashContext *hash_context;
struct TALER_MintPublicKeyP pub;
struct TALER_ExchangePublicKeyP pub;
if (JSON_OBJECT != json_typeof (resp_obj))
return GNUNET_SYSERR;
@ -476,21 +483,22 @@ decode_keys_json (json_t *resp_obj,
hash_context = GNUNET_CRYPTO_hash_context_start ();
/* parse the master public key and issue date of the response */
{
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("master_public_key",
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("master_public_key",
&key_data->master_pub),
MAJ_spec_fixed_auto ("eddsa_sig",
GNUNET_JSON_spec_fixed_auto ("eddsa_sig",
&sig),
MAJ_spec_fixed_auto ("eddsa_pub",
GNUNET_JSON_spec_fixed_auto ("eddsa_pub",
&pub),
MAJ_spec_absolute_time ("list_issue_date",
GNUNET_JSON_spec_absolute_time ("list_issue_date",
&list_issue_date),
MAJ_spec_end
GNUNET_JSON_spec_end()
};
EXITIF (GNUNET_OK !=
MAJ_parse_json (resp_obj,
spec));
GNUNET_JSON_parse (resp_obj,
spec,
NULL, NULL));
}
/* parse the signing keys */
@ -507,7 +515,7 @@ decode_keys_json (json_t *resp_obj,
json_array_size (sign_keys_array)));
key_data->sign_keys
= GNUNET_new_array (key_data->num_sign_keys,
struct TALER_MINT_SigningPublicKey);
struct TALER_EXCHANGE_SigningPublicKey);
index = 0;
json_array_foreach (sign_keys_array, index, sign_key_obj) {
EXITIF (GNUNET_SYSERR ==
@ -528,7 +536,7 @@ decode_keys_json (json_t *resp_obj,
EXITIF (JSON_ARRAY != json_typeof (denom_keys_array));
EXITIF (0 == (key_data->num_denom_keys = json_array_size (denom_keys_array)));
key_data->denom_keys = GNUNET_new_array (key_data->num_denom_keys,
struct TALER_MINT_DenomPublicKey);
struct TALER_EXCHANGE_DenomPublicKey);
index = 0;
json_array_foreach (denom_keys_array, index, denom_key_obj) {
EXITIF (GNUNET_SYSERR ==
@ -553,7 +561,7 @@ decode_keys_json (json_t *resp_obj,
if (0 != len)
{
key_data->auditors = GNUNET_new_array (len,
struct TALER_MINT_AuditorInformation);
struct TALER_EXCHANGE_AuditorInformation);
index = 0;
json_array_foreach (auditors_array, index, auditor_info) {
EXITIF (GNUNET_SYSERR ==
@ -566,16 +574,16 @@ decode_keys_json (json_t *resp_obj,
/* Validate signature... */
ks.purpose.size = htonl (sizeof (ks));
ks.purpose.purpose = htonl (TALER_SIGNATURE_MINT_KEY_SET);
ks.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET);
ks.list_issue_date = GNUNET_TIME_absolute_hton (list_issue_date);
GNUNET_CRYPTO_hash_context_finish (hash_context,
&ks.hc);
hash_context = NULL;
EXITIF (GNUNET_OK !=
TALER_MINT_test_signing_key (key_data,
TALER_EXCHANGE_test_signing_key (key_data,
&pub));
EXITIF (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_KEY_SET,
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_KEY_SET,
&ks.purpose,
&sig.eddsa_signature,
&pub.eddsa_pub));
@ -600,10 +608,10 @@ keys_completed_cb (void *cls,
CURL *eh)
{
struct KeysRequest *kr = cls;
struct TALER_MINT_Handle *mint = kr->mint;
struct TALER_EXCHANGE_Handle *exchange = kr->exchange;
json_t *resp_obj;
long response_code;
TALER_MINT_CertificationCallback cb;
TALER_EXCHANGE_CertificationCallback cb;
resp_obj = MAC_download_get_result (&kr->db,
eh,
@ -619,7 +627,7 @@ keys_completed_cb (void *cls,
if ( (NULL == resp_obj) ||
(GNUNET_OK !=
decode_keys_json (resp_obj,
&kr->mint->key_data)) )
&kr->exchange->key_data)) )
response_code = 0;
break;
default:
@ -633,27 +641,27 @@ keys_completed_cb (void *cls,
if (MHD_HTTP_OK != response_code)
{
mint->kr = NULL;
exchange->kr = NULL;
free_keys_request (kr);
mint->state = MHS_FAILED;
exchange->state = MHS_FAILED;
/* notify application that we failed */
if (NULL != (cb = mint->cert_cb))
if (NULL != (cb = exchange->cert_cb))
{
mint->cert_cb = NULL;
cb (mint->cert_cb_cls,
exchange->cert_cb = NULL;
cb (exchange->cert_cb_cls,
NULL);
}
return;
}
mint->kr = NULL;
exchange->kr = NULL;
free_keys_request (kr);
mint->state = MHS_CERT;
exchange->state = MHS_CERT;
/* notify application about the key information */
if (NULL != (cb = mint->cert_cb))
if (NULL != (cb = exchange->cert_cb))
{
mint->cert_cb = NULL;
cb (mint->cert_cb_cls,
&mint->key_data);
exchange->cert_cb = NULL;
cb (exchange->cert_cb_cls,
&exchange->key_data);
}
}
@ -662,13 +670,13 @@ keys_completed_cb (void *cls,
/**
* Get the context of a mint.
* Get the context of a exchange.
*
* @param h the mint handle to query
* @param h the exchange handle to query
* @return ctx context to execute jobs in
*/
struct TALER_MINT_Context *
MAH_handle_to_context (struct TALER_MINT_Handle *h)
struct TALER_EXCHANGE_Context *
MAH_handle_to_context (struct TALER_EXCHANGE_Handle *h)
{
return h->ctx;
}
@ -677,11 +685,11 @@ MAH_handle_to_context (struct TALER_MINT_Handle *h)
/**
* Check if the handle is ready to process requests.
*
* @param h the mint handle to query
* @param h the exchange handle to query
* @return #GNUNET_YES if we are ready, #GNUNET_NO if not
*/
int
MAH_handle_is_ready (struct TALER_MINT_Handle *h)
MAH_handle_is_ready (struct TALER_EXCHANGE_Handle *h)
{
return (MHS_CERT == h->state) ? GNUNET_YES : GNUNET_NO;
}
@ -690,12 +698,12 @@ MAH_handle_is_ready (struct TALER_MINT_Handle *h)
/**
* Obtain the URL to use for an API request.
*
* @param h the mint handle to query
* @param h the exchange handle to query
* @param path Taler API path (i.e. "/reserve/withdraw")
* @return the full URI to use with cURL
*/
char *
MAH_path_to_url (struct TALER_MINT_Handle *h,
MAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
const char *path)
{
char *url;
@ -715,39 +723,39 @@ MAH_path_to_url (struct TALER_MINT_Handle *h,
/* ********************* public API ******************* */
/**
* Initialise a connection to the mint. Will connect to the
* mint and obtain information about the mint's master public
* key and the mint's auditor. The respective information will
* Initialise a connection to the exchange. Will connect to the
* exchange and obtain information about the exchange's master public
* key and the exchange's auditor. The respective information will
* be passed to the @a cert_cb once available, and all future
* interactions with the mint will be checked to be signed
* interactions with the exchange will be checked to be signed
* (where appropriate) by the respective master key.
*
* @param ctx the context
* @param url HTTP base URL for the mint
* @param cert_cb function to call with the mint's certification information
* @param url HTTP base URL for the exchange
* @param cert_cb function to call with the exchange's certification information
* @param cert_cb_cls closure for @a cert_cb
* @param ... list of additional arguments, terminated by #TALER_MINT_OPTION_END.
* @return the mint handle; NULL upon error
* @param ... list of additional arguments, terminated by #TALER_EXCHANGE_OPTION_END.
* @return the exchange handle; NULL upon error
*/
struct TALER_MINT_Handle *
TALER_MINT_connect (struct TALER_MINT_Context *ctx,
struct TALER_EXCHANGE_Handle *
TALER_EXCHANGE_connect (struct TALER_EXCHANGE_Context *ctx,
const char *url,
TALER_MINT_CertificationCallback cert_cb,
TALER_EXCHANGE_CertificationCallback cert_cb,
void *cert_cb_cls,
...)
{
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
struct KeysRequest *kr;
CURL *c;
mint = GNUNET_new (struct TALER_MINT_Handle);
mint->ctx = ctx;
mint->url = GNUNET_strdup (url);
mint->cert_cb = cert_cb;
mint->cert_cb_cls = cert_cb_cls;
exchange = GNUNET_new (struct TALER_EXCHANGE_Handle);
exchange->ctx = ctx;
exchange->url = GNUNET_strdup (url);
exchange->cert_cb = cert_cb;
exchange->cert_cb_cls = cert_cb_cls;
kr = GNUNET_new (struct KeysRequest);
kr->mint = mint;
kr->url = MAH_path_to_url (mint, "/keys");
kr->exchange = exchange;
kr->url = MAH_path_to_url (exchange, "/keys");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requesting keys with URL `%s'.\n",
kr->url);
@ -772,59 +780,59 @@ TALER_MINT_connect (struct TALER_MINT_Context *ctx,
curl_easy_setopt (c,
CURLOPT_WRITEDATA,
&kr->db));
kr->job = MAC_job_add (mint->ctx,
kr->job = MAC_job_add (exchange->ctx,
c,
GNUNET_NO,
&keys_completed_cb,
kr);
mint->kr = kr;
return mint;
exchange->kr = kr;
return exchange;
}
/**
* Disconnect from the mint
* Disconnect from the exchange
*
* @param mint the mint handle
* @param exchange the exchange handle
*/
void
TALER_MINT_disconnect (struct TALER_MINT_Handle *mint)
TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange)
{
unsigned int i;
if (NULL != mint->kr)
if (NULL != exchange->kr)
{
MAC_job_cancel (mint->kr->job);
free_keys_request (mint->kr);
mint->kr = NULL;
MAC_job_cancel (exchange->kr->job);
free_keys_request (exchange->kr);
exchange->kr = NULL;
}
GNUNET_array_grow (mint->key_data.sign_keys,
mint->key_data.num_sign_keys,
GNUNET_array_grow (exchange->key_data.sign_keys,
exchange->key_data.num_sign_keys,
0);
for (i=0;i<mint->key_data.num_denom_keys;i++)
GNUNET_CRYPTO_rsa_public_key_free (mint->key_data.denom_keys[i].key.rsa_public_key);
GNUNET_array_grow (mint->key_data.denom_keys,
mint->key_data.num_denom_keys,
for (i=0;i<exchange->key_data.num_denom_keys;i++)
GNUNET_CRYPTO_rsa_public_key_free (exchange->key_data.denom_keys[i].key.rsa_public_key);
GNUNET_array_grow (exchange->key_data.denom_keys,
exchange->key_data.num_denom_keys,
0);
GNUNET_array_grow (mint->key_data.auditors,
mint->key_data.num_auditors,
GNUNET_array_grow (exchange->key_data.auditors,
exchange->key_data.num_auditors,
0);
GNUNET_free (mint->url);
GNUNET_free (mint);
GNUNET_free (exchange->url);
GNUNET_free (exchange);
}
/**
* Test if the given @a pub is a the current signing key from the mint
* Test if the given @a pub is a the current signing key from the exchange
* according to @a keys.
*
* @param keys the mint's key set
* @param pub claimed current online signing key for the mint
* @param keys the exchange's key set
* @param pub claimed current online signing key for the exchange
* @return #GNUNET_OK if @a pub is (according to /keys) a current signing key
*/
int
TALER_MINT_test_signing_key (const struct TALER_MINT_Keys *keys,
const struct TALER_MintPublicKeyP *pub)
TALER_EXCHANGE_test_signing_key (const struct TALER_EXCHANGE_Keys *keys,
const struct TALER_ExchangePublicKeyP *pub)
{
struct GNUNET_TIME_Absolute now;
unsigned int i;
@ -836,22 +844,22 @@ TALER_MINT_test_signing_key (const struct TALER_MINT_Keys *keys,
(keys->sign_keys[i].valid_until.abs_value_us > now.abs_value_us - 60 * 60 * 1000LL * 1000LL) &&
(0 == memcmp (pub,
&keys->sign_keys[i].key,
sizeof (struct TALER_MintPublicKeyP))) )
sizeof (struct TALER_ExchangePublicKeyP))) )
return GNUNET_OK;
return GNUNET_SYSERR;
}
/**
* Obtain the denomination key details from the mint.
* Obtain the denomination key details from the exchange.
*
* @param keys the mint's key set
* @param keys the exchange's key set
* @param pk public key of the denomination to lookup
* @return details about the given denomination key, NULL if the key is
* not found
*/
const struct TALER_MINT_DenomPublicKey *
TALER_MINT_get_denomination_key (const struct TALER_MINT_Keys *keys,
const struct TALER_EXCHANGE_DenomPublicKey *
TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys,
const struct TALER_DenominationPublicKey *pk)
{
unsigned int i;
@ -865,14 +873,14 @@ TALER_MINT_get_denomination_key (const struct TALER_MINT_Keys *keys,
/**
* Obtain the denomination key details from the mint.
* Obtain the denomination key details from the exchange.
*
* @param keys the mint's key set
* @param keys the exchange's key set
* @param hc hash of the public key of the denomination to lookup
* @return details about the given denomination key
*/
const struct TALER_MINT_DenomPublicKey *
TALER_MINT_get_denomination_key_by_hash (const struct TALER_MINT_Keys *keys,
const struct TALER_EXCHANGE_DenomPublicKey *
TALER_EXCHANGE_get_denomination_key_by_hash (const struct TALER_EXCHANGE_Keys *keys,
const struct GNUNET_HashCode *hc)
{
unsigned int i;
@ -887,16 +895,16 @@ TALER_MINT_get_denomination_key_by_hash (const struct TALER_MINT_Keys *keys,
/**
* Obtain the keys from the mint.
* Obtain the keys from the exchange.
*
* @param mint the mint handle
* @return the mint's key set
* @param exchange the exchange handle
* @return the exchange's key set
*/
const struct TALER_MINT_Keys *
TALER_MINT_get_keys (const struct TALER_MINT_Handle *mint)
const struct TALER_EXCHANGE_Keys *
TALER_EXCHANGE_get_keys (const struct TALER_EXCHANGE_Handle *exchange)
{
return &mint->key_data;
return &exchange->key_data;
}
/* end of mint_api_handle.c */
/* end of exchange_api_handle.c */

View File

@ -15,45 +15,45 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_handle.h
* @brief Internal interface to the handle part of the mint's HTTP API
* @file exchange-lib/exchange_api_handle.h
* @brief Internal interface to the handle part of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
#include <curl/curl.h>
#include "taler_mint_service.h"
#include "taler_exchange_service.h"
/**
* Get the context of a mint.
* Get the context of a exchange.
*
* @param h the mint handle to query
* @param h the exchange handle to query
* @return ctx context to execute jobs in
*/
struct TALER_MINT_Context *
MAH_handle_to_context (struct TALER_MINT_Handle *h);
struct TALER_EXCHANGE_Context *
MAH_handle_to_context (struct TALER_EXCHANGE_Handle *h);
/**
* Check if the handle is ready to process requests.
*
* @param h the mint handle to query
* @param h the exchange handle to query
* @return #GNUNET_YES if we are ready, #GNUNET_NO if not
*/
int
MAH_handle_is_ready (struct TALER_MINT_Handle *h);
MAH_handle_is_ready (struct TALER_EXCHANGE_Handle *h);
/**
* Obtain the URL to use for an API request.
*
* @param h the mint handle to query
* @param h the exchange handle to query
* @param path Taler API path (i.e. "/reserve/withdraw")
* @return the full URI to use with cURL
*/
char *
MAH_path_to_url (struct TALER_MINT_Handle *h,
MAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
const char *path);
/* end of mint_api_handle.h */
/* end of exchange_api_handle.h */

View File

@ -15,8 +15,8 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_refresh.c
* @brief Implementation of the /refresh/melt+reveal requests of the mint's HTTP API
* @file exchange-lib/exchange_api_refresh.c
* @brief Implementation of the /refresh/melt+reveal requests of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
@ -24,11 +24,12 @@
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "mint_api_common.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include <gnunet/gnunet_json_lib.h>
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
#include "exchange_api_common.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
@ -145,7 +146,7 @@ struct MeltDataP
/* Followed by serializations of:
1) struct MeltedCoinP melted_coins[num_melted_coins];
2) struct TALER_MINT_DenomPublicKey fresh_pks[num_fresh_coins];
2) struct TALER_EXCHANGE_DenomPublicKey fresh_pks[num_fresh_coins];
3) TALER_CNC_KAPPA times:
3a) struct FreshCoinP fresh_coins[num_fresh_coins];
*/
@ -196,7 +197,7 @@ struct MeltedCoin
struct TALER_DenominationPublicKey pub_key;
/**
* Mint's signature over the coin.
* Exchange's signature over the coin.
*/
struct TALER_DenominationSignature sig;
@ -257,7 +258,7 @@ struct MeltData
/**
* Array of @e num_fresh_coins denomination keys for the coins to be
* freshly minted.
* freshly exchangeed.
*/
struct TALER_DenominationPublicKey *fresh_pks;
@ -794,7 +795,7 @@ deserialize_melt_data (const char *buf,
*/
static void
setup_fresh_coin (struct FreshCoin *fc,
const struct TALER_MINT_DenomPublicKey *pk)
const struct TALER_EXCHANGE_DenomPublicKey *pk)
{
struct GNUNET_CRYPTO_EddsaPrivateKey *epk;
unsigned int len;
@ -818,7 +819,7 @@ setup_fresh_coin (struct FreshCoin *fc,
* no money is lost in case of hardware failures, is operation does
* not actually initiate the request. Instead, it generates a buffer
* which the caller must store before proceeding with the actual call
* to #TALER_MINT_refresh_melt() that will generate the request.
* to #TALER_EXCHANGE_refresh_melt() that will generate the request.
*
* This function does verify that the given request data is internally
* consistent. However, the @a melts_sigs are only verified if
@ -845,20 +846,20 @@ setup_fresh_coin (struct FreshCoin *fc,
* @param fresh_pks array of @a pks_len denominations of fresh coins to create
* @param[out] res_size set to the size of the return value, or 0 on error
* @return NULL
* if the inputs are invalid (i.e. denomination key not with this mint).
* if the inputs are invalid (i.e. denomination key not with this exchange).
* Otherwise, pointer to a buffer of @a res_size to store persistently
* before proceeding to #TALER_MINT_refresh_melt().
* before proceeding to #TALER_EXCHANGE_refresh_melt().
* Non-null results should be freed using #GNUNET_free().
*/
char *
TALER_MINT_refresh_prepare (unsigned int num_melts,
TALER_EXCHANGE_refresh_prepare (unsigned int num_melts,
const struct TALER_CoinSpendPrivateKeyP *melt_privs,
const struct TALER_Amount *melt_amounts,
const struct TALER_DenominationSignature *melt_sigs,
const struct TALER_MINT_DenomPublicKey *melt_pks,
const struct TALER_EXCHANGE_DenomPublicKey *melt_pks,
int check_sigs,
unsigned int fresh_pks_len,
const struct TALER_MINT_DenomPublicKey *fresh_pks,
const struct TALER_EXCHANGE_DenomPublicKey *fresh_pks,
size_t *res_size)
{
struct MeltData md;
@ -1022,13 +1023,13 @@ TALER_MINT_refresh_prepare (unsigned int num_melts,
/**
* @brief A /refresh/melt Handle
*/
struct TALER_MINT_RefreshMeltHandle
struct TALER_EXCHANGE_RefreshMeltHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -1048,7 +1049,7 @@ struct TALER_MINT_RefreshMeltHandle
/**
* Function to call with refresh melt failure results.
*/
TALER_MINT_RefreshMeltCallback melt_cb;
TALER_EXCHANGE_RefreshMeltCallback melt_cb;
/**
* Closure for @e result_cb and @e melt_failure_cb.
@ -1069,42 +1070,43 @@ struct TALER_MINT_RefreshMeltHandle
/**
* Verify that the signature on the "200 OK" response
* from the mint is valid.
* from the exchange is valid.
*
* @param rmh melt handle
* @param json json reply with the signature
* @param[out] noreveal_index set to the noreveal index selected by the mint
* @param[out] noreveal_index set to the noreveal index selected by the exchange
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
*/
static int
verify_refresh_melt_signature_ok (struct TALER_MINT_RefreshMeltHandle *rmh,
verify_refresh_melt_signature_ok (struct TALER_EXCHANGE_RefreshMeltHandle *rmh,
json_t *json,
uint16_t *noreveal_index)
{
struct TALER_MintSignatureP mint_sig;
struct TALER_MintPublicKeyP mint_pub;
const struct TALER_MINT_Keys *key_state;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("mint_sig", &mint_sig),
MAJ_spec_fixed_auto ("mint_pub", &mint_pub),
MAJ_spec_uint16 ("noreveal_index", noreveal_index),
MAJ_spec_end
struct TALER_ExchangeSignatureP exchange_sig;
struct TALER_ExchangePublicKeyP exchange_pub;
const struct TALER_EXCHANGE_Keys *key_state;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
GNUNET_JSON_spec_uint16 ("noreveal_index", noreveal_index),
GNUNET_JSON_spec_end()
};
struct TALER_RefreshMeltConfirmationPS confirm;
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
/* check that mint signing key is permitted */
key_state = TALER_MINT_get_keys (rmh->mint);
/* check that exchange signing key is permitted */
key_state = TALER_EXCHANGE_get_keys (rmh->exchange);
if (GNUNET_OK !=
TALER_MINT_test_signing_key (key_state,
&mint_pub))
TALER_EXCHANGE_test_signing_key (key_state,
&exchange_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -1117,17 +1119,17 @@ verify_refresh_melt_signature_ok (struct TALER_MINT_RefreshMeltHandle *rmh,
return GNUNET_SYSERR;
}
/* verify signature by mint */
confirm.purpose.purpose = htonl (TALER_SIGNATURE_MINT_CONFIRM_MELT);
/* verify signature by exchange */
confirm.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT);
confirm.purpose.size = htonl (sizeof (struct TALER_RefreshMeltConfirmationPS));
confirm.session_hash = rmh->md->melt_session_hash;
confirm.noreveal_index = htons (*noreveal_index);
confirm.reserved = htons (0);
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_CONFIRM_MELT,
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT,
&confirm.purpose,
&mint_sig.eddsa_signature,
&mint_pub.eddsa_pub))
&exchange_sig.eddsa_signature,
&exchange_pub.eddsa_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -1138,14 +1140,14 @@ verify_refresh_melt_signature_ok (struct TALER_MINT_RefreshMeltHandle *rmh,
/**
* Verify that the signatures on the "403 FORBIDDEN" response from the
* mint demonstrating customer double-spending are valid.
* exchange demonstrating customer double-spending are valid.
*
* @param rmh melt handle
* @param json json reply with the signature(s) and transaction history
* @return #GNUNET_OK if the signature(s) is valid, #GNUNET_SYSERR if not
*/
static int
verify_refresh_melt_signature_forbidden (struct TALER_MINT_RefreshMeltHandle *rmh,
verify_refresh_melt_signature_forbidden (struct TALER_EXCHANGE_RefreshMeltHandle *rmh,
json_t *json)
{
json_t *history;
@ -1154,25 +1156,26 @@ verify_refresh_melt_signature_forbidden (struct TALER_MINT_RefreshMeltHandle *rm
struct TALER_Amount total;
struct TALER_CoinSpendPublicKeyP coin_pub;
unsigned int i;
struct MAJ_Specification spec[] = {
MAJ_spec_json ("history", &history),
MAJ_spec_fixed_auto ("coin_pub", &coin_pub),
MAJ_spec_amount ("original_value", &original_value),
MAJ_spec_amount ("requested_value", &melt_value_with_fee),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("history", &history),
GNUNET_JSON_spec_fixed_auto ("coin_pub", &coin_pub),
TALER_JSON_spec_amount ("original_value", &original_value),
TALER_JSON_spec_amount ("requested_value", &melt_value_with_fee),
GNUNET_JSON_spec_end()
};
const struct MeltedCoin *mc;
/* parse JSON reply */
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
/* Find out which coin was deemed problematic by the mint */
/* Find out which coin was deemed problematic by the exchange */
mc = NULL;
for (i=0;i<rmh->md->num_melted_coins;i++)
{
@ -1222,7 +1225,7 @@ verify_refresh_melt_signature_forbidden (struct TALER_MINT_RefreshMeltHandle *rm
history = json_object_get (json,
"history");
if (GNUNET_OK !=
TALER_MINT_verify_coin_history_ (original_value.currency,
TALER_EXCHANGE_verify_coin_history_ (original_value.currency,
&coin_pub,
history,
&total))
@ -1261,14 +1264,14 @@ verify_refresh_melt_signature_forbidden (struct TALER_MINT_RefreshMeltHandle *rm
* Function called when we're done processing the
* HTTP /refresh/melt request.
*
* @param cls the `struct TALER_MINT_RefreshMeltHandle`
* @param cls the `struct TALER_EXCHANGE_RefreshMeltHandle`
* @param eh the curl request handle
*/
static void
handle_refresh_melt_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_RefreshMeltHandle *rmh = cls;
struct TALER_EXCHANGE_RefreshMeltHandle *rmh = cls;
long response_code;
json_t *json;
uint16_t noreveal_index = TALER_CNC_KAPPA; /* invalid value */
@ -1300,7 +1303,7 @@ handle_refresh_melt_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_FORBIDDEN:
@ -1314,7 +1317,7 @@ handle_refresh_melt_finished (void *cls,
}
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, mint says one of the signatures is
/* Nothing really to verify, exchange says one of the signatures is
invalid; assuming we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
@ -1341,7 +1344,7 @@ handle_refresh_melt_finished (void *cls,
UINT16_MAX,
json);
json_decref (json);
TALER_MINT_refresh_melt_cancel (rmh);
TALER_EXCHANGE_refresh_melt_cancel (rmh);
}
@ -1373,45 +1376,45 @@ melted_coin_to_json (const struct GNUNET_HashCode *melt_session_hash,
&confirm_sig.eddsa_signature);
return json_pack ("{s:o, s:o, s:o, s:o, s:o}",
"coin_pub",
TALER_json_from_data (&melt.coin_pub,
GNUNET_JSON_from_data (&melt.coin_pub,
sizeof (melt.coin_pub)),
"denom_pub",
TALER_json_from_rsa_public_key (mc->pub_key.rsa_public_key),
GNUNET_JSON_from_rsa_public_key (mc->pub_key.rsa_public_key),
"denom_sig",
TALER_json_from_rsa_signature (mc->sig.rsa_signature),
GNUNET_JSON_from_rsa_signature (mc->sig.rsa_signature),
"confirm_sig",
TALER_json_from_data (&confirm_sig,
GNUNET_JSON_from_data (&confirm_sig,
sizeof (confirm_sig)),
"value_with_fee",
TALER_json_from_amount (&mc->melt_amount_with_fee));
TALER_JSON_from_amount (&mc->melt_amount_with_fee));
}
/**
* Submit a melt request to the mint and get the mint's
* Submit a melt request to the exchange and get the exchange's
* response.
*
* This API is typically used by a wallet. Note that to ensure that
* no money is lost in case of hardware failures, the provided
* argument should have been constructed using
* #TALER_MINT_refresh_prepare and committed to persistent storage
* #TALER_EXCHANGE_refresh_prepare and committed to persistent storage
* prior to calling this function.
*
* @param mint the mint handle; the mint must be ready to operate
* @param exchange the exchange handle; the exchange must be ready to operate
* @param refresh_data_length size of the @a refresh_data (returned
* in the `res_size` argument from #TALER_MINT_refresh_prepare())
* in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare())
* @param refresh_data the refresh data as returned from
#TALER_MINT_refresh_prepare())
#TALER_EXCHANGE_refresh_prepare())
* @param melt_cb the callback to call with the result
* @param melt_cb_cls closure for @a melt_cb
* @return a handle for this request; NULL if the argument was invalid.
* In this case, neither callback will be called.
*/
struct TALER_MINT_RefreshMeltHandle *
TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
struct TALER_EXCHANGE_RefreshMeltHandle *
TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
size_t refresh_data_length,
const char *refresh_data,
TALER_MINT_RefreshMeltCallback melt_cb,
TALER_EXCHANGE_RefreshMeltCallback melt_cb,
void *melt_cb_cls)
{
json_t *melt_obj;
@ -1422,15 +1425,15 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
json_t *secret_encs;
json_t *link_encs;
json_t *tmp;
struct TALER_MINT_RefreshMeltHandle *rmh;
struct TALER_EXCHANGE_RefreshMeltHandle *rmh;
CURL *eh;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_Context *ctx;
struct MeltData *md;
unsigned int i;
unsigned int j;
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
@ -1472,7 +1475,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
GNUNET_CRYPTO_ecdhe_key_get_public (&mc->transfer_priv[j].ecdhe_priv,
&transfer_pub.ecdhe_pub);
json_array_append (tmp,
TALER_json_from_data (&transfer_pub,
GNUNET_JSON_from_data (&transfer_pub,
sizeof (transfer_pub)));
}
json_array_append (transfer_pubs,
@ -1497,7 +1500,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
&trans_sec,
&els));
json_array_append (tmp,
TALER_json_from_data (&els,
GNUNET_JSON_from_data (&els,
sizeof (els)));
}
json_array_append (secret_encs,
@ -1508,7 +1511,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
for (i=0;i<md->num_fresh_coins;i++)
{
json_array_append (new_denoms,
TALER_json_from_rsa_public_key
GNUNET_JSON_from_rsa_public_key
(md->fresh_pks[i].rsa_public_key));
}
@ -1533,7 +1536,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
&buf_len);
GNUNET_assert (NULL != buf);
json_array_append (tmp,
TALER_json_from_data (buf,
GNUNET_JSON_from_data (buf,
buf_len));
GNUNET_free (buf);
GNUNET_free (rle);
@ -1564,7 +1567,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
md->fresh_pks[i].rsa_public_key,
&coin_ev);
json_array_append (tmp,
TALER_json_from_data (coin_ev,
GNUNET_JSON_from_data (coin_ev,
coin_ev_size));
GNUNET_free (coin_ev);
}
@ -1582,12 +1585,12 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
"link_encs", link_encs);
/* and now we can at last begin the actual request handling */
rmh = GNUNET_new (struct TALER_MINT_RefreshMeltHandle);
rmh->mint = mint;
rmh = GNUNET_new (struct TALER_EXCHANGE_RefreshMeltHandle);
rmh->exchange = exchange;
rmh->melt_cb = melt_cb;
rmh->melt_cb_cls = melt_cb_cls;
rmh->md = md;
rmh->url = MAH_path_to_url (mint,
rmh->url = MAH_path_to_url (exchange,
"/refresh/melt");
eh = curl_easy_init ();
@ -1615,7 +1618,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&rmh->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
rmh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -1632,7 +1635,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint,
* @param rmh the refresh melt handle
*/
void
TALER_MINT_refresh_melt_cancel (struct TALER_MINT_RefreshMeltHandle *rmh)
TALER_EXCHANGE_refresh_melt_cancel (struct TALER_EXCHANGE_RefreshMeltHandle *rmh)
{
if (NULL != rmh->job)
{
@ -1654,13 +1657,13 @@ TALER_MINT_refresh_melt_cancel (struct TALER_MINT_RefreshMeltHandle *rmh)
/**
* @brief A /refresh/reveal Handle
*/
struct TALER_MINT_RefreshRevealHandle
struct TALER_EXCHANGE_RefreshRevealHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -1680,7 +1683,7 @@ struct TALER_MINT_RefreshRevealHandle
/**
* Function to call with the result.
*/
TALER_MINT_RefreshRevealCallback reveal_cb;
TALER_EXCHANGE_RefreshRevealCallback reveal_cb;
/**
* Closure for @e reveal_cb.
@ -1698,7 +1701,7 @@ struct TALER_MINT_RefreshRevealHandle
struct MeltData *md;
/**
* The index selected by the mint in cut-and-choose to not be revealed.
* The index selected by the exchange in cut-and-choose to not be revealed.
*/
uint16_t noreveal_index;
@ -1708,7 +1711,7 @@ struct TALER_MINT_RefreshRevealHandle
/**
* We got a 200 OK response for the /refresh/reveal operation.
* Extract the coin signatures and return them to the caller.
* The signatures we get from the mint is for the blinded value.
* The signatures we get from the exchange is for the blinded value.
* Thus, we first must unblind them and then should verify their
* validity.
*
@ -1716,27 +1719,28 @@ struct TALER_MINT_RefreshRevealHandle
* to the application via the callback.
*
* @param rrh operation handle
* @param json reply from the mint
* @param json reply from the exchange
* @param[out] coin_privs array of length `num_fresh_coins`, initialized to contain private keys
* @param[out] sigs array of length `num_fresh_coins`, initialized to cointain RSA signatures
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
*/
static int
refresh_reveal_ok (struct TALER_MINT_RefreshRevealHandle *rrh,
refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh,
json_t *json,
struct TALER_CoinSpendPrivateKeyP *coin_privs,
struct TALER_DenominationSignature *sigs)
{
unsigned int i;
json_t *jsona;
struct MAJ_Specification spec[] = {
MAJ_spec_json ("ev_sigs", &jsona),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("ev_sigs", &jsona),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -1758,14 +1762,14 @@ refresh_reveal_ok (struct TALER_MINT_RefreshRevealHandle *rrh,
const struct FreshCoin *fc;
struct TALER_DenominationPublicKey *pk;
json_t *jsonai;
struct GNUNET_CRYPTO_rsa_Signature *blind_sig;
struct GNUNET_CRYPTO_rsa_Signature *sig;
struct GNUNET_CRYPTO_RsaSignature *blind_sig;
struct GNUNET_CRYPTO_RsaSignature *sig;
struct TALER_CoinSpendPublicKeyP coin_pub;
struct GNUNET_HashCode coin_hash;
struct MAJ_Specification spec[] = {
MAJ_spec_rsa_signature ("ev_sig", &blind_sig),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_rsa_signature ("ev_sig", &blind_sig),
GNUNET_JSON_spec_end()
};
fc = &rrh->md->fresh_coins[rrh->noreveal_index][i];
@ -1774,8 +1778,9 @@ refresh_reveal_ok (struct TALER_MINT_RefreshRevealHandle *rrh,
GNUNET_assert (NULL != jsonai);
if (GNUNET_OK !=
MAJ_parse_json (jsonai,
spec))
GNUNET_JSON_parse (jsonai,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -1814,14 +1819,14 @@ refresh_reveal_ok (struct TALER_MINT_RefreshRevealHandle *rrh,
* Function called when we're done processing the
* HTTP /refresh/reveal request.
*
* @param cls the `struct TALER_MINT_RefreshHandle`
* @param cls the `struct TALER_EXCHANGE_RefreshHandle`
* @param eh the curl request handle
*/
static void
handle_refresh_reveal_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_RefreshRevealHandle *rrh = cls;
struct TALER_EXCHANGE_RefreshRevealHandle *rrh = cls;
long response_code;
json_t *json;
@ -1865,11 +1870,11 @@ handle_refresh_reveal_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_CONFLICT:
/* Nothing really to verify, mint says our reveal is inconsitent
/* Nothing really to verify, exchange says our reveal is inconsitent
with our commitment, so either side is buggy; we
should pass the JSON reply to the application */
break;
@ -1892,12 +1897,12 @@ handle_refresh_reveal_finished (void *cls,
0, NULL, NULL,
json);
json_decref (json);
TALER_MINT_refresh_reveal_cancel (rrh);
TALER_EXCHANGE_refresh_reveal_cancel (rrh);
}
/**
* Submit a /refresh/reval request to the mint and get the mint's
* Submit a /refresh/reval request to the exchange and get the exchange's
* response.
*
* This API is typically used by a wallet. Note that to ensure that
@ -1905,39 +1910,39 @@ handle_refresh_reveal_finished (void *cls,
* arguments should have been committed to persistent storage
* prior to calling this function.
*
* @param mint the mint handle; the mint must be ready to operate
* @param exchange the exchange handle; the exchange must be ready to operate
* @param refresh_data_length size of the @a refresh_data (returned
* in the `res_size` argument from #TALER_MINT_refresh_prepare())
* in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare())
* @param refresh_data the refresh data as returned from
#TALER_MINT_refresh_prepare())
* @param noreveal_index response from the mint to the
* #TALER_MINT_refresh_melt() invocation
#TALER_EXCHANGE_refresh_prepare())
* @param noreveal_index response from the exchange to the
* #TALER_EXCHANGE_refresh_melt() invocation
* @param reveal_cb the callback to call with the final result of the
* refresh operation
* @param reveal_cb_cls closure for the above callback
* @return a handle for this request; NULL if the argument was invalid.
* In this case, neither callback will be called.
*/
struct TALER_MINT_RefreshRevealHandle *
TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint,
struct TALER_EXCHANGE_RefreshRevealHandle *
TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange,
size_t refresh_data_length,
const char *refresh_data,
uint16_t noreveal_index,
TALER_MINT_RefreshRevealCallback reveal_cb,
TALER_EXCHANGE_RefreshRevealCallback reveal_cb,
void *reveal_cb_cls)
{
struct TALER_MINT_RefreshRevealHandle *rrh;
struct TALER_EXCHANGE_RefreshRevealHandle *rrh;
json_t *transfer_privs;
json_t *reveal_obj;
json_t *tmp;
CURL *eh;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_Context *ctx;
struct MeltData *md;
unsigned int i;
unsigned int j;
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
@ -1953,7 +1958,7 @@ TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint,
{
/* We check this here, as it would be really bad to below just
disclose all the transfer keys. Note that this error should
have been caught way earlier when the mint replied, but maybe
have been caught way earlier when the exchange replied, but maybe
we had some internal corruption that changed the value... */
GNUNET_break (0);
return NULL;
@ -1975,7 +1980,7 @@ TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint,
const struct MeltedCoin *mc = &md->melted_coins[i];
json_array_append (tmp,
TALER_json_from_data (&mc->transfer_priv[j],
GNUNET_JSON_from_data (&mc->transfer_priv[j],
sizeof (struct TALER_TransferPrivateKeyP)));
}
json_array_append (transfer_privs,
@ -1985,19 +1990,19 @@ TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint,
/* build main JSON request */
reveal_obj = json_pack ("{s:o, s:o}",
"session_hash",
TALER_json_from_data (&md->melt_session_hash,
GNUNET_JSON_from_data (&md->melt_session_hash,
sizeof (struct GNUNET_HashCode)),
"transfer_privs",
transfer_privs);
/* finally, we can actually issue the request */
rrh = GNUNET_new (struct TALER_MINT_RefreshRevealHandle);
rrh->mint = mint;
rrh = GNUNET_new (struct TALER_EXCHANGE_RefreshRevealHandle);
rrh->exchange = exchange;
rrh->noreveal_index = noreveal_index;
rrh->reveal_cb = reveal_cb;
rrh->reveal_cb_cls = reveal_cb_cls;
rrh->md = md;
rrh->url = MAH_path_to_url (rrh->mint,
rrh->url = MAH_path_to_url (rrh->exchange,
"/refresh/reveal");
eh = curl_easy_init ();
@ -2025,7 +2030,7 @@ TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&rrh->db));
ctx = MAH_handle_to_context (rrh->mint);
ctx = MAH_handle_to_context (rrh->exchange);
rrh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -2042,7 +2047,7 @@ TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint,
* @param rrh the refresh reval handle
*/
void
TALER_MINT_refresh_reveal_cancel (struct TALER_MINT_RefreshRevealHandle *rrh)
TALER_EXCHANGE_refresh_reveal_cancel (struct TALER_EXCHANGE_RefreshRevealHandle *rrh)
{
if (NULL != rrh->job)
{
@ -2058,4 +2063,4 @@ TALER_MINT_refresh_reveal_cancel (struct TALER_MINT_RefreshRevealHandle *rrh)
}
/* end of mint_api_refresh.c */
/* end of exchange_api_refresh.c */

View File

@ -15,32 +15,31 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_refresh_link.c
* @brief Implementation of the /refresh/link request of the mint's HTTP API
* @file exchange-lib/exchange_api_refresh_link.c
* @brief Implementation of the /refresh/link request of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
#include <curl/curl.h>
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include "taler_exchange_service.h"
#include "taler_json_lib.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
/**
* @brief A /refresh/link Handle
*/
struct TALER_MINT_RefreshLinkHandle
struct TALER_EXCHANGE_RefreshLinkHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -55,7 +54,7 @@ struct TALER_MINT_RefreshLinkHandle
/**
* Function to call with the result.
*/
TALER_MINT_RefreshLinkCallback link_cb;
TALER_EXCHANGE_RefreshLinkCallback link_cb;
/**
* Closure for @e cb.
@ -89,7 +88,7 @@ struct TALER_MINT_RefreshLinkHandle
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
parse_refresh_link_coin (const struct TALER_EXCHANGE_RefreshLinkHandle *rlh,
json_t *json,
const struct TALER_TransferPublicKeyP *trans_pub,
const struct TALER_EncryptedLinkSecretP *secret_enc,
@ -99,13 +98,13 @@ parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
{
void *link_enc;
size_t link_enc_size;
struct GNUNET_CRYPTO_rsa_Signature *bsig;
struct GNUNET_CRYPTO_rsa_PublicKey *rpub;
struct MAJ_Specification spec[] = {
MAJ_spec_varsize ("link_enc", &link_enc, &link_enc_size),
MAJ_spec_rsa_public_key ("denom_pub", &rpub),
MAJ_spec_rsa_signature ("ev_sig", &bsig),
MAJ_spec_end
struct GNUNET_CRYPTO_RsaSignature *bsig;
struct GNUNET_CRYPTO_RsaPublicKey *rpub;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_varsize ("link_enc", &link_enc, &link_enc_size),
GNUNET_JSON_spec_rsa_public_key ("denom_pub", &rpub),
GNUNET_JSON_spec_rsa_signature ("ev_sig", &bsig),
GNUNET_JSON_spec_end()
};
struct TALER_RefreshLinkEncrypted *rle;
struct TALER_RefreshLinkDecrypted *rld;
@ -113,8 +112,9 @@ parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
/* parse reply */
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -126,7 +126,7 @@ parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
if (NULL == rle)
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -136,7 +136,7 @@ parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
&secret))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
rld = TALER_refresh_decrypt (rle,
@ -144,7 +144,7 @@ parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
if (NULL == rld)
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
@ -158,7 +158,7 @@ parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
/* clean up */
GNUNET_free (rld);
pub->rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (rpub);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}
@ -172,7 +172,7 @@ parse_refresh_link_coin (const struct TALER_MINT_RefreshLinkHandle *rlh,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh,
parse_refresh_link_ok (struct TALER_EXCHANGE_RefreshLinkHandle *rlh,
json_t *json)
{
unsigned int session;
@ -199,15 +199,16 @@ parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh,
for (session=0;session<json_array_size (json); session++)
{
json_t *jsona;
struct MAJ_Specification spec[] = {
MAJ_spec_json ("new_coins", &jsona),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("new_coins", &jsona),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json_array_get (json,
session),
spec))
GNUNET_JSON_parse (json_array_get (json,
session),
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -215,13 +216,13 @@ parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh,
if (! json_is_array (jsona))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
/* count all coins over all sessions */
num_coins += json_array_size (jsona);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
}
/* Now that we know how big the 1d array is, allocate
and fill it. */
@ -240,17 +241,18 @@ parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh,
json_t *jsona;
struct TALER_TransferPublicKeyP trans_pub;
struct TALER_EncryptedLinkSecretP secret_enc;
struct MAJ_Specification spec[] = {
MAJ_spec_json ("new_coins", &jsona),
MAJ_spec_fixed_auto ("transfer_pub", &trans_pub),
MAJ_spec_fixed_auto ("secret_enc", &secret_enc),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("new_coins", &jsona),
GNUNET_JSON_spec_fixed_auto ("transfer_pub", &trans_pub),
GNUNET_JSON_spec_fixed_auto ("secret_enc", &secret_enc),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json_array_get (json,
session),
spec))
GNUNET_JSON_parse (json_array_get (json,
session),
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -258,7 +260,7 @@ parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh,
if (! json_is_array (jsona))
{
GNUNET_break_op (0);
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
@ -285,10 +287,10 @@ parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh,
{
GNUNET_break_op (0);
ret = GNUNET_SYSERR;
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
break;
}
MAJ_parse_free (spec);
GNUNET_JSON_parse_free (spec);
} /* end of for (session) */
if (off_coin == num_coins)
@ -326,14 +328,14 @@ parse_refresh_link_ok (struct TALER_MINT_RefreshLinkHandle *rlh,
* Function called when we're done processing the
* HTTP /refresh/link request.
*
* @param cls the `struct TALER_MINT_RefreshLinkHandle`
* @param cls the `struct TALER_EXCHANGE_RefreshLinkHandle`
* @param eh the curl request handle
*/
static void
handle_refresh_link_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_RefreshLinkHandle *rlh = cls;
struct TALER_EXCHANGE_RefreshLinkHandle *rlh = cls;
long response_code;
json_t *json;
@ -355,11 +357,11 @@ handle_refresh_link_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, mint says this coin was not melted; we
/* Nothing really to verify, exchange says this coin was not melted; we
should pass the JSON reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
@ -381,39 +383,39 @@ handle_refresh_link_finished (void *cls,
0, NULL, NULL, NULL,
json);
json_decref (json);
TALER_MINT_refresh_link_cancel (rlh);
TALER_EXCHANGE_refresh_link_cancel (rlh);
}
/**
* Submit a link request to the mint and get the mint's response.
* Submit a link request to the exchange and get the exchange's response.
*
* This API is typically not used by anyone, it is more a threat
* against those trying to receive a funds transfer by abusing the
* /refresh protocol.
*
* @param mint the mint handle; the mint must be ready to operate
* @param exchange the exchange handle; the exchange must be ready to operate
* @param coin_priv private key to request link data for
* @param link_cb the callback to call with the useful result of the
* refresh operation the @a coin_priv was involved in (if any)
* @param link_cb_cls closure for @a link_cb
* @return a handle for this request
*/
struct TALER_MINT_RefreshLinkHandle *
TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint,
struct TALER_EXCHANGE_RefreshLinkHandle *
TALER_EXCHANGE_refresh_link (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
TALER_MINT_RefreshLinkCallback link_cb,
TALER_EXCHANGE_RefreshLinkCallback link_cb,
void *link_cb_cls)
{
struct TALER_MINT_RefreshLinkHandle *rlh;
struct TALER_EXCHANGE_RefreshLinkHandle *rlh;
CURL *eh;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_Context *ctx;
struct TALER_CoinSpendPublicKeyP coin_pub;
char *pub_str;
char *arg_str;
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
@ -428,12 +430,12 @@ TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint,
pub_str);
GNUNET_free (pub_str);
rlh = GNUNET_new (struct TALER_MINT_RefreshLinkHandle);
rlh->mint = mint;
rlh = GNUNET_new (struct TALER_EXCHANGE_RefreshLinkHandle);
rlh->exchange = exchange;
rlh->link_cb = link_cb;
rlh->link_cb_cls = link_cb_cls;
rlh->coin_priv = *coin_priv;
rlh->url = MAH_path_to_url (mint, arg_str);
rlh->url = MAH_path_to_url (exchange, arg_str);
GNUNET_free (arg_str);
eh = curl_easy_init ();
@ -449,7 +451,7 @@ TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&rlh->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
rlh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -466,7 +468,7 @@ TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint,
* @param rlh the refresh link handle
*/
void
TALER_MINT_refresh_link_cancel (struct TALER_MINT_RefreshLinkHandle *rlh)
TALER_EXCHANGE_refresh_link_cancel (struct TALER_EXCHANGE_RefreshLinkHandle *rlh)
{
if (NULL != rlh->job)
{
@ -479,4 +481,4 @@ TALER_MINT_refresh_link_cancel (struct TALER_MINT_RefreshLinkHandle *rlh)
}
/* end of mint_api_refresh_link.c */
/* end of exchange_api_refresh_link.c */

View File

@ -15,8 +15,8 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_reserve.c
* @brief Implementation of the /reserve requests of the mint's HTTP API
* @file exchange-lib/exchange_api_reserve.c
* @brief Implementation of the /reserve requests of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
@ -24,10 +24,11 @@
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include <gnunet/gnunet_json_lib.h>
#include "taler_exchange_service.h"
#include "taler_json_lib.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
@ -36,13 +37,13 @@
/**
* @brief A Withdraw Status Handle
*/
struct TALER_MINT_ReserveStatusHandle
struct TALER_EXCHANGE_ReserveStatusHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -57,7 +58,7 @@ struct TALER_MINT_ReserveStatusHandle
/**
* Function to call with the result.
*/
TALER_MINT_ReserveStatusResultCallback cb;
TALER_EXCHANGE_ReserveStatusResultCallback cb;
/**
* Public key of the reserve we are querying.
@ -98,7 +99,7 @@ parse_reserve_history (json_t *history,
const char *currency,
struct TALER_Amount *balance,
unsigned int history_length,
struct TALER_MINT_ReserveHistory *rhistory)
struct TALER_EXCHANGE_ReserveHistory *rhistory)
{
struct GNUNET_HashCode uuid[history_length];
unsigned int uuid_off;
@ -116,19 +117,20 @@ parse_reserve_history (json_t *history,
json_t *transaction;
struct TALER_Amount amount;
const char *type;
struct MAJ_Specification hist_spec[] = {
MAJ_spec_string ("type", &type),
MAJ_spec_amount ("amount",
struct GNUNET_JSON_Specification hist_spec[] = {
GNUNET_JSON_spec_string ("type", &type),
TALER_JSON_spec_amount ("amount",
&amount),
/* 'wire' and 'signature' are optional depending on 'type'! */
MAJ_spec_end
GNUNET_JSON_spec_end()
};
transaction = json_array_get (history,
off);
if (GNUNET_OK !=
MAJ_parse_json (transaction,
hist_spec))
GNUNET_JSON_parse (transaction,
hist_spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -140,13 +142,13 @@ parse_reserve_history (json_t *history,
{
json_t *wire;
rhistory[off].type = TALER_MINT_RTT_DEPOSIT;
rhistory[off].type = TALER_EXCHANGE_RTT_DEPOSIT;
if (GNUNET_OK !=
TALER_amount_add (&total_in,
&total_in,
&amount))
{
/* overflow in history already!? inconceivable! Bad mint! */
/* overflow in history already!? inconceivable! Bad exchange! */
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
@ -170,19 +172,20 @@ parse_reserve_history (json_t *history,
struct TALER_ReserveSignatureP sig;
struct TALER_WithdrawRequestPS withdraw_purpose;
struct TALER_Amount amount_from_purpose;
struct MAJ_Specification withdraw_spec[] = {
MAJ_spec_fixed_auto ("signature",
struct GNUNET_JSON_Specification withdraw_spec[] = {
GNUNET_JSON_spec_fixed_auto ("signature",
&sig),
MAJ_spec_fixed_auto ("details",
GNUNET_JSON_spec_fixed_auto ("details",
&withdraw_purpose),
MAJ_spec_end
GNUNET_JSON_spec_end()
};
unsigned int i;
rhistory[off].type = TALER_MINT_RTT_WITHDRAWAL;
rhistory[off].type = TALER_EXCHANGE_RTT_WITHDRAWAL;
if (GNUNET_OK !=
MAJ_parse_json (transaction,
withdraw_spec))
GNUNET_JSON_parse (transaction,
withdraw_spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -195,7 +198,7 @@ parse_reserve_history (json_t *history,
&reserve_pub->eddsa_pub))
{
GNUNET_break_op (0);
MAJ_parse_free (withdraw_spec);
GNUNET_JSON_parse_free (withdraw_spec);
return GNUNET_SYSERR;
}
TALER_amount_ntoh (&amount_from_purpose,
@ -204,13 +207,13 @@ parse_reserve_history (json_t *history,
&amount_from_purpose))
{
GNUNET_break_op (0);
MAJ_parse_free (withdraw_spec);
GNUNET_JSON_parse_free (withdraw_spec);
return GNUNET_SYSERR;
}
rhistory[off].details.out_authorization_sig = json_object_get (transaction,
"signature");
/* Check check that the same withdraw transaction
isn't listed twice by the mint. We use the
isn't listed twice by the exchange. We use the
"uuid" array to remember the hashes of all
purposes, and compare the hashes to find
duplicates. */
@ -224,7 +227,7 @@ parse_reserve_history (json_t *history,
sizeof (struct GNUNET_HashCode)))
{
GNUNET_break_op (0);
MAJ_parse_free (withdraw_spec);
GNUNET_JSON_parse_free (withdraw_spec);
return GNUNET_SYSERR;
}
}
@ -235,9 +238,9 @@ parse_reserve_history (json_t *history,
&total_out,
&amount))
{
/* overflow in history already!? inconceivable! Bad mint! */
/* overflow in history already!? inconceivable! Bad exchange! */
GNUNET_break_op (0);
MAJ_parse_free (withdraw_spec);
GNUNET_JSON_parse_free (withdraw_spec);
return GNUNET_SYSERR;
}
/* end type==WITHDRAW */
@ -256,7 +259,7 @@ parse_reserve_history (json_t *history,
&total_in,
&total_out))
{
/* total_in < total_out, why did the mint ever allow this!? */
/* total_in < total_out, why did the exchange ever allow this!? */
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
@ -269,14 +272,14 @@ parse_reserve_history (json_t *history,
* Function called when we're done processing the
* HTTP /reserve/status request.
*
* @param cls the `struct TALER_MINT_ReserveStatusHandle`
* @param cls the `struct TALER_EXCHANGE_ReserveStatusHandle`
* @param eh curl handle of the request that finished
*/
static void
handle_reserve_status_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_ReserveStatusHandle *wsh = cls;
struct TALER_EXCHANGE_ReserveStatusHandle *wsh = cls;
long response_code;
json_t *json;
@ -295,14 +298,15 @@ handle_reserve_status_finished (void *cls,
unsigned int len;
struct TALER_Amount balance;
struct TALER_Amount balance_from_history;
struct MAJ_Specification spec[] = {
MAJ_spec_amount ("balance", &balance),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("balance", &balance),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
response_code = 0;
@ -318,7 +322,7 @@ handle_reserve_status_finished (void *cls,
}
len = json_array_size (history);
{
struct TALER_MINT_ReserveHistory rhistory[len];
struct TALER_EXCHANGE_ReserveHistory rhistory[len];
if (GNUNET_OK !=
parse_reserve_history (history,
@ -336,7 +340,7 @@ handle_reserve_status_finished (void *cls,
TALER_amount_cmp (&balance_from_history,
&balance))
{
/* mint cannot add up balances!? */
/* exchange cannot add up balances!? */
GNUNET_break_op (0);
response_code = 0;
break;
@ -352,7 +356,7 @@ handle_reserve_status_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
@ -379,40 +383,40 @@ handle_reserve_status_finished (void *cls,
NULL,
0, NULL);
json_decref (json);
TALER_MINT_reserve_status_cancel (wsh);
TALER_EXCHANGE_reserve_status_cancel (wsh);
}
/**
* Submit a request to obtain the transaction history of a reserve
* from the mint. Note that while we return the full response to the
* from the exchange. Note that while we return the full response to the
* caller for further processing, we do already verify that the
* response is well-formed (i.e. that signatures included in the
* response are all valid and add up to the balance). If the mint's
* response are all valid and add up to the balance). If the exchange's
* reply is not well-formed, we return an HTTP status code of zero to
* @a cb.
*
* @param mint the mint handle; the mint must be ready to operate
* @param exchange the exchange handle; the exchange must be ready to operate
* @param reserve_pub public key of the reserve to inspect
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
* signatures fail to verify). In this case, the callback is not called.
*/
struct TALER_MINT_ReserveStatusHandle *
TALER_MINT_reserve_status (struct TALER_MINT_Handle *mint,
struct TALER_EXCHANGE_ReserveStatusHandle *
TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_ReservePublicKeyP *reserve_pub,
TALER_MINT_ReserveStatusResultCallback cb,
TALER_EXCHANGE_ReserveStatusResultCallback cb,
void *cb_cls)
{
struct TALER_MINT_ReserveStatusHandle *wsh;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_ReserveStatusHandle *wsh;
struct TALER_EXCHANGE_Context *ctx;
CURL *eh;
char *pub_str;
char *arg_str;
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
@ -423,12 +427,12 @@ TALER_MINT_reserve_status (struct TALER_MINT_Handle *mint,
"/reserve/status?reserve_pub=%s",
pub_str);
GNUNET_free (pub_str);
wsh = GNUNET_new (struct TALER_MINT_ReserveStatusHandle);
wsh->mint = mint;
wsh = GNUNET_new (struct TALER_EXCHANGE_ReserveStatusHandle);
wsh->exchange = exchange;
wsh->cb = cb;
wsh->cb_cls = cb_cls;
wsh->reserve_pub = *reserve_pub;
wsh->url = MAH_path_to_url (mint,
wsh->url = MAH_path_to_url (exchange,
arg_str);
GNUNET_free (arg_str);
@ -445,7 +449,7 @@ TALER_MINT_reserve_status (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&wsh->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
wsh->job = MAC_job_add (ctx,
eh,
GNUNET_NO,
@ -462,7 +466,7 @@ TALER_MINT_reserve_status (struct TALER_MINT_Handle *mint,
* @param wsh the withdraw status request handle
*/
void
TALER_MINT_reserve_status_cancel (struct TALER_MINT_ReserveStatusHandle *wsh)
TALER_EXCHANGE_reserve_status_cancel (struct TALER_EXCHANGE_ReserveStatusHandle *wsh)
{
if (NULL != wsh->job)
{
@ -480,13 +484,13 @@ TALER_MINT_reserve_status_cancel (struct TALER_MINT_ReserveStatusHandle *wsh)
/**
* @brief A Withdraw Sign Handle
*/
struct TALER_MINT_ReserveWithdrawHandle
struct TALER_EXCHANGE_ReserveWithdrawHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -506,7 +510,7 @@ struct TALER_MINT_ReserveWithdrawHandle
/**
* Function to call with the result.
*/
TALER_MINT_ReserveWithdrawResultCallback cb;
TALER_EXCHANGE_ReserveWithdrawResultCallback cb;
/**
* Key used to blind the value.
@ -516,7 +520,7 @@ struct TALER_MINT_ReserveWithdrawHandle
/**
* Denomination key we are withdrawing.
*/
const struct TALER_MINT_DenomPublicKey *pk;
const struct TALER_EXCHANGE_DenomPublicKey *pk;
/**
* Closure for @a cb.
@ -544,7 +548,7 @@ struct TALER_MINT_ReserveWithdrawHandle
/**
* We got a 200 OK response for the /reserve/withdraw operation.
* Extract the coin's signature and return it to the caller.
* The signature we get from the mint is for the blinded value.
* The signature we get from the exchange is for the blinded value.
* Thus, we first must unblind it and then should verify its
* validity against our coin's hash.
*
@ -552,24 +556,25 @@ struct TALER_MINT_ReserveWithdrawHandle
* to the application via the callback.
*
* @param wsh operation handle
* @param json reply from the mint
* @param json reply from the exchange
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
*/
static int
reserve_withdraw_ok (struct TALER_MINT_ReserveWithdrawHandle *wsh,
reserve_withdraw_ok (struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh,
json_t *json)
{
struct GNUNET_CRYPTO_rsa_Signature *blind_sig;
struct GNUNET_CRYPTO_rsa_Signature *sig;
struct GNUNET_CRYPTO_RsaSignature *blind_sig;
struct GNUNET_CRYPTO_RsaSignature *sig;
struct TALER_DenominationSignature dsig;
struct MAJ_Specification spec[] = {
MAJ_spec_rsa_signature ("ev_sig", &blind_sig),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_rsa_signature ("ev_sig", &blind_sig),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -605,15 +610,15 @@ reserve_withdraw_ok (struct TALER_MINT_ReserveWithdrawHandle *wsh,
* Check the signatures on the withdraw transactions in the provided
* history and that the balances add up. We don't do anything directly
* with the information, as the JSON will be returned to the application.
* However, our job is ensuring that the mint followed the protocol, and
* However, our job is ensuring that the exchange followed the protocol, and
* this in particular means checking all of the signatures in the history.
*
* @param wsh operation handle
* @param json reply from the mint
* @param json reply from the exchange
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
*/
static int
reserve_withdraw_payment_required (struct TALER_MINT_ReserveWithdrawHandle *wsh,
reserve_withdraw_payment_required (struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh,
json_t *json)
{
struct TALER_Amount balance;
@ -621,14 +626,15 @@ reserve_withdraw_payment_required (struct TALER_MINT_ReserveWithdrawHandle *wsh,
struct TALER_Amount requested_amount;
json_t *history;
size_t len;
struct MAJ_Specification spec[] = {
MAJ_spec_amount ("balance", &balance),
MAJ_spec_end
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("balance", &balance),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@ -645,7 +651,7 @@ reserve_withdraw_payment_required (struct TALER_MINT_ReserveWithdrawHandle *wsh,
total incoming and outgoing amounts */
len = json_array_size (history);
{
struct TALER_MINT_ReserveHistory rhistory[len];
struct TALER_EXCHANGE_ReserveHistory rhistory[len];
if (GNUNET_OK !=
parse_reserve_history (history,
@ -664,7 +670,7 @@ reserve_withdraw_payment_required (struct TALER_MINT_ReserveWithdrawHandle *wsh,
TALER_amount_cmp (&balance_from_history,
&balance))
{
/* mint cannot add up balances!? */
/* exchange cannot add up balances!? */
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
@ -695,14 +701,14 @@ reserve_withdraw_payment_required (struct TALER_MINT_ReserveWithdrawHandle *wsh,
* Function called when we're done processing the
* HTTP /reserve/withdraw request.
*
* @param cls the `struct TALER_MINT_ReserveWithdrawHandle`
* @param cls the `struct TALER_EXCHANGE_ReserveWithdrawHandle`
* @param eh curl handle of the request that finished
*/
static void
handle_reserve_withdraw_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_ReserveWithdrawHandle *wsh = cls;
struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh = cls;
long response_code;
json_t *json;
@ -724,11 +730,11 @@ handle_reserve_withdraw_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_PAYMENT_REQUIRED:
/* The mint says that the reserve has insufficient funds;
/* The exchange says that the reserve has insufficient funds;
check the signatures in the history... */
if (GNUNET_OK !=
reserve_withdraw_payment_required (wsh,
@ -740,12 +746,12 @@ handle_reserve_withdraw_finished (void *cls,
break;
case MHD_HTTP_UNAUTHORIZED:
GNUNET_break (0);
/* Nothing really to verify, mint says one of the signatures is
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, the mint basically just says
/* Nothing really to verify, the exchange basically just says
that it doesn't know this reserve. Can happen if we
query before the wire transfer went through.
We should simply pass the JSON reply to the application. */
@ -769,18 +775,18 @@ handle_reserve_withdraw_finished (void *cls,
NULL,
json);
json_decref (json);
TALER_MINT_reserve_withdraw_cancel (wsh);
TALER_EXCHANGE_reserve_withdraw_cancel (wsh);
}
/**
* Withdraw a coin from the mint using a /reserve/withdraw request. Note
* Withdraw a coin from the exchange using a /reserve/withdraw request. Note
* that to ensure that no money is lost in case of hardware failures,
* the caller must have committed (most of) the arguments to disk
* before calling, and be ready to repeat the request with the same
* arguments in case of failures.
*
* @param mint the mint handle; the mint must be ready to operate
* @param exchange the exchange handle; the exchange must be ready to operate
* @param pk kind of coin to create
* @param reserve_priv private key of the reserve to withdraw from
* @param coin_priv where to store the coin's private key,
@ -790,31 +796,31 @@ handle_reserve_withdraw_finished (void *cls,
* @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback
* @return #GNUNET_OK on success, #GNUNET_SYSERR
* if the inputs are invalid (i.e. denomination key not with this mint).
* if the inputs are invalid (i.e. denomination key not with this exchange).
* In this case, the callback is not called.
*/
struct TALER_MINT_ReserveWithdrawHandle *
TALER_MINT_reserve_withdraw (struct TALER_MINT_Handle *mint,
const struct TALER_MINT_DenomPublicKey *pk,
struct TALER_EXCHANGE_ReserveWithdrawHandle *
TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_EXCHANGE_DenomPublicKey *pk,
const struct TALER_ReservePrivateKeyP *reserve_priv,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
const struct TALER_DenominationBlindingKey *blinding_key,
TALER_MINT_ReserveWithdrawResultCallback res_cb,
TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb,
void *res_cb_cls)
{
struct TALER_MINT_ReserveWithdrawHandle *wsh;
struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh;
struct TALER_WithdrawRequestPS req;
struct TALER_ReserveSignatureP reserve_sig;
struct TALER_CoinSpendPublicKeyP coin_pub;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_Context *ctx;
struct TALER_Amount amount_with_fee;
char *coin_ev;
size_t coin_ev_size;
json_t *withdraw_obj;
CURL *eh;
wsh = GNUNET_new (struct TALER_MINT_ReserveWithdrawHandle);
wsh->mint = mint;
wsh = GNUNET_new (struct TALER_EXCHANGE_ReserveWithdrawHandle);
wsh->exchange = exchange;
wsh->cb = res_cb;
wsh->cb_cls = res_cb_cls;
wsh->pk = pk;
@ -838,7 +844,7 @@ TALER_MINT_reserve_withdraw (struct TALER_MINT_Handle *mint,
&pk->fee_withdraw,
&pk->value))
{
/* mint gave us denomination keys that overflow like this!? */
/* exchange gave us denomination keys that overflow like this!? */
GNUNET_break_op (0);
GNUNET_free (coin_ev);
GNUNET_free (wsh);
@ -859,17 +865,17 @@ TALER_MINT_reserve_withdraw (struct TALER_MINT_Handle *mint,
&reserve_sig.eddsa_signature));
withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub and coin_ev */
" s:o, s:o}",/* reserve_pub and reserve_sig */
"denom_pub", TALER_json_from_rsa_public_key (pk->key.rsa_public_key),
"coin_ev", TALER_json_from_data (coin_ev,
"denom_pub", GNUNET_JSON_from_rsa_public_key (pk->key.rsa_public_key),
"coin_ev", GNUNET_JSON_from_data (coin_ev,
coin_ev_size),
"reserve_pub", TALER_json_from_data (&wsh->reserve_pub,
"reserve_pub", GNUNET_JSON_from_data (&wsh->reserve_pub,
sizeof (struct TALER_ReservePublicKeyP)),
"reserve_sig", TALER_json_from_data (&reserve_sig,
"reserve_sig", GNUNET_JSON_from_data (&reserve_sig,
sizeof (reserve_sig)));
GNUNET_free (coin_ev);
wsh->blinding_key = blinding_key;
wsh->url = MAH_path_to_url (mint, "/reserve/withdraw");
wsh->url = MAH_path_to_url (exchange, "/reserve/withdraw");
eh = curl_easy_init ();
GNUNET_assert (NULL != (wsh->json_enc =
@ -896,7 +902,7 @@ TALER_MINT_reserve_withdraw (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&wsh->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
wsh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -913,7 +919,7 @@ TALER_MINT_reserve_withdraw (struct TALER_MINT_Handle *mint,
* @param sign the withdraw sign request handle
*/
void
TALER_MINT_reserve_withdraw_cancel (struct TALER_MINT_ReserveWithdrawHandle *sign)
TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHandle *sign)
{
if (NULL != sign->job)
{
@ -927,4 +933,4 @@ TALER_MINT_reserve_withdraw_cancel (struct TALER_MINT_ReserveWithdrawHandle *sig
}
/* end of mint_api_reserve.c */
/* end of exchange_api_reserve.c */

View File

@ -0,0 +1,318 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015, 2016 Inria and GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
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, If not, see
<http://www.gnu.org/licenses/>
*/
/**
* @file exchange-lib/exchange_api_wire.c
* @brief Implementation of the /wire request of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
#include <curl/curl.h>
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_exchange_service.h"
#include "taler_json_lib.h"
#include "taler_wire_plugin.h"
#include "exchange_api_common.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
/**
* @brief A Wire Handle
*/
struct TALER_EXCHANGE_WireHandle
{
/**
* The connection to exchange this request handle will use
*/
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
*/
char *url;
/**
* Handle for the request.
*/
struct MAC_Job *job;
/**
* Function to call with the result.
*/
TALER_EXCHANGE_WireResultCallback cb;
/**
* Closure for @a cb.
*/
void *cb_cls;
/**
* Download buffer
*/
struct MAC_DownloadBuffer db;
/**
* Set to the "methods" JSON array returned by the
* /wire request.
*/
json_t *methods;
/**
* Current iteration offset in the @e methods array.
*/
unsigned int methods_off;
};
/**
* Verify that the signature on the "200 OK" response
* for /wire/METHOD from the exchange is valid.
*
* @param wh wire handle with key material
* @param method method to verify the reply for
* @param json json reply with the signature
* @return #GNUNET_SYSERR if @a json is invalid,
* #GNUNET_NO if the method is unknown,
* #GNUNET_OK if the json is valid
*/
static int
verify_wire_method_signature_ok (const struct TALER_EXCHANGE_WireHandle *wh,
const char *method,
json_t *json)
{
const struct TALER_EXCHANGE_Keys *key_state;
struct TALER_WIRE_Plugin *plugin;
char *lib_name;
int ret;
key_state = TALER_EXCHANGE_get_keys (wh->exchange);
(void) GNUNET_asprintf (&lib_name,
"libtaler_plugin_wire_%s",
method);
plugin = GNUNET_PLUGIN_load (lib_name,
NULL);
if (NULL == plugin)
{
GNUNET_free (lib_name);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Wire transfer method `%s' not supported\n",
method);
return GNUNET_NO;
}
plugin->library_name = lib_name;
ret = plugin->wire_validate (plugin->cls,
json,
&key_state->master_pub);
GNUNET_PLUGIN_unload (lib_name,
plugin);
GNUNET_free (lib_name);
return (GNUNET_YES == ret) ? GNUNET_OK : GNUNET_SYSERR;
}
/**
* Function called when we're done processing the
* HTTP /wire request.
*
* @param cls the `struct TALER_EXCHANGE_WireHandle`
* @param eh the curl request handle
*/
static void
handle_wire_finished (void *cls,
CURL *eh)
{
struct TALER_EXCHANGE_WireHandle *wh = cls;
long response_code;
json_t *json;
wh->job = NULL;
json = MAC_download_get_result (&wh->db,
eh,
&response_code);
switch (response_code)
{
case 0:
break;
case MHD_HTTP_OK:
{
const char *key;
json_t *method;
json_t *keep;
int ret;
/* We 'keep' methods that we support and that are well-formed;
we fail (by setting response_code=0) if any method that we do
support fails to verify. */
keep = json_object ();
json_object_foreach (json, key, method) {
ret = verify_wire_method_signature_ok (wh,
key,
method);
if (GNUNET_SYSERR == ret)
{
/* bogus reply */
GNUNET_break_op (0);
response_code = 0;
}
/* GNUNET_NO: not understood by us, simply skip! */
if (GNUNET_OK == ret)
{
/* supported and valid, keep! */
json_object_set (keep,
key,
method);
}
}
if (0 != response_code)
{
/* all supported methods were valid, use 'keep' for 'json' */
json_decref (json);
json = keep;
break;
}
else
{
/* some supported methods were invalid, release 'keep', preserve
full 'json' for application-level error handling. */
json_decref (keep);
}
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
break;
default:
/* unexpected response code */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u\n",
response_code);
GNUNET_break (0);
response_code = 0;
break;
}
wh->cb (wh->cb_cls,
response_code,
json);
if (NULL != json)
json_decref (json);
TALER_EXCHANGE_wire_cancel (wh);
}
/**
* Obtain information about a exchange's wire instructions.
* A exchange may provide wire instructions for creating
* a reserve. The wire instructions also indicate
* which wire formats merchants may use with the exchange.
* This API is typically used by a wallet for wiring
* funds, and possibly by a merchant to determine
* supported wire formats.
*
* Note that while we return the (main) response verbatim to the
* caller for further processing, we do already verify that the
* response is well-formed (i.e. that signatures included in the
* response are all valid). If the exchange's reply is not well-formed,
* we return an HTTP status code of zero to @a cb.
*
* @param exchange the exchange handle; the exchange must be ready to operate
* @param wire_cb the callback to call when a reply for this request is available
* @param wire_cb_cls closure for the above callback
* @return a handle for this request
*/
struct TALER_EXCHANGE_WireHandle *
TALER_EXCHANGE_wire (struct TALER_EXCHANGE_Handle *exchange,
TALER_EXCHANGE_WireResultCallback wire_cb,
void *wire_cb_cls)
{
struct TALER_EXCHANGE_WireHandle *wh;
struct TALER_EXCHANGE_Context *ctx;
CURL *eh;
if (GNUNET_YES !=
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
}
wh = GNUNET_new (struct TALER_EXCHANGE_WireHandle);
wh->exchange = exchange;
wh->cb = wire_cb;
wh->cb_cls = wire_cb_cls;
wh->url = MAH_path_to_url (exchange, "/wire");
eh = curl_easy_init ();
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_URL,
wh->url));
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_WRITEFUNCTION,
&MAC_download_cb));
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&wh->db));
ctx = MAH_handle_to_context (exchange);
wh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
&handle_wire_finished,
wh);
return wh;
}
/**
* Cancel a wire information request. This function cannot be used
* on a request handle if a response is already served for it.
*
* @param wh the wire information request handle
*/
void
TALER_EXCHANGE_wire_cancel (struct TALER_EXCHANGE_WireHandle *wh)
{
if (NULL != wh->job)
{
MAC_job_cancel (wh->job);
wh->job = NULL;
}
if (NULL != wh->methods)
{
json_decref (wh->methods);
wh->methods = NULL;
}
GNUNET_free_non_null (wh->db.buf);
GNUNET_free (wh->url);
GNUNET_free (wh);
}
/* end of exchange_api_wire.c */

View File

@ -15,8 +15,8 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file mint-lib/mint_api_wire_deposits.c
* @brief Implementation of the /wire/deposits request of the mint's HTTP API
* @file exchange-lib/exchange_api_wire_deposits.c
* @brief Implementation of the /wire/deposits request of the exchange's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
@ -24,24 +24,24 @@
#include <jansson.h>
#include <microhttpd.h> /* just for HTTP status codes */
#include <gnunet/gnunet_util_lib.h>
#include "taler_mint_service.h"
#include "mint_api_common.h"
#include "mint_api_json.h"
#include "mint_api_context.h"
#include "mint_api_handle.h"
#include "taler_exchange_service.h"
#include "exchange_api_common.h"
#include "taler_json_lib.h"
#include "exchange_api_context.h"
#include "exchange_api_handle.h"
#include "taler_signatures.h"
/**
* @brief A /wire/deposits Handle
*/
struct TALER_MINT_WireDepositsHandle
struct TALER_EXCHANGE_WireDepositsHandle
{
/**
* The connection to mint this request handle will use
* The connection to exchange this request handle will use
*/
struct TALER_MINT_Handle *mint;
struct TALER_EXCHANGE_Handle *exchange;
/**
* The url for this request.
@ -56,7 +56,7 @@ struct TALER_MINT_WireDepositsHandle
/**
* Function to call with the result.
*/
TALER_MINT_WireDepositsCallback cb;
TALER_EXCHANGE_WireDepositsCallback cb;
/**
* Closure for @a cb.
@ -75,14 +75,14 @@ struct TALER_MINT_WireDepositsHandle
* Function called when we're done processing the
* HTTP /wire/deposits request.
*
* @param cls the `struct TALER_MINT_WireDepositsHandle`
* @param cls the `struct TALER_EXCHANGE_WireDepositsHandle`
* @param eh the curl request handle
*/
static void
handle_wire_deposits_finished (void *cls,
CURL *eh)
{
struct TALER_MINT_WireDepositsHandle *wdh = cls;
struct TALER_EXCHANGE_WireDepositsHandle *wdh = cls;
long response_code;
json_t *json;
@ -101,17 +101,22 @@ handle_wire_deposits_finished (void *cls,
struct TALER_Amount total_amount;
struct TALER_MerchantPublicKeyP merchant_pub;
unsigned int num_details;
struct MAJ_Specification spec[] = {
MAJ_spec_fixed_auto ("H_wire", &h_wire),
MAJ_spec_fixed_auto ("merchant_pub", &merchant_pub),
MAJ_spec_amount ("total_amount", &total_amount),
MAJ_spec_json ("details", &details_j),
MAJ_spec_end
struct TALER_ExchangePublicKeyP exchange_pub;
struct TALER_ExchangeSignatureP exchange_sig;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("H_wire", &h_wire),
GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig),
GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub),
TALER_JSON_spec_amount ("total_amount", &total_amount),
GNUNET_JSON_spec_json ("details", &details_j),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (json,
spec))
GNUNET_JSON_parse (json,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
response_code = 0;
@ -121,28 +126,69 @@ handle_wire_deposits_finished (void *cls,
{
struct TALER_WireDepositDetails details[num_details];
unsigned int i;
struct GNUNET_HashContext *hash_context;
struct TALER_WireDepositDetailP dd;
struct TALER_WireDepositDataPS wdp;
hash_context = GNUNET_CRYPTO_hash_context_start ();
for (i=0;i<num_details;i++)
{
struct TALER_WireDepositDetails *detail = &details[i];
struct json_t *detail_j = json_array_get (details_j, i);
struct MAJ_Specification spec_detail[] = {
MAJ_spec_fixed_auto ("H_contract", &detail->h_contract),
MAJ_spec_amount ("deposit_value", &detail->coin_value),
MAJ_spec_amount ("deposit_fee", &detail->coin_fee),
MAJ_spec_uint64 ("transaction_id", &detail->transaction_id),
MAJ_spec_fixed_auto ("coin_pub", &detail->coin_pub),
MAJ_spec_end
struct GNUNET_JSON_Specification spec_detail[] = {
GNUNET_JSON_spec_fixed_auto ("H_contract", &detail->h_contract),
TALER_JSON_spec_amount ("deposit_value", &detail->coin_value),
TALER_JSON_spec_amount ("deposit_fee", &detail->coin_fee),
GNUNET_JSON_spec_uint64 ("transaction_id", &detail->transaction_id),
GNUNET_JSON_spec_fixed_auto ("coin_pub", &detail->coin_pub),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
MAJ_parse_json (detail_j,
spec_detail))
GNUNET_JSON_parse (detail_j,
spec_detail,
NULL, NULL))
{
GNUNET_break_op (0);
response_code = 0;
break;
}
/* build up big hash for signature checking later */
dd.h_contract = detail->h_contract;
dd.transaction_id = GNUNET_htonll (detail->transaction_id);
dd.coin_pub = detail->coin_pub;
TALER_amount_hton (&dd.deposit_value,
&detail->coin_value);
TALER_amount_hton (&dd.deposit_fee,
&detail->coin_fee);
GNUNET_CRYPTO_hash_context_read (hash_context,
&dd,
sizeof (struct TALER_WireDepositDetailP));
}
/* Check signature */
wdp.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT);
wdp.purpose.size = htonl (sizeof (struct TALER_WireDepositDataPS));
TALER_amount_hton (&wdp.total,
&total_amount);
wdp.merchant_pub = merchant_pub;
wdp.h_wire = h_wire;
GNUNET_CRYPTO_hash_context_finish (hash_context,
&wdp.h_details);
if ( (0 == response_code /* avoid crypto if things are already wrong */) &&
(GNUNET_OK !=
TALER_EXCHANGE_test_signing_key (TALER_EXCHANGE_get_keys (wdh->exchange),
&exchange_pub)) )
{
GNUNET_break_op (0);
response_code = 0;
}
if ( (0 == response_code /* avoid crypto if things are already wrong */) &&
(GNUNET_OK !=
TALER_EXCHANGE_test_signing_key (TALER_EXCHANGE_get_keys (wdh->exchange),
&exchange_pub)) )
{
GNUNET_break_op (0);
response_code = 0;
}
if (0 == response_code)
break;
@ -154,22 +200,22 @@ handle_wire_deposits_finished (void *cls,
num_details,
details);
json_decref (json);
TALER_MINT_wire_deposits_cancel (wdh);
TALER_EXCHANGE_wire_deposits_cancel (wdh);
return;
}
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the mint is buggy
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, mint says one of the signatures is
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
/* Mint does not know about transaction;
/* Exchange does not know about transaction;
we should pass the reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
@ -190,41 +236,41 @@ handle_wire_deposits_finished (void *cls,
json,
NULL, NULL, 0, NULL);
json_decref (json);
TALER_MINT_wire_deposits_cancel (wdh);
TALER_EXCHANGE_wire_deposits_cancel (wdh);
}
/**
* Query the mint about which transactions were combined
* Query the exchange about which transactions were combined
* to create a wire transfer.
*
* @param mint mint to query
* @param exchange exchange to query
* @param wtid raw wire transfer identifier to get information about
* @param cb callback to call
* @param cb_cls closure for @a cb
* @return handle to cancel operation
*/
struct TALER_MINT_WireDepositsHandle *
TALER_MINT_wire_deposits (struct TALER_MINT_Handle *mint,
const struct TALER_WireTransferIdentifierRawP *wtid,
TALER_MINT_WireDepositsCallback cb,
void *cb_cls)
struct TALER_EXCHANGE_WireDepositsHandle *
TALER_EXCHANGE_wire_deposits (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_WireTransferIdentifierRawP *wtid,
TALER_EXCHANGE_WireDepositsCallback cb,
void *cb_cls)
{
struct TALER_MINT_WireDepositsHandle *wdh;
struct TALER_MINT_Context *ctx;
struct TALER_EXCHANGE_WireDepositsHandle *wdh;
struct TALER_EXCHANGE_Context *ctx;
char *buf;
char *path;
CURL *eh;
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
MAH_handle_is_ready (exchange))
{
GNUNET_break (0);
return NULL;
}
wdh = GNUNET_new (struct TALER_MINT_WireDepositsHandle);
wdh->mint = mint;
wdh = GNUNET_new (struct TALER_EXCHANGE_WireDepositsHandle);
wdh->exchange = exchange;
wdh->cb = cb;
wdh->cb_cls = cb_cls;
@ -233,7 +279,7 @@ TALER_MINT_wire_deposits (struct TALER_MINT_Handle *mint,
GNUNET_asprintf (&path,
"/wire/deposits?wtid=%s",
buf);
wdh->url = MAH_path_to_url (wdh->mint,
wdh->url = MAH_path_to_url (wdh->exchange,
path);
GNUNET_free (buf);
GNUNET_free (path);
@ -251,7 +297,7 @@ TALER_MINT_wire_deposits (struct TALER_MINT_Handle *mint,
curl_easy_setopt (eh,
CURLOPT_WRITEDATA,
&wdh->db));
ctx = MAH_handle_to_context (mint);
ctx = MAH_handle_to_context (exchange);
wdh->job = MAC_job_add (ctx,
eh,
GNUNET_YES,
@ -268,7 +314,7 @@ TALER_MINT_wire_deposits (struct TALER_MINT_Handle *mint,
* @param wdh the wire deposits request handle
*/
void
TALER_MINT_wire_deposits_cancel (struct TALER_MINT_WireDepositsHandle *wdh)
TALER_EXCHANGE_wire_deposits_cancel (struct TALER_EXCHANGE_WireDepositsHandle *wdh)
{
if (NULL != wdh->job)
{
@ -281,4 +327,4 @@ TALER_MINT_wire_deposits_cancel (struct TALER_MINT_WireDepositsHandle *wdh)
}
/* end of mint_api_wire_deposits.c */
/* end of exchange_api_wire_deposits.c */

View File

@ -0,0 +1,95 @@
# This file is in the public domain.
#
[PATHS]
# Persistant data storage for the testcase
TALER_TEST_HOME = test_exchange_api_home/
[exchange]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
# Wire format supported by the exchange
# We use 'test' for testing of the actual
# coin operations, and 'sepa' to test SEPA-specific routines.
WIREFORMAT = test sepa
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Is this is a testcase, use transient DB actions?
TESTRUN = YES
[exchangedb-postgres]
DB_CONN_STR = "postgres:///talercheck"
[wire-incoming-test]
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/test.json
[wire-outgoing-test]
# What is the main website of the bank?
BANK_URI = "http://localhost:8082/"
# Into which account at the 'bank' should (incoming) wire transfers be made?
BANK_ACCOUNT_NUMBER = 2
[coin_eur_ct_1]
value = EUR:0.01
duration_overlap = 5 minutes
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
rsa_keysize = 1024
[coin_eur_ct_10]
value = EUR:0.10
duration_overlap = 5 minutes
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
rsa_keysize = 1024
[coin_eur_1]
value = EUR:1
duration_overlap = 5 minutes
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
rsa_keysize = 1024
[coin_eur_5]
value = EUR:5
duration_overlap = 5 minutes
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
rsa_keysize = 1024
[coin_eur_10]
value = EUR:10
duration_overlap = 5 minutes
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
rsa_keysize = 1024

View File

@ -0,0 +1,9 @@
{
"name": "Max Musterman",
"bic": "COBADEFF370",
"type": "sepa",
"sig": "4EVRC2MCJPXQC8MC00831DNWEXMZAP4JQDDE1A7R6KR3MANG24RC1VQ55AX5A2E35S58VW1VSTENFTPHG5MWG9BSN8B8WXSV21KKW20",
"address": "Musterstadt",
"salt": "3KTM1ZRMWGEQPQ254S4R5R4Q8XM0ZYWTCTE01TZ76MVBSQ6RX7A5DR08WXVH1DCHR1R7ACRB7X0EVC2XDW1CBZM9WFSD9TRMZ90BR98",
"iban": "DE89370400440532013000"
}

View File

@ -0,0 +1,8 @@
{
"salt": "AZPRFVJ58NM6M7J5CZQPJAH3EW5DYM52AEZ9Y1C1ER3W94QV8D8TQKF6CK8MYQRA9QMSKDQTGZ306ZS9GQ0M6R01CJ20KPP49WFDZK8",
"name": "The exchange",
"account_number": 3,
"bank_uri": "http://localhost:8082/",
"type": "test",
"sig": "RPQXP9S4P8PQP7HEZQNRSZCT0ATNEP8GW0P5TPM34V5RX86FCD670V44R9NETSYDDKB8SZV7TKY9PAJYTY51D3VDWY9XXQ5BPFRXR28"
}

View File

@ -0,0 +1,96 @@
# This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include
pkgcfgdir = $(prefix)/share/taler/config.d/
pkgcfg_DATA = \
auditor.conf \
exchange-signkeys.conf \
coins.conf
if USE_COVERAGE
AM_CFLAGS = --coverage -O0
XLIB = -lgcov
endif
bin_PROGRAMS = \
taler-auditor-sign \
taler-exchange-keyup \
taler-exchange-keycheck \
taler-exchange-reservemod \
taler-exchange-wire \
taler-exchange-dbinit
taler_exchange_keyup_SOURCES = \
taler-exchange-keyup.c
taler_exchange_keyup_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
-lgnunetutil $(XLIB)
taler_exchange_keyup_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_auditor_sign_SOURCES = \
taler-auditor-sign.c
taler_auditor_sign_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
-lgnunetutil $(XLIB)
taler_exchange_wire_SOURCES = \
taler-exchange-wire.c
taler_exchange_wire_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/wire/libtalerwire.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetjson \
-lgnunetutil \
-ljansson $(XLIB)
taler_exchange_wire_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_exchange_keycheck_SOURCES = \
taler-exchange-keycheck.c
taler_exchange_keycheck_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
-lgnunetutil $(XLIB)
taler_exchange_keycheck_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_exchange_reservemod_SOURCES = \
taler-exchange-reservemod.c
taler_exchange_reservemod_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
-lgnunetutil -ljansson $(XLIB)
taler_exchange_reservemod_LDFLAGS = \
$(POSTGRESQL_LDFLAGS)
taler_exchange_reservemod_CPPFLAGS = \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/pq/ \
$(POSTGRESQL_CPPFLAGS)
taler_exchange_dbinit_SOURCES = \
taler-exchange-dbinit.c
taler_exchange_dbinit_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
-lgnunetutil $(XLIB)
taler_exchange_dbinit_LDFLAGS = \
$(POSTGRESQL_LDFLAGS)
taler_exchange_dbinit_CPPFLAGS = \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/pq/ \
$(POSTGRESQL_CPPFLAGS)
EXTRA_DIST = \
auditor.conf

View File

@ -0,0 +1,12 @@
# This configuration file is in the public domain
#
# It cointains options for the auditor.
[auditor]
# Where do we store the auditor's private key?
AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
# What is the Web site of the auditor (i.e. to file complaints about
# a misbehaving exchange)?
# AUDITOR_URL = https://auditor.taler.net/

View File

@ -0,0 +1,25 @@
# This configuration file is in the public domain
#
# This is a template file for coin definitions. There are no
# reasonable defaults, as legal and business concerns influence each
# value given.
#
# Note that while we only give one section here, you can define
# any number of coins by providing many "coin_" sections.
#
# Coin definitions are detected because the section name begins with
# "coin_". The rest of the name is free, but of course following the
# convention of "coin_$CURRENCY[_$SUBUNIT]_$VALUE" make sense.
#
# [coin_eur_ct_1]
# All options are mandatory!
# value = EUR:0.01
# duration_overlap = 60 minutes
# duration_withdraw = 7 days
# duration_spend = 2 years
# duration_legal = 3 years
# fee_withdraw = EUR:0.00
# fee_deposit = EUR:0.00
# fee_refresh = EUR:0.01
# rsa_keysize = 1024

View File

@ -0,0 +1,16 @@
# General data for signing keys.
[exchange_keys]
# how long is one signkey valid?
signkey_duration = 4 weeks
# how long are the signatures with the signkey valid?
legal_duration = 2 years
# how long do we generate denomination and signing keys
# ahead of time?
lookahead_sign = 32 weeks 1 day
# how long do we provide to clients denomination and signing keys
# ahead of time?
lookahead_provide = 4 weeks 1 day

View File

@ -15,12 +15,12 @@
*/
/**
* @file taler-auditor-sign.c
* @brief Tool used by the auditor to sign the mint's master key and the
* @brief Tool used by the auditor to sign the exchange's master key and the
* denomination key(s).
* @author Christian Grothoff
*/
#include <platform.h>
#include "taler_mintdb_lib.h"
#include "taler_exchangedb_lib.h"
/**
@ -34,15 +34,15 @@ static int verbose;
static char *auditor_key_file;
/**
* Mint's public key (in Crockford base32 encoding).
* Exchange's public key (in Crockford base32 encoding).
*/
static char *mint_public_key;
static char *exchange_public_key;
/**
* File with the Mint's denomination keys to sign, itself
* signed by the Mint's public key.
* File with the Exchange's denomination keys to sign, itself
* signed by the Exchange's public key.
*/
static char *mint_request_file;
static char *exchange_request_file;
/**
* Where should we write the auditor's signature?
@ -50,10 +50,20 @@ static char *mint_request_file;
static char *output_file;
/**
* Master public key of the mint.
* URL of the auditor (informative for the user).
*/
static char *auditor_url;
/**
* Master public key of the exchange.
*/
static struct TALER_MasterPublicKeyP master_public_key;
/**
* Our configuration.
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Print denomination key details for diagnostics.
@ -114,8 +124,8 @@ print_dk (const struct TALER_DenominationKeyValidityPS *dk)
/**
* The main function of the taler-auditor-sign tool. This tool is used
* to sign a mint's master and denomination keys, affirming that the
* auditor is aware of them and will validate the mint's database with
* to sign a exchange's master and denomination keys, affirming that the
* auditor is aware of them and will validate the exchange's database with
* respect to these keys.
*
* @param argc number of arguments from the command line
@ -126,18 +136,23 @@ int
main (int argc,
char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'a', "auditor-key", "FILE",
char *cfgfile = NULL;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'a', "auditor-key", "FILENAME",
"file containing the private key of the auditor", 1,
&GNUNET_GETOPT_set_filename, &auditor_key_file},
TALER_GETOPT_OPTION_HELP ("Private key of the auditor to use for signing"),
{'m', "mint-key", "KEY",
"public key of the mint (Crockford base32 encoded)", 1,
&GNUNET_GETOPT_set_filename, &mint_public_key},
{'r', "mint-request", "FILE",
"set of keys the mint requested the auditor to sign", 1,
&GNUNET_GETOPT_set_string, &mint_request_file},
{'o', "output", "FILE",
GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
GNUNET_GETOPT_OPTION_HELP ("Private key of the auditor to use for signing"),
{'m', "exchange-key", "KEY",
"public key of the exchange (Crockford base32 encoded)", 1,
&GNUNET_GETOPT_set_filename, &exchange_public_key},
{'u', "auditor-url", "URL",
"URL of the auditor (informative link for the user)", 1,
&GNUNET_GETOPT_set_string, &auditor_url},
{'r', "exchange-request", "FILENAME",
"set of keys the exchange requested the auditor to sign", 1,
&GNUNET_GETOPT_set_string, &exchange_request_file},
{'o', "output", "FILENAME",
"where to write our signature", 1,
&GNUNET_GETOPT_set_string, &output_file},
GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),
@ -150,22 +165,49 @@ main (int argc,
struct GNUNET_DISK_FileHandle *fh;
struct TALER_DenominationKeyValidityPS *dks;
unsigned int dks_len;
struct TALER_MintKeyValidityPS kv;
struct TALER_ExchangeKeyValidityPS kv;
off_t in_size;
unsigned int i;
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-mint-keyup",
GNUNET_log_setup ("taler-auditor-sign",
"WARNING",
NULL));
if (GNUNET_GETOPT_run ("taler-mint-keyup",
if (GNUNET_GETOPT_run ("taler-auditor-sign",
options,
argc, argv) < 0)
return 1;
if (NULL == auditor_key_file)
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg,
cfgfile))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1;
}
GNUNET_free_non_null (cfgfile);
if ( (NULL == auditor_key_file) &&
(GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
"auditor",
"AUDITOR_PRIV_FILE",
&auditor_key_file)) )
{
fprintf (stderr,
"Auditor key file not given\n");
"Auditor key file not given in neither configuration nor command-line\n");
return 1;
}
if ( (NULL == auditor_url) &&
(GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"auditor",
"AUDITOR_URL",
&auditor_url)) )
{
fprintf (stderr,
"Auditor URL not given\n");
return 1;
}
eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (auditor_key_file);
@ -178,40 +220,40 @@ main (int argc,
}
GNUNET_CRYPTO_eddsa_key_get_public (eddsa_priv,
&apub.eddsa_pub);
if (NULL == mint_public_key)
if (NULL == exchange_public_key)
{
fprintf (stderr,
"Mint public key not given\n");
"Exchange public key not given\n");
GNUNET_free (eddsa_priv);
return 1;
}
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (mint_public_key,
strlen (mint_public_key),
GNUNET_STRINGS_string_to_data (exchange_public_key,
strlen (exchange_public_key),
&master_public_key,
sizeof (master_public_key)))
{
fprintf (stderr,
"Public key `%s' malformed\n",
mint_public_key);
exchange_public_key);
GNUNET_free (eddsa_priv);
return 1;
}
if (NULL == mint_request_file)
if (NULL == exchange_request_file)
{
fprintf (stderr,
"Mint signing request not given\n");
"Exchange signing request not given\n");
GNUNET_free (eddsa_priv);
return 1;
}
fh = GNUNET_DISK_file_open (mint_request_file,
fh = GNUNET_DISK_file_open (exchange_request_file,
GNUNET_DISK_OPEN_READ,
GNUNET_DISK_PERM_NONE);
if (NULL == fh)
{
fprintf (stderr,
"Failed to open file `%s': %s\n",
mint_request_file,
exchange_request_file,
STRERROR (errno));
GNUNET_free (eddsa_priv);
return 1;
@ -222,7 +264,7 @@ main (int argc,
{
fprintf (stderr,
"Failed to obtain input file size `%s': %s\n",
mint_request_file,
exchange_request_file,
STRERROR (errno));
GNUNET_DISK_file_close (fh);
GNUNET_free (eddsa_priv);
@ -232,14 +274,17 @@ main (int argc,
{
fprintf (stderr,
"Input file size of file `%s' is invalid\n",
mint_request_file);
exchange_request_file);
GNUNET_DISK_file_close (fh);
GNUNET_free (eddsa_priv);
return 1;
}
dks_len = in_size / sizeof (struct TALER_DenominationKeyValidityPS);
kv.purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_MINT_KEYS);
kv.purpose.size = htonl (sizeof (struct TALER_MintKeyValidityPS));
kv.purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS);
kv.purpose.size = htonl (sizeof (struct TALER_ExchangeKeyValidityPS));
GNUNET_CRYPTO_hash (auditor_url,
strlen (auditor_url) + 1,
&kv.auditor_url_hash);
kv.master = master_public_key;
dks = GNUNET_new_array (dks_len,
struct TALER_DenominationKeyValidityPS);
@ -252,7 +297,7 @@ main (int argc,
{
fprintf (stderr,
"Failed to read input file `%s': %s\n",
mint_request_file,
exchange_request_file,
STRERROR (errno));
GNUNET_DISK_file_close (fh);
GNUNET_free (sigs);
@ -281,8 +326,6 @@ main (int argc,
GNUNET_CRYPTO_eddsa_sign (eddsa_priv,
&kv.purpose,
&sigs[i].eddsa_sig);
}
if (NULL == output_file)
@ -297,12 +340,13 @@ main (int argc,
/* write result to disk */
if (GNUNET_OK !=
TALER_MINTDB_auditor_write (output_file,
&apub,
sigs,
&master_public_key,
dks_len,
dks))
TALER_EXCHANGEDB_auditor_write (output_file,
&apub,
auditor_url,
sigs,
&master_public_key,
dks_len,
dks))
{
fprintf (stderr,
"Failed to write to file `%s': %s\n",
@ -312,6 +356,7 @@ main (int argc,
GNUNET_free (dks);
return 1;
}
GNUNET_free (sigs);
GNUNET_free (dks);
GNUNET_free (eddsa_priv);

View File

@ -14,34 +14,18 @@
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file mint-tools/taler-mint-dbinit.c
* @brief Create tables for the mint database.
* @file exchange-tools/taler-exchange-dbinit.c
* @brief Create tables for the exchange database.
* @author Florian Dold
*/
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <libpq-fe.h>
#include "taler_mintdb_plugin.h"
/**
* Mint directory with the keys.
*/
static char *mint_base_dir;
/**
* Our configuration.
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Our DB plugin.
*/
static struct TALER_MINTDB_Plugin *plugin;
#include "taler_exchangedb_plugin.h"
/**
* The main function of the database initialization tool.
* Used to initialize the Taler Mint's database.
* Used to initialize the Taler Exchange's database.
*
* @param argc number of arguments from the command line
* @param argv command line arguments
@ -51,42 +35,42 @@ int
main (int argc,
char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'d', "mint-dir", "DIR",
"mint directory", 1,
&GNUNET_GETOPT_set_filename, &mint_base_dir},
GNUNET_GETOPT_OPTION_HELP ("Initialize Taler Mint database"),
char *cfgfile = NULL;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
GNUNET_GETOPT_OPTION_HELP ("Initialize Taler Exchange database"),
GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),
GNUNET_GETOPT_OPTION_END
};
struct GNUNET_CONFIGURATION_Handle *cfg;
struct TALER_EXCHANGEDB_Plugin *plugin;
if (GNUNET_GETOPT_run ("taler-mint-dbinit",
if (GNUNET_GETOPT_run ("taler-exchange-dbinit",
options,
argc, argv) < 0)
return 1;
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-mint-dbinit",
GNUNET_log_setup ("taler-exchange-dbinit",
"INFO",
NULL));
if (NULL == mint_base_dir)
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg,
cfgfile))
{
fprintf (stderr,
"Mint base directory not given.\n");
return 1;
}
cfg = TALER_config_load (mint_base_dir);
if (NULL == cfg)
{
fprintf (stderr,
"Failed to load mint configuration.\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1;
}
GNUNET_free_non_null (cfgfile);
if (NULL ==
(plugin = TALER_MINTDB_plugin_load (cfg)))
(plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
{
fprintf (stderr,
"Failed to initialize database plugin.\n");
GNUNET_CONFIGURATION_destroy (cfg);
return 1;
}
if (GNUNET_OK !=
@ -95,11 +79,13 @@ main (int argc,
{
fprintf (stderr,
"Failed to initialize database.\n");
TALER_MINTDB_plugin_unload (plugin);
TALER_EXCHANGEDB_plugin_unload (plugin);
GNUNET_CONFIGURATION_destroy (cfg);
return 1;
}
TALER_MINTDB_plugin_unload (plugin);
TALER_EXCHANGEDB_plugin_unload (plugin);
GNUNET_CONFIGURATION_destroy (cfg);
return 0;
}
/* end of taler-mint-dbinit.c */
/* end of taler-exchange-dbinit.c */

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015 GNUnet e.V.
Copyright (C) 2014, 2015, 2016 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@ -14,9 +14,9 @@
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file taler-mint-keycheck.c
* @brief Check mint keys for validity. Reads the signing and denomination
* keys from the mint directory and checks to make sure they are
* @file taler-exchange-keycheck.c
* @brief Check exchange keys for validity. Reads the signing and denomination
* keys from the exchange directory and checks to make sure they are
* well-formed. This is purely a diagnostic tool.
* @author Florian Dold
* @author Benedikt Mueller
@ -24,12 +24,12 @@
*/
#include <platform.h>
#include <gnunet/gnunet_util_lib.h>
#include "taler_mintdb_lib.h"
#include "taler_exchangedb_lib.h"
/**
* Mint directory with the keys.
* Exchange directory with the keys.
*/
static char *mint_directory;
static char *exchange_directory;
/**
* Our configuration.
@ -50,7 +50,7 @@ static struct GNUNET_CONFIGURATION_Handle *kcfg;
static int
signkeys_iter (void *cls,
const char *filename,
const struct TALER_MINTDB_PrivateSigningKeyInformationP *ski)
const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Iterating over key `%s' for start time %s\n",
@ -59,8 +59,8 @@ signkeys_iter (void *cls,
(GNUNET_TIME_absolute_ntoh (ski->issue.start)));
if (ntohl (ski->issue.purpose.size) !=
(sizeof (struct TALER_MintSigningKeyValidityPS) -
offsetof (struct TALER_MintSigningKeyValidityPS,
(sizeof (struct TALER_ExchangeSigningKeyValidityPS) -
offsetof (struct TALER_ExchangeSigningKeyValidityPS,
purpose)))
{
fprintf (stderr,
@ -101,11 +101,11 @@ signkeys_iter (void *cls,
* #GNUNET_NO if not
*/
static int
mint_signkeys_check ()
exchange_signkeys_check ()
{
if (0 > TALER_MINTDB_signing_keys_iterate (mint_directory,
&signkeys_iter,
NULL))
if (0 > TALER_EXCHANGEDB_signing_keys_iterate (exchange_directory,
&signkeys_iter,
NULL))
return GNUNET_NO;
return GNUNET_OK;
}
@ -124,7 +124,7 @@ mint_signkeys_check ()
static int
denomkeys_iter (void *cls,
const char *alias,
const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki)
{
struct GNUNET_HashCode hc;
@ -183,11 +183,11 @@ denomkeys_iter (void *cls,
* #GNUNET_NO if not
*/
static int
mint_denomkeys_check ()
exchange_denomkeys_check ()
{
if (0 > TALER_MINTDB_denomination_keys_iterate (mint_directory,
&denomkeys_iter,
NULL))
if (0 > TALER_EXCHANGEDB_denomination_keys_iterate (exchange_directory,
&denomkeys_iter,
NULL))
return GNUNET_NO;
return GNUNET_OK;
}
@ -203,39 +203,47 @@ mint_denomkeys_check ()
int
main (int argc, char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-keycheck OPTIONS"),
{'d', "directory", "DIRECTORY",
"mint directory with keys to check", 1,
&GNUNET_GETOPT_set_filename, &mint_directory},
char *cfgfile;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
GNUNET_GETOPT_OPTION_HELP ("gnunet-exchange-keycheck OPTIONS"),
GNUNET_GETOPT_OPTION_END
};
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-mint-keycheck",
GNUNET_log_setup ("taler-exchange-keycheck",
"WARNING",
NULL));
if (GNUNET_GETOPT_run ("taler-mint-keycheck",
if (GNUNET_GETOPT_run ("taler-exchange-keycheck",
options,
argc, argv) < 0)
return 1;
if (NULL == mint_directory)
kcfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg,
cfgfile))
{
fprintf (stderr,
"Mint directory not given\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1;
}
GNUNET_free_non_null (cfgfile);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (kcfg,
"exchange",
"KEYDIR",
&exchange_directory))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"KEYDIR");
return 1;
}
kcfg = TALER_config_load (mint_directory);
if (NULL == kcfg)
{
fprintf (stderr,
"Failed to load mint configuration\n");
return 1;
}
if ( (GNUNET_OK != mint_signkeys_check ()) ||
(GNUNET_OK != mint_denomkeys_check ()) )
if ( (GNUNET_OK != exchange_signkeys_check ()) ||
(GNUNET_OK != exchange_denomkeys_check ()) )
{
GNUNET_CONFIGURATION_destroy (kcfg);
return 1;
@ -244,4 +252,4 @@ main (int argc, char *const *argv)
return 0;
}
/* end of taler-mint-keycheck.c */
/* end of taler-exchange-keycheck.c */

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015 GNUnet e.V.
Copyright (C) 2014, 2015, 2016 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@ -14,15 +14,15 @@
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file taler-mint-keyup.c
* @brief Update the mint's keys for coins and signatures,
* using the mint's offline master key.
* @file taler-exchange-keyup.c
* @brief Update the exchange's keys for coins and signatures,
* using the exchange's offline master key.
* @author Florian Dold
* @author Benedikt Mueller
* @author Christian Grothoff
*/
#include <platform.h>
#include "taler_mintdb_lib.h"
#include "taler_exchangedb_lib.h"
/**
* When generating filenames from a cryptographic hash, we do not use
@ -169,9 +169,9 @@ static char *auditorrequestfile;
static FILE *auditor_output_file;
/**
* Director of the mint, containing the keys.
* Director of the exchange, containing the keys.
*/
static char *mint_directory;
static char *exchange_directory;
/**
* Time to pretend when the key update is executed.
@ -179,7 +179,7 @@ static char *mint_directory;
static char *pretend_time_str;
/**
* Handle to the mint's configuration
* Handle to the exchange's configuration
*/
static struct GNUNET_CONFIGURATION_Handle *kcfg;
@ -190,12 +190,12 @@ static struct GNUNET_CONFIGURATION_Handle *kcfg;
static struct GNUNET_TIME_Absolute now;
/**
* Master private key of the mint.
* Master private key of the exchange.
*/
static struct TALER_MasterPrivateKeyP master_priv;
/**
* Master public key of the mint.
* Master public key of the exchange.
*/
static struct TALER_MasterPublicKeyP master_public_key;
@ -210,7 +210,7 @@ static struct GNUNET_TIME_Absolute lookahead_sign_stamp;
* keys created at time @a start.
*
* @param start time at which we create the signing key
* @return name of the directory we should use, basically "$MINTDIR/$TIME/";
* @return name of the directory we should use, basically "$EXCHANGEDIR/$TIME/";
* (valid until next call to this function)
*/
static const char *
@ -220,8 +220,8 @@ get_signkey_file (struct GNUNET_TIME_Absolute start)
GNUNET_snprintf (dir,
sizeof (dir),
"%s" DIR_SEPARATOR_STR TALER_MINTDB_DIR_SIGNING_KEYS DIR_SEPARATOR_STR "%llu",
mint_directory,
"%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS DIR_SEPARATOR_STR "%llu",
exchange_directory,
(unsigned long long) start.abs_value_us);
return dir;
}
@ -265,7 +265,7 @@ hash_coin_type (const struct CoinTypeParams *p,
/**
* Obtain the name of the directory we should use to store coins of
* the given type. The directory name has the format
* "$MINTDIR/$VALUE/$HASH/" where "$VALUE" represents the value of the
* "$EXCHANGEDIR/$VALUE/$HASH/" where "$VALUE" represents the value of the
* coin and "$HASH" encodes all of the coin's parameters, generating a
* unique string for each type of coin. Note that the "$HASH"
* includes neither the absolute creation time nor the key of the
@ -299,8 +299,8 @@ get_cointype_dir (const struct CoinTypeParams *p)
GNUNET_snprintf (dir,
sizeof (dir),
"%s" DIR_SEPARATOR_STR TALER_MINTDB_DIR_DENOMINATION_KEYS DIR_SEPARATOR_STR "%s-%s",
mint_directory,
"%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS DIR_SEPARATOR_STR "%s-%s",
exchange_directory,
val_str,
hash_str);
GNUNET_free (hash_str);
@ -434,7 +434,7 @@ get_anchor (const char *dir,
/**
* Create a mint signing key (for signing mint messages, not for coins)
* Create a exchange signing key (for signing exchange messages, not for coins)
* and assert its correctness by signing it with the master key.
*
* @param start start time of the validity period for the key
@ -446,10 +446,10 @@ static void
create_signkey_issue_priv (struct GNUNET_TIME_Absolute start,
struct GNUNET_TIME_Relative duration,
struct GNUNET_TIME_Absolute end,
struct TALER_MINTDB_PrivateSigningKeyInformationP *pi)
struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *pi)
{
struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
struct TALER_MintSigningKeyValidityPS *issue = &pi->issue;
struct TALER_ExchangeSigningKeyValidityPS *issue = &pi->issue;
priv = GNUNET_CRYPTO_eddsa_key_create ();
pi->signkey_priv.eddsa_priv = *priv;
@ -462,8 +462,8 @@ create_signkey_issue_priv (struct GNUNET_TIME_Absolute start,
GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv.eddsa_priv,
&issue->signkey_pub.eddsa_pub);
issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY);
issue->purpose.size = htonl (sizeof (struct TALER_MintSigningKeyValidityPS) -
offsetof (struct TALER_MintSigningKeyValidityPS,
issue->purpose.size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS) -
offsetof (struct TALER_ExchangeSigningKeyValidityPS,
purpose));
GNUNET_assert (GNUNET_OK ==
@ -480,7 +480,7 @@ create_signkey_issue_priv (struct GNUNET_TIME_Absolute start,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
mint_keys_update_signkeys ()
exchange_keys_update_signkeys ()
{
struct GNUNET_TIME_Relative signkey_duration;
struct GNUNET_TIME_Relative legal_duration;
@ -489,23 +489,23 @@ mint_keys_update_signkeys ()
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
"mint_keys",
"exchange_keys",
"signkey_duration",
&signkey_duration))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"mint_keys",
"exchange_keys",
"signkey_duration");
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
"mint_keys",
"exchange_keys",
"legal_duration",
&legal_duration))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"mint_keys",
"exchange_keys",
"legal_duration",
"fails to specify valid timeframe");
return GNUNET_SYSERR;
@ -513,15 +513,15 @@ mint_keys_update_signkeys ()
if (signkey_duration.rel_value_us > legal_duration.rel_value_us)
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"mint_keys",
"exchange_keys",
"legal_duration",
"must be longer than signkey_duration");
return GNUNET_SYSERR;
}
TALER_round_rel_time (&signkey_duration);
GNUNET_TIME_round_rel (&signkey_duration);
GNUNET_asprintf (&signkey_dir,
"%s" DIR_SEPARATOR_STR TALER_MINTDB_DIR_SIGNING_KEYS,
mint_directory);
"%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS,
exchange_directory);
/* make sure the directory exists */
if (GNUNET_OK !=
GNUNET_DISK_directory_create (signkey_dir))
@ -539,7 +539,7 @@ mint_keys_update_signkeys ()
while (anchor.abs_value_us < lookahead_sign_stamp.abs_value_us)
{
const char *skf;
struct TALER_MINTDB_PrivateSigningKeyInformationP signkey_issue;
struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP signkey_issue;
ssize_t nwrite;
struct GNUNET_TIME_Absolute end;
@ -557,9 +557,9 @@ mint_keys_update_signkeys ()
&signkey_issue);
nwrite = GNUNET_DISK_fn_write (skf,
&signkey_issue,
sizeof (struct TALER_MINTDB_PrivateSigningKeyInformationP),
sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP),
GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ);
if (sizeof (struct TALER_MINTDB_PrivateSigningKeyInformationP) != nwrite)
if (sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP) != nwrite)
{
fprintf (stderr,
"Failed to write to file `%s': %s\n",
@ -600,7 +600,7 @@ get_cointype_params (const char *ct,
"duration_withdraw");
return GNUNET_SYSERR;
}
TALER_round_rel_time (&params->duration_withdraw);
GNUNET_TIME_round_rel (&params->duration_withdraw);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
ct,
@ -612,7 +612,7 @@ get_cointype_params (const char *ct,
"duration_spend");
return GNUNET_SYSERR;
}
TALER_round_rel_time (&params->duration_spend);
GNUNET_TIME_round_rel (&params->duration_spend);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
ct,
@ -624,7 +624,7 @@ get_cointype_params (const char *ct,
"duration_legal");
return GNUNET_SYSERR;
}
TALER_round_rel_time (&params->duration_legal);
GNUNET_TIME_round_rel (&params->duration_legal);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
ct,
@ -633,10 +633,10 @@ get_cointype_params (const char *ct,
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
ct,
"mint_denom_duration_overlap");
"exchange_denom_duration_overlap");
return GNUNET_SYSERR;
}
TALER_round_rel_time (&params->duration_overlap);
GNUNET_TIME_round_rel (&params->duration_overlap);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (kcfg,
ct,
@ -722,7 +722,7 @@ get_cointype_params (const char *ct,
*/
static void
create_denomkey_issue (const struct CoinTypeParams *params,
struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki)
{
dki->denom_priv.rsa_private_key
= GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize);
@ -769,13 +769,13 @@ create_denomkey_issue (const struct CoinTypeParams *params,
* @param coin_alias name of the coin's section in the configuration
*/
static void
mint_keys_update_cointype (void *cls,
exchange_keys_update_cointype (void *cls,
const char *coin_alias)
{
int *ret = cls;
struct CoinTypeParams p;
const char *dkf;
struct TALER_MINTDB_DenominationKeyIssueInformation denomkey_issue;
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation denomkey_issue;
if (0 != strncasecmp (coin_alias,
"coin_",
@ -808,7 +808,7 @@ mint_keys_update_cointype (void *cls,
create_denomkey_issue (&p,
&denomkey_issue);
if (GNUNET_OK !=
TALER_MINTDB_denomination_key_write (dkf,
TALER_EXCHANGEDB_denomination_key_write (dkf,
&denomkey_issue))
{
fprintf (stderr,
@ -842,28 +842,28 @@ mint_keys_update_cointype (void *cls,
/**
* Update all of the denomination keys of the mint.
* Update all of the denomination keys of the exchange.
*
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
mint_keys_update_denomkeys ()
exchange_keys_update_denomkeys ()
{
int ok;
ok = GNUNET_OK;
GNUNET_CONFIGURATION_iterate_sections (kcfg,
&mint_keys_update_cointype,
&exchange_keys_update_cointype,
&ok);
return ok;
}
/**
* The main function of the taler-mint-keyup tool. This tool is used
* to create the signing and denomination keys for the mint. It uses
* The main function of the taler-exchange-keyup tool. This tool is used
* to create the signing and denomination keys for the exchange. It uses
* the long-term offline private key and writes the (additional) key
* files to the respective mint directory (from where they can then be
* files to the respective exchange directory (from where they can then be
* copied to the online server). Note that we need (at least) the
* most recent generated previous keys so as to align the validity
* periods.
@ -876,11 +876,10 @@ int
main (int argc,
char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'d', "mint-dir", "DIR",
"mint directory with keys to update", 1,
&GNUNET_GETOPT_set_filename, &mint_directory},
TALER_GETOPT_OPTION_HELP ("Setup signing and denomination keys for a Taler mint"),
char *cfgfile = NULL;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
GNUNET_GETOPT_OPTION_HELP ("Setup signing and denomination keys for a Taler exchange"),
{'m', "master-key", "FILE",
"master key file (private key)", 1,
&GNUNET_GETOPT_set_filename, &masterkeyfile},
@ -897,20 +896,25 @@ main (int argc,
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv;
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-mint-keyup",
GNUNET_log_setup ("taler-exchange-keyup",
"WARNING",
NULL));
if (GNUNET_GETOPT_run ("taler-mint-keyup",
if (GNUNET_GETOPT_run ("taler-exchange-keyup",
options,
argc, argv) < 0)
return 1;
if (NULL == mint_directory)
kcfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg,
cfgfile))
{
fprintf (stderr,
"Mint directory not given\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1;
}
GNUNET_free_non_null (cfgfile);
if (NULL != pretend_time_str)
{
if (GNUNET_OK !=
@ -927,19 +931,27 @@ main (int argc,
{
now = GNUNET_TIME_absolute_get ();
}
TALER_round_abs_time (&now);
kcfg = TALER_config_load (mint_directory);
if (NULL == kcfg)
GNUNET_TIME_round_abs (&now);
if ( (NULL == masterkeyfile) &&
(GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (kcfg,
"exchange",
"MASTER_PRIV_FILE",
&masterkeyfile)) )
{
fprintf (stderr,
"Failed to load mint configuration\n");
"Master key file not given in neither configuration nor command-line\n");
return 1;
}
if (NULL == masterkeyfile)
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (kcfg,
"exchange",
"KEYDIR",
&exchange_directory))
{
fprintf (stderr,
"Master key file not given\n");
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"KEYDIR");
return 1;
}
eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile);
@ -975,13 +987,13 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_data (kcfg,
"mint",
"exchange",
"master_public_key",
&master_public_key_from_cfg,
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"mint",
"exchange",
"master_public_key");
return 1;
}
@ -991,7 +1003,7 @@ main (int argc,
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"mint",
"exchange",
"master_public_key",
_("does not match with private key"));
return 1;
@ -1000,33 +1012,33 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
"mint_keys",
"exchange_keys",
"lookahead_sign",
&lookahead_sign))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"mint_keys",
"exchange_keys",
"lookahead_sign");
return GNUNET_SYSERR;
}
if (0 == lookahead_sign.rel_value_us)
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"mint_keys",
"exchange_keys",
"lookahead_sign",
_("must not be zero"));
return GNUNET_SYSERR;
}
TALER_round_rel_time (&lookahead_sign);
GNUNET_TIME_round_rel (&lookahead_sign);
lookahead_sign_stamp = GNUNET_TIME_absolute_add (now,
lookahead_sign);
/* finally, do actual work */
if (GNUNET_OK != mint_keys_update_signkeys ())
if (GNUNET_OK != exchange_keys_update_signkeys ())
return 1;
if (GNUNET_OK != mint_keys_update_denomkeys ())
if (GNUNET_OK != exchange_keys_update_denomkeys ())
return 1;
if (NULL != auditor_output_file)
{
@ -1036,4 +1048,4 @@ main (int argc,
return 0;
}
/* end of taler-mint-keyup.c */
/* end of taler-exchange-keyup.c */

View File

@ -14,7 +14,7 @@
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file taler-mint-reservemod.c
* @file taler-exchange-reservemod.c
* @brief Modify reserves. Allows manipulation of reserve balances.
* @author Florian Dold
* @author Benedikt Mueller
@ -23,22 +23,22 @@
#include <gnunet/gnunet_util_lib.h>
#include <libpq-fe.h>
#include <jansson.h>
#include "taler_mintdb_plugin.h"
#include "taler_exchangedb_plugin.h"
/**
* Director of the mint, containing the keys.
* Director of the exchange, containing the keys.
*/
static char *mint_directory;
static char *exchange_directory;
/**
* Handle to the mint's configuration
* Handle to the exchange's configuration
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Our DB plugin.
*/
static struct TALER_MINTDB_Plugin *plugin;
static struct TALER_EXCHANGEDB_Plugin *plugin;
/**
@ -51,6 +51,7 @@ static struct TALER_MINTDB_Plugin *plugin;
int
main (int argc, char *const *argv)
{
char *cfgfile = NULL;
char *reserve_pub_str = NULL;
char *add_str = NULL;
struct TALER_Amount add_value;
@ -58,18 +59,16 @@ main (int argc, char *const *argv)
json_t *jdetails;
json_error_t error;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_MINTDB_Session *session;
struct TALER_EXCHANGEDB_Session *session;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'a', "add", "DENOM",
"value to add", 1,
&GNUNET_GETOPT_set_string, &add_str},
{'d', "mint-dir", "DIR",
"mint directory with keys to update", 1,
&GNUNET_GETOPT_set_filename, &mint_directory},
{'D', "details", "JSON",
GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
{'d', "details", "JSON",
"details about the bank transaction which justify why we add this amount", 1,
&GNUNET_GETOPT_set_string, &details},
TALER_GETOPT_OPTION_HELP ("Deposit funds into a Taler reserve"),
GNUNET_GETOPT_OPTION_HELP ("Deposit funds into a Taler reserve"),
{'R', "reserve", "KEY",
"reserve (public key) to modify", 1,
&GNUNET_GETOPT_set_string, &reserve_pub_str},
@ -79,18 +78,37 @@ main (int argc, char *const *argv)
int ret;
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-mint-reservemod",
GNUNET_log_setup ("taler-exchange-reservemod",
"WARNING",
NULL));
if (GNUNET_GETOPT_run ("taler-mint-reservemod",
if (GNUNET_GETOPT_run ("taler-exchange-reservemod",
options,
argc, argv) < 0)
return 1;
if (NULL == mint_directory)
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg,
cfgfile))
{
fprintf (stderr,
"Mint directory not given\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
GNUNET_free_non_null (add_str);
GNUNET_free_non_null (details);
GNUNET_free_non_null (reserve_pub_str);
return 1;
}
GNUNET_free_non_null (cfgfile);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
"exchange",
"KEYDIR",
&exchange_directory))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"KEYDIR");
GNUNET_free_non_null (add_str);
GNUNET_free_non_null (details);
GNUNET_free_non_null (reserve_pub_str);
@ -133,19 +151,9 @@ main (int argc, char *const *argv)
return 1;
}
cfg = TALER_config_load (mint_directory);
if (NULL == cfg)
{
fprintf (stderr,
"Failed to load mint configuration\n");
GNUNET_free_non_null (add_str);
GNUNET_free_non_null (details);
GNUNET_free_non_null (reserve_pub_str);
return 1;
}
ret = 1;
if (NULL ==
(plugin = TALER_MINTDB_plugin_load (cfg)))
(plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
{
fprintf (stderr,
"Failed to initialize database plugin.\n");
@ -194,7 +202,7 @@ main (int argc, char *const *argv)
ret = 0;
cleanup:
if (NULL != plugin)
TALER_MINTDB_plugin_unload (plugin);
TALER_EXCHANGEDB_plugin_unload (plugin);
if (NULL != cfg)
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free_non_null (add_str);
@ -203,4 +211,4 @@ main (int argc, char *const *argv)
return ret;
}
/* end taler-mint-reservemod.c */
/* end taler-exchange-reservemod.c */

View File

@ -0,0 +1,214 @@
/*
This file is part of TALER
Copyright (C) 2015, 2016 Inria
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, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file taler-exchange-wire.c
* @brief Create signed response for /wire requests.
* @author Christian Grothoff
*/
#include <platform.h>
#include <jansson.h>
#include <gnunet/gnunet_json_lib.h>
#include "taler_crypto_lib.h"
#include "taler_wire_lib.h"
#include "taler_signatures.h"
/**
* Filename of the master private key.
*/
static char *masterkeyfile;
/**
* Account holder information in JSON format.
*/
static char *json_in;
/**
* Which wire method is this for?
*/
static char *method;
/**
* Where to write the result.
*/
static char *output_filename;
/**
* Our configuration.
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* The main function of the taler-exchange-sepa tool. This tool is used
* to sign the SEPA bank account details using the master key.
*
* @param argc number of arguments from the command line
* @param argv command line arguments
* @return 0 ok, 1 on error
*/
int
main (int argc,
char *const *argv)
{
char *cfgfile = NULL;
const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
{'j', "json", "JSON",
"account information in JSON format", 1,
&GNUNET_GETOPT_set_string, &json_in},
{'m', "master-key", "FILE",
"master key file (private key)", 1,
&GNUNET_GETOPT_set_filename, &masterkeyfile},
{'t', "type", "METHOD",
"which wire transfer method (i.e. 'test' or 'sepa') is this for?", 1,
&GNUNET_GETOPT_set_string, &method},
{'o', "output", "FILE",
"where to write the result", 1,
&GNUNET_GETOPT_set_filename, &output_filename},
GNUNET_GETOPT_OPTION_HELP ("Setup /wire response"),
GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),
GNUNET_GETOPT_OPTION_END
};
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv;
struct TALER_MasterPrivateKeyP key;
struct TALER_MasterSignatureP sig;
json_t *j;
json_error_t err;
char *json_out;
struct GNUNET_HashCode salt;
struct TALER_WIRE_Plugin *plugin;
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-exchange-wire",
"WARNING",
NULL));
if (GNUNET_GETOPT_run ("taler-exchange-wire",
options,
argc, argv) < 0)
return 1;
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg,
cfgfile))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Malformed configuration file `%s', exit ...\n"),
cfgfile);
GNUNET_free_non_null (cfgfile);
return 1;
}
GNUNET_free_non_null (cfgfile);
if ( (NULL == masterkeyfile) &&
(GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
"exchange-master",
"MASTER_PRIV_FILE",
&masterkeyfile)) )
{
fprintf (stderr,
"Master key file not given in neither configuration nor command-line\n");
return 1;
}
eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile);
if (NULL == eddsa_priv)
{
fprintf (stderr,
"Failed to initialize master key from file `%s'\n",
masterkeyfile);
return 1;
}
if (NULL == json_in)
{
fprintf (stderr,
"Required -j argument missing\n");
return 1;
}
if (NULL == method)
{
fprintf (stderr,
"Required -t argument missing\n");
return 1;
}
j = json_loads (json_in,
JSON_REJECT_DUPLICATES,
&err);
if (NULL == j)
{
fprintf (stderr,
"Failed to parse JSON: %s (at offset %u)\n",
err.text,
(unsigned int) err.position);
return 1;
}
key.eddsa_priv = *eddsa_priv;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&salt,
sizeof (salt));
plugin = TALER_WIRE_plugin_load (cfg,
method);
if (NULL == plugin)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Wire transfer method `%s' not supported\n",
method);
return 1;
}
if (GNUNET_OK !=
plugin->sign_wire_details (plugin->cls,
j,
&key,
&salt,
&sig))
{
/* sign function should have logged applicable errors */
json_decref (j);
TALER_WIRE_plugin_unload (plugin);
return 1;
}
TALER_WIRE_plugin_unload (plugin);
GNUNET_free (eddsa_priv);
/* add signature and salt to JSON message */
json_object_set_new (j,
"salt",
GNUNET_JSON_from_data (&salt,
sizeof (salt)));
json_object_set_new (j,
"sig",
GNUNET_JSON_from_data (&sig,
sizeof (sig)));
/* dump result to stdout */
json_out = json_dumps (j, JSON_INDENT(2));
json_decref (j);
GNUNET_assert (NULL != json_out);
if (NULL != output_filename)
{
fclose (stdout);
stdout = fopen (output_filename,
"w+");
}
fprintf (stdout,
"%s",
json_out);
fflush (stdout);
free (json_out);
return 0;
}
/* end of taler-exchange-wire.c */

6
src/exchange/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
taler-exchange-dbinit
taler-exchange-keycheck
taler-exchange-keyup
taler-exchange-pursemod
taler-exchange-reservemod
taler-exchange-httpd

95
src/exchange/Makefile.am Normal file
View File

@ -0,0 +1,95 @@
# This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include
if USE_COVERAGE
AM_CFLAGS = --coverage -O0
XLIB = -lgcov
endif
pkgcfgdir = $(prefix)/share/taler/config.d/
pkgcfg_DATA = \
exchange.conf
bin_PROGRAMS = \
taler-exchange-aggregator \
taler-exchange-httpd
taler_exchange_aggregator_SOURCES = \
taler-exchange-aggregator.c
taler_exchange_aggregator_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/wire/libtalerwire.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
-ljansson \
-lgnunetutil
taler_exchange_httpd_SOURCES = \
taler-exchange-httpd.c taler-exchange-httpd.h \
taler-exchange-httpd_admin.c taler-exchange-httpd_admin.h \
taler-exchange-httpd_db.c taler-exchange-httpd_db.h \
taler-exchange-httpd_deposit.c taler-exchange-httpd_deposit.h \
taler-exchange-httpd_keystate.c taler-exchange-httpd_keystate.h \
taler-exchange-httpd_mhd.c taler-exchange-httpd_mhd.h \
taler-exchange-httpd_parsing.c taler-exchange-httpd_parsing.h \
taler-exchange-httpd_refresh.c taler-exchange-httpd_refresh.h \
taler-exchange-httpd_reserve.c taler-exchange-httpd_reserve.h \
taler-exchange-httpd_responses.c taler-exchange-httpd_responses.h \
taler-exchange-httpd_tracking.c taler-exchange-httpd_tracking.h \
taler-exchange-httpd_wire.c taler-exchange-httpd_wire.h \
taler-exchange-httpd_validation.c taler-exchange-httpd_validation.h
taler_exchange_httpd_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/wire/libtalerwire.la \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/util/libtalerutil.la \
-lmicrohttpd \
-lgnunetutil \
-lgnunetjson \
-ljansson \
-lpthread
if HAVE_DEVELOPER
taler_exchange_httpd_SOURCES += \
taler-exchange-httpd_test.c taler-exchange-httpd_test.h
endif
check_SCRIPTS = \
test_taler_exchange_httpd.sh
if HAVE_EXPENSIVE_TESTS
check_SCRIPTS += \
test_taler_exchange_httpd_afl.sh
endif
test_taler_exchange_aggregator_postgres_SOURCES = \
test_taler_exchange_aggregator.c
test_taler_exchange_aggregator_postgres_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
-lmicrohttpd \
-lgnunetutil \
-lgnunetjson \
-ljansson \
-lpthread
check_PROGRAMS = \
test_taler_exchange_aggregator-postgres
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
$(check_SCRIPTS) \
$(check_PROGRAMS)
EXTRA_DIST = \
test-taler-exchange-aggregator-postgres.conf \
test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \
test_taler_exchange_httpd.conf \
exchange.conf

Some files were not shown because too many files have changed in this diff Show More