aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-09 18:18:59 +0100
committerChristian Grothoff <christian@grothoff.org>2015-01-09 18:18:59 +0100
commit0430d6fb031d1713a39a996068387c3ab2c36c2d (patch)
treedf1e2813dde318f8af2c92fc2367c3956cd58f28
parentf5e49d926ad1dddcfc87b5fb6671a1934aef7b3c (diff)
downloadexchange-0430d6fb031d1713a39a996068387c3ab2c36c2d.tar.gz
exchange-0430d6fb031d1713a39a996068387c3ab2c36c2d.zip
moving structs relevant for signatures into taler_signatures.h, splitting of private keys that are not in messages; moving test_hash_context to GNUnet
-rw-r--r--README14
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile.am2
-rw-r--r--src/include/Makefile.am1
-rw-r--r--src/include/taler_mint_service.h45
-rw-r--r--src/include/taler_signatures.h143
-rw-r--r--src/include/taler_types.h120
-rw-r--r--src/lib/Makefile.am34
-rw-r--r--src/lib/mint_api.c (renamed from src/mint/mint_api.c)3
-rw-r--r--src/lib/test_mint_api.c (renamed from src/mint/test_mint_api.c)4
-rw-r--r--src/mint/Makefile.am44
-rw-r--r--src/mint/mint.h80
-rw-r--r--src/mint/mint_common.c29
-rw-r--r--src/mint/mint_db.h27
-rw-r--r--src/mint/taler-mint-httpd.c1
-rw-r--r--src/mint/taler-mint-httpd_deposit.c1
-rw-r--r--src/mint/taler-mint-httpd_keys.c41
-rw-r--r--src/mint/taler-mint-httpd_keys.h4
-rw-r--r--src/mint/taler-mint-httpd_refresh.c10
-rw-r--r--src/mint/taler-mint-httpd_withdraw.c13
-rw-r--r--src/mint/taler-mint-keycheck.c50
-rw-r--r--src/mint/taler-mint-keyup.c65
-rw-r--r--src/mint/test_mint_common.c10
-rw-r--r--src/util/Makefile.am6
-rw-r--r--src/util/test_hash_context.c48
25 files changed, 392 insertions, 404 deletions
diff --git a/README b/README
index e69de29bb..ab27a88d3 100644
--- a/README
+++ b/README
@@ -0,0 +1,14 @@
1Project structure is currently as follows:
2
3src/include/
4 -- installed headers for public APIs
5
6src/util/
7 -- common utility functions (to be ideally eliminated)
8
9src/mint/
10 -- taler mint server and helper binaries
11
12src/lib/
13 -- libtalermint: C API to issue HTTP requests to mint, including testcases
14
diff --git a/configure.ac b/configure.ac
index 789df8e46..55ee8f11a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,5 +152,6 @@ AC_CONFIG_FILES([Makefile
152 src/include/Makefile 152 src/include/Makefile
153 src/util/Makefile 153 src/util/Makefile
154 src/mint/Makefile 154 src/mint/Makefile
155 src/lib/Makefile
155 ]) 156 ])
156AC_OUTPUT 157AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 485c4f9d7..ed9c9c2bf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,2 +1,2 @@
1AM_CPPFLAGS = -I$(top_srcdir)/src/include 1AM_CPPFLAGS = -I$(top_srcdir)/src/include
2SUBDIRS = include util mint 2SUBDIRS = include util mint lib
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index c95940ea2..ebdf8561d 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -7,5 +7,4 @@ talerinclude_HEADERS = \
7 taler_mint_service.h \ 7 taler_mint_service.h \
8 taler_rsa.h \ 8 taler_rsa.h \
9 taler_signatures.h \ 9 taler_signatures.h \
10 taler_types.h \
11 taler_util.h 10 taler_util.h
diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h
index ee3b30e39..a9d27982f 100644
--- a/src/include/taler_mint_service.h
+++ b/src/include/taler_mint_service.h
@@ -3,23 +3,21 @@
3 (C) 2014 Christian Grothoff (and other contributing authors) 3 (C) 2014 Christian Grothoff (and other contributing authors)
4 4
5 TALER is free software; you can redistribute it and/or modify it under the 5 TALER is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software 6 terms of the GNU Affero General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version. 7 Foundation; either version 3, or (at your option) any later version.
8 8
9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
12 12
13 You should have received a copy of the GNU General Public License along with 13 You should have received a copy of the GNU Affero General Public License along with
14 TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> 14 TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/ 15*/
16
17/** 16/**
18 * @file include/taler_mint_service.h 17 * @file include/taler_mint_service.h
19 * @brief C interface to the mint's HTTP API 18 * @brief C interface of libtalermint, a C library to use mint's HTTP API
20 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 19 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
21 */ 20 */
22
23#ifndef _TALER_MINT_SERVICE_H 21#ifndef _TALER_MINT_SERVICE_H
24#define _TALER_MINT_SERVICE_H 22#define _TALER_MINT_SERVICE_H
25 23
@@ -166,8 +164,9 @@ struct TALER_MINT_KeysGetHandle;
166 * @param emsg if the asynchronous call could not be completed due to an error, 164 * @param emsg if the asynchronous call could not be completed due to an error,
167 * this parameter contains a human readable error message 165 * this parameter contains a human readable error message
168 */ 166 */
169typedef void (*TALER_MINT_ContinuationCallback) (void *cls, 167typedef void
170 const char *emsg); 168(*TALER_MINT_ContinuationCallback) (void *cls,
169 const char *emsg);
171 170
172/** 171/**
173 * Functions of this type are called to provide the retrieved signing and 172 * Functions of this type are called to provide the retrieved signing and
@@ -180,9 +179,10 @@ typedef void (*TALER_MINT_ContinuationCallback) (void *cls,
180 * @param denom_keys NULL-terminated array of pointers to the mint's 179 * @param denom_keys NULL-terminated array of pointers to the mint's
181 * denomination keys; will be NULL if no signing keys are retrieved. 180 * denomination keys; will be NULL if no signing keys are retrieved.
182 */ 181 */
183typedef void (*TALER_MINT_KeysGetCallback) (void *cls, 182typedef void
184 struct TALER_MINT_SigningPublicKey **sign_keys, 183(*TALER_MINT_KeysGetCallback) (void *cls,
185 struct TALER_MINT_DenomPublicKey **denom_keys); 184 struct TALER_MINT_SigningPublicKey **sign_keys,
185 struct TALER_MINT_DenomPublicKey **denom_keys);
186 186
187 187
188/** 188/**
@@ -190,15 +190,18 @@ typedef void (*TALER_MINT_KeysGetCallback) (void *cls,
190 * 190 *
191 * @param mint handle to the mint 191 * @param mint handle to the mint
192 * @param cb the callback to call with the keys 192 * @param cb the callback to call with the keys
193 * @param cls closure for the above callback 193 * @param cb_cls closure for the @a cb callback
194 * @param cont_cb the callback to call after completing this asynchronous call 194 * @param cont_cb the callback to call after completing this asynchronous call
195 * @param cont_cls the closure for the continuation callback 195 * @param cont_cls the closure for the @a cont_cb callback
196 * @return a handle to this asynchronous call; NULL upon eror 196 * @return a handle to this asynchronous call; NULL upon eror
197 */ 197 */
198struct TALER_MINT_KeysGetHandle * 198struct TALER_MINT_KeysGetHandle *
199TALER_MINT_keys_get (struct TALER_MINT_Handle *mint, 199TALER_MINT_keys_get (struct TALER_MINT_Handle *mint,
200 TALER_MINT_KeysGetCallback cb, void *cls, 200 TALER_MINT_KeysGetCallback cb,
201 TALER_MINT_ContinuationCallback cont_cb, void *cont_cls); 201 void *cb_cls,
202 TALER_MINT_ContinuationCallback cont_cb,
203 void *cont_cls);
204
202 205
203/** 206/**
204 * Cancel the asynchronous call initiated by TALER_MINT_keys_get(). This should 207 * Cancel the asynchronous call initiated by TALER_MINT_keys_get(). This should
@@ -229,10 +232,12 @@ struct TALER_MINT_DepositHandle;
229 * @param emsg in case of unsuccessful deposit, this contains a human readable 232 * @param emsg in case of unsuccessful deposit, this contains a human readable
230 * explanation. 233 * explanation.
231 */ 234 */
232typedef void (*TALER_MINT_DepositResultCallback) (void *cls, 235typedef void
233 int status, 236(*TALER_MINT_DepositResultCallback) (void *cls,
234 json_t *obj, 237 int status,
235 char *emsg); 238 json_t *obj,
239 char *emsg);
240
236 241
237/** 242/**
238 * Submit a deposit permission to the mint and get the mint's response 243 * Submit a deposit permission to the mint and get the mint's response
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 8c142f61f..238a915c1 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -13,18 +13,25 @@
13 You should have received a copy of the GNU General Public License along with 13 You should have received a copy of the GNU General Public License along with
14 TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> 14 TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/ 15*/
16
17/** 16/**
18 * @file taler-mint-keyup.c 17 * @file taler_signatures.h
19 * @brief Update the mint's keys for coins and signatures, 18 * @brief message formats and signature constants used to define
20 * using the mint's offline master key. 19 * the binary formats of signatures in Taler
21 * @author Florian Dold 20 * @author Florian Dold
22 * @author Benedikt Mueller 21 * @author Benedikt Mueller
22 *
23 * This file should define the constants and C structs that one
24 * needs to know to implement Taler clients (wallets or merchants)
25 * that need to produce or verify Taler signatures.
23 */ 26 */
24 27
25#ifndef TALER_SIGNATURES_H 28#ifndef TALER_SIGNATURES_H
26#define TALER_SIGNATURES_H 29#define TALER_SIGNATURES_H
27 30
31#include <gnunet/gnunet_util_lib.h>
32#include "taler_rsa.h"
33
34
28/** 35/**
29 * Purpose for signing public keys signed 36 * Purpose for signing public keys signed
30 * by the mint master key. 37 * by the mint master key.
@@ -102,5 +109,133 @@
102 */ 109 */
103#define TALER_SIGNATURE_INCREMENTAL_DEPOSIT 202 110#define TALER_SIGNATURE_INCREMENTAL_DEPOSIT 202
104 111
112
113
114GNUNET_NETWORK_STRUCT_BEGIN
115
116
117/**
118 * Request to withdraw coins from a reserve.
119 */
120struct TALER_WithdrawRequest
121{
122 /**
123 * Signature over the rest of the message
124 * by the withdraw public key.
125 */
126 struct GNUNET_CRYPTO_EddsaSignature sig;
127
128 /**
129 * Purpose must be #TALER_SIGNATURE_WITHDRAW.
130 */
131 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
132
133 /**
134 * Reserve public key.
135 */
136 struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub;
137
138 /**
139 * Denomination public key for the coin that is withdrawn.
140 * FIXME: change to the hash of the public key (so this
141 * is fixed-size).
142 */
143 struct TALER_RSA_PublicKeyBinaryEncoded denomination_pub;
144
145 /**
146 * Purpose containing coin's blinded public key.
147 *
148 * FIXME: this should be explicitly a variable-size field with the
149 * (blinded) message to be signed by the Mint.
150 */
151 struct TALER_RSA_BlindedSignaturePurpose coin_envelope;
152};
153
154
155
156/**
157 * FIXME
158 */
159struct TALER_MINT_SignKeyIssue
160{
161 struct GNUNET_CRYPTO_EddsaSignature signature;
162 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
163 struct GNUNET_CRYPTO_EddsaPublicKey master_pub;
164 struct GNUNET_TIME_AbsoluteNBO start;
165 struct GNUNET_TIME_AbsoluteNBO expire;
166 struct GNUNET_CRYPTO_EddsaPublicKey signkey_pub;
167};
168
169
170/**
171 * FIXME
172 */
173struct TALER_MINT_DenomKeyIssue
174{
175 struct GNUNET_CRYPTO_EddsaSignature signature;
176 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
177 struct GNUNET_CRYPTO_EddsaPublicKey master;
178 struct GNUNET_TIME_AbsoluteNBO start;
179 struct GNUNET_TIME_AbsoluteNBO expire_withdraw;
180 struct GNUNET_TIME_AbsoluteNBO expire_spend;
181 struct TALER_RSA_PublicKeyBinaryEncoded denom_pub;
182 struct TALER_AmountNBO value;
183 struct TALER_AmountNBO fee_withdraw;
184 struct TALER_AmountNBO fee_deposit;
185 struct TALER_AmountNBO fee_refresh;
186};
187
188
189/**
190 * FIXME
191 */
192struct RefreshMeltSignatureBody
193{
194 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
195 struct GNUNET_HashCode melt_hash;
196};
197
198/**
199 * FIXME
200 */
201struct RefreshCommitSignatureBody
202{
203 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
204 struct GNUNET_HashCode commit_hash;
205};
206
207
208/**
209 * FIXME
210 */
211struct RefreshCommitResponseSignatureBody
212{
213 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
214 uint16_t noreveal_index;
215};
216
217
218/**
219 * FIXME
220 */
221struct RefreshMeltResponseSignatureBody
222{
223 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
224 struct GNUNET_HashCode melt_response_hash;
225};
226
227
228/**
229 * FIXME
230 */
231struct RefreshMeltConfirmSignRequestBody
232{
233 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
234 struct GNUNET_CRYPTO_EddsaPublicKey session_pub;
235};
236
237
238GNUNET_NETWORK_STRUCT_END
239
105#endif 240#endif
106 241
diff --git a/src/include/taler_types.h b/src/include/taler_types.h
deleted file mode 100644
index c6c2c0209..000000000
--- a/src/include/taler_types.h
+++ /dev/null
@@ -1,120 +0,0 @@
1/**
2 * @file include/types.h
3 * @brief This files defines the various data and message types in TALER.
4 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
5 * @author Florian Dold
6 */
7
8#ifndef TYPES_H_
9#define TYPES_H_
10
11#include "taler_rsa.h"
12
13
14/**
15 * Public information about a coin.
16 */
17struct TALER_CoinPublicInfo
18{
19 /**
20 * The coin's public key.
21 */
22 struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub;
23
24 /*
25 * The public key signifying the coin's denomination.
26 */
27 struct TALER_RSA_PublicKeyBinaryEncoded denom_pub;
28
29 /**
30 * Signature over coin_pub by denom_pub.
31 */
32 struct TALER_RSA_Signature denom_sig;
33};
34
35
36/**
37 * Request to withdraw coins from a reserve.
38 */
39struct TALER_WithdrawRequest
40{
41 /**
42 * Signature over the rest of the message
43 * by the withdraw public key.
44 */
45 struct GNUNET_CRYPTO_EddsaSignature sig;
46
47 /**
48 * Purpose must be TALER_SIGNATURE_WITHDRAW.
49 */
50 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
51
52 /**
53 * Reserve public key.
54 */
55 struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub;
56
57 /**
58 * Denomination public key for the coin that is withdrawn.
59 */
60 struct TALER_RSA_PublicKeyBinaryEncoded denomination_pub;
61
62 /**
63 * Purpose containing coin's blinded public key.
64 */
65 struct TALER_RSA_BlindedSignaturePurpose coin_envelope;
66};
67
68
69
70/**
71 * Data type for messages
72 */
73struct TALER_MessageHeader
74{
75 /**
76 * The type of the message in Network-byte order (NBO)
77 */
78 uint16_t type;
79
80 /**
81 * The size of the message in NBO
82 */
83 uint16_t size;
84};
85
86/*****************/
87/* Message types */
88/*****************/
89
90/**
91 * The message type of a blind signature
92 */
93#define TALER_MSG_TYPE_BLINDED_SIGNATURE 1
94
95/**
96 * The message type of a blinded message
97 */
98#define TALER_MSG_TYPE_BLINDED_MESSAGE 2
99
100/**
101 * The message type of an unblinded signature
102 * @FIXME: Not currently used
103 */
104#define TALER_MSG_TYPE_UNBLINDED_SIGNATURE 3
105
106/**
107 * The type of a blinding residue message
108 * @FIXME: Not currently used
109 */
110#define TALER_MSG_TYPE_BLINDING_RESIDUE 4
111
112/**
113 * The type of a message containing the blinding factor
114 */
115#define TALER_MSG_TYPE_BLINDING_FACTOR 5
116
117
118#endif /* TYPES_H_ */
119
120/* end of include/types.h */
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
new file mode 100644
index 000000000..5c740fe29
--- /dev/null
+++ b/src/lib/Makefile.am
@@ -0,0 +1,34 @@
1AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS)
2
3lib_LTLIBRARIES = \
4 libtalermint.la
5
6libtalermint_la_LDFLAGS = \
7 $(POSTGRESQL_LDFLAGS) \
8 -version-info 0:0:0 \
9 -no-undefined
10
11libtalermint_la_SOURCES = \
12 mint_api.c
13
14libtalermint_la_LIBADD = \
15 -lgnunetutil \
16 -ljansson \
17 -lcurl
18
19libtalermint_la_LDFLAGS = \
20 -version-info 0:0:0 \
21 -no-undefined
22
23check_PROGRAMS = \
24 test_mint_api
25
26test_mint_api_SOURCES = \
27 test_mint_api.c
28test_mint_api_LDADD = \
29 libtalermint.la \
30 $(LIBGCRYPT_LIBS) \
31 $(top_builddir)/src/util/libtalerutil.la \
32 -lgnunetutil \
33 -ljansson
34
diff --git a/src/mint/mint_api.c b/src/lib/mint_api.c
index b8d42b274..10f4e48b4 100644
--- a/src/mint/mint_api.c
+++ b/src/lib/mint_api.c
@@ -20,14 +20,13 @@
20 * @brief Implementation of the client interface to mint's HTTP API 20 * @brief Implementation of the client interface to mint's HTTP API
21 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 21 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
22 */ 22 */
23
24#include "platform.h" 23#include "platform.h"
25#include <curl/curl.h> 24#include <curl/curl.h>
26#include <jansson.h> 25#include <jansson.h>
27#include <gnunet/gnunet_util_lib.h> 26#include <gnunet/gnunet_util_lib.h>
28#include "taler_mint_service.h" 27#include "taler_mint_service.h"
29#include "taler_signatures.h" 28#include "taler_signatures.h"
30#include "mint.h" 29
31 30
32#define CURL_STRERROR(TYPE, FUNCTION, CODE) \ 31#define CURL_STRERROR(TYPE, FUNCTION, CODE) \
33 GNUNET_log (TYPE, "cURL function `%s' has failed at `%s:%d' with error: %s", \ 32 GNUNET_log (TYPE, "cURL function `%s' has failed at `%s:%d' with error: %s", \
diff --git a/src/mint/test_mint_api.c b/src/lib/test_mint_api.c
index 965d607f5..8eb2761dc 100644
--- a/src/mint/test_mint_api.c
+++ b/src/lib/test_mint_api.c
@@ -32,7 +32,7 @@ struct TALER_MINT_KeysGetHandle *dkey_get;
32 32
33struct TALER_MINT_DepositHandle *dh; 33struct TALER_MINT_DepositHandle *dh;
34 34
35static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; 35static struct GNUNET_SCHEDULER_Task *shutdown_task;
36 36
37static int result; 37static int result;
38 38
@@ -40,7 +40,7 @@ static int result;
40static void 40static void
41do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 41do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
42{ 42{
43 shutdown_task = GNUNET_SCHEDULER_NO_TASK; 43 shutdown_task = NULL;
44 if (NULL != dkey_get) 44 if (NULL != dkey_get)
45 TALER_MINT_keys_get_cancel (dkey_get); 45 TALER_MINT_keys_get_cancel (dkey_get);
46 dkey_get = NULL; 46 dkey_get = NULL;
diff --git a/src/mint/Makefile.am b/src/mint/Makefile.am
index d0a58812e..eff126a07 100644
--- a/src/mint/Makefile.am
+++ b/src/mint/Makefile.am
@@ -1,35 +1,22 @@
1AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS) 1AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS)
2 2
3lib_LTLIBRARIES = \ 3lib_LTLIBRARIES = \
4 libtalermint.la \ 4 libtalermint_common.la
5 libtalermintapi.la
6 5
7libtalermint_la_SOURCES = \ 6libtalermint_common_la_SOURCES = \
8 mint_common.c \ 7 mint_common.c \
9 mint_db.c 8 mint_db.c
10 9
11libtalermint_la_LIBADD = \ 10libtalermint_common_la_LIBADD = \
12 $(top_builddir)/src/util/libtalerutil.la \ 11 $(top_builddir)/src/util/libtalerutil.la \
13 -lgnunetutil \ 12 -lgnunetutil \
14 -lpq 13 -lpq
15 14
16libtalermint_la_LDFLAGS = \ 15libtalermint_common_la_LDFLAGS = \
17 $(POSTGRESQL_LDFLAGS) \ 16 $(POSTGRESQL_LDFLAGS) \
18 -version-info 0:0:0 \ 17 -version-info 0:0:0 \
19 -no-undefined 18 -no-undefined
20 19
21libtalermintapi_la_SOURCES = \
22 mint_api.c
23
24libtalermintapi_la_LIBADD = \
25 -lgnunetutil \
26 -ljansson \
27 -lcurl
28
29libtalermintapi_la_LDFLAGS = \
30 -version-info 0:0:0 \
31 -no-undefined
32
33 20
34bin_PROGRAMS = \ 21bin_PROGRAMS = \
35 taler-mint-keyup \ 22 taler-mint-keyup \
@@ -44,7 +31,7 @@ taler_mint_keyup_SOURCES = \
44taler_mint_keyup_LDADD = \ 31taler_mint_keyup_LDADD = \
45 $(LIBGCRYPT_LIBS) \ 32 $(LIBGCRYPT_LIBS) \
46 $(top_builddir)/src/util/libtalerutil.la \ 33 $(top_builddir)/src/util/libtalerutil.la \
47 $(top_builddir)/src/mint/libtalermint.la \ 34 $(top_builddir)/src/mint/libtalermint_common.la \
48 -lpq \ 35 -lpq \
49 -lgnunetutil 36 -lgnunetutil
50taler_mint_keyup_LDFLAGS = $(POSTGRESQL_LDFLAGS) 37taler_mint_keyup_LDFLAGS = $(POSTGRESQL_LDFLAGS)
@@ -56,7 +43,7 @@ taler_mint_keycheck_SOURCES = \
56taler_mint_keycheck_LDADD = \ 43taler_mint_keycheck_LDADD = \
57 $(LIBGCRYPT_LIBS) \ 44 $(LIBGCRYPT_LIBS) \
58 $(top_builddir)/src/util/libtalerutil.la \ 45 $(top_builddir)/src/util/libtalerutil.la \
59 $(top_builddir)/src/mint/libtalermint.la \ 46 $(top_builddir)/src/mint/libtalermint_common.la \
60 -lgnunetutil \ 47 -lgnunetutil \
61 -lpq 48 -lpq
62taler_mint_keycheck_LDFLAGS = $(POSTGRESQL_LDFLAGS) 49taler_mint_keycheck_LDFLAGS = $(POSTGRESQL_LDFLAGS)
@@ -66,7 +53,7 @@ taler_mint_reservemod_SOURCES = \
66taler_mint_reservemod_LDADD = \ 53taler_mint_reservemod_LDADD = \
67 $(LIBGCRYPT_LIBS) \ 54 $(LIBGCRYPT_LIBS) \
68 $(top_builddir)/src/util/libtalerutil.la \ 55 $(top_builddir)/src/util/libtalerutil.la \
69 $(top_builddir)/src/mint/libtalermint.la \ 56 $(top_builddir)/src/mint/libtalermint_common.la \
70 -lpq \ 57 -lpq \
71 -lgnunetutil 58 -lgnunetutil
72taler_mint_reservemod_LDFLAGS = \ 59taler_mint_reservemod_LDFLAGS = \
@@ -83,7 +70,7 @@ taler_mint_httpd_SOURCES = \
83taler_mint_httpd_LDADD = \ 70taler_mint_httpd_LDADD = \
84 $(LIBGCRYPT_LIBS) \ 71 $(LIBGCRYPT_LIBS) \
85 $(top_builddir)/src/util/libtalerutil.la \ 72 $(top_builddir)/src/util/libtalerutil.la \
86 $(top_builddir)/src/mint/libtalermint.la \ 73 $(top_builddir)/src/mint/libtalermint_common.la \
87 -lpq \ 74 -lpq \
88 -lmicrohttpd \ 75 -lmicrohttpd \
89 -ljansson \ 76 -ljansson \
@@ -98,28 +85,19 @@ taler_mint_dbinit_SOURCES = \
98taler_mint_dbinit_LDADD = \ 85taler_mint_dbinit_LDADD = \
99 $(LIBGCRYPT_LIBS) \ 86 $(LIBGCRYPT_LIBS) \
100 $(top_builddir)/src/util/libtalerutil.la \ 87 $(top_builddir)/src/util/libtalerutil.la \
101 $(top_builddir)/src/mint/libtalermint.la \ 88 $(top_builddir)/src/mint/libtalermint_common.la \
102 -lpq \ 89 -lpq \
103 -lgnunetutil 90 -lgnunetutil
104taler_mint_dbinit_LDFLAGS = $(POSTGRESQL_LDFLAGS) 91taler_mint_dbinit_LDFLAGS = $(POSTGRESQL_LDFLAGS)
105 92
106check_PROGRAMS = \ 93check_PROGRAMS = \
107 test-mint-api \
108 test-mint-deposits \ 94 test-mint-deposits \
109 test-mint-common 95 test-mint-common
110 96
111test_mint_api_SOURCES = test_mint_api.c
112test_mint_api_LDADD = \
113 libtalermintapi.la \
114 $(LIBGCRYPT_LIBS) \
115 $(top_builddir)/src/util/libtalerutil.la \
116 -lgnunetutil \
117 -ljansson
118
119test_mint_deposits_SOURCES = \ 97test_mint_deposits_SOURCES = \
120 test_mint_deposits.c 98 test_mint_deposits.c
121test_mint_deposits_LDADD = \ 99test_mint_deposits_LDADD = \
122 libtalermint.la \ 100 libtalermint_common.la \
123 $(top_srcdir)/src/util/libtalerutil.la \ 101 $(top_srcdir)/src/util/libtalerutil.la \
124 -lgnunetutil \ 102 -lgnunetutil \
125 -lpq 103 -lpq
@@ -127,6 +105,6 @@ test_mint_deposits_LDADD = \
127test_mint_common_SOURCES = \ 105test_mint_common_SOURCES = \
128 test_mint_common.c 106 test_mint_common.c
129test_mint_common_LDADD = \ 107test_mint_common_LDADD = \
130 libtalermint.la \ 108 libtalermint_common.la \
131 $(top_srcdir)/src/util/libtalerutil.la \ 109 $(top_srcdir)/src/util/libtalerutil.la \
132 -lgnunetutil 110 -lgnunetutil
diff --git a/src/mint/mint.h b/src/mint/mint.h
index 5adce03c6..644a9d292 100644
--- a/src/mint/mint.h
+++ b/src/mint/mint.h
@@ -29,81 +29,37 @@
29#include <libpq-fe.h> 29#include <libpq-fe.h>
30#include "taler_util.h" 30#include "taler_util.h"
31#include "taler_rsa.h" 31#include "taler_rsa.h"
32#include "taler_signatures.h"
32 33
33#define DIR_SIGNKEYS "signkeys" 34#define DIR_SIGNKEYS "signkeys"
34#define DIR_DENOMKEYS "denomkeys" 35#define DIR_DENOMKEYS "denomkeys"
35 36
36 37
37GNUNET_NETWORK_STRUCT_BEGIN
38
39
40/** 38/**
41 * FIXME 39 * On disk format used for a mint signing key.
40 * Includes the private key followed by the signed
41 * issue message.
42 */ 42 */
43struct TALER_MINT_SignKeyIssue 43struct TALER_MINT_SignKeyIssuePriv
44{ 44{
45 struct GNUNET_CRYPTO_EddsaPrivateKey signkey_priv; 45 struct GNUNET_CRYPTO_EddsaPrivateKey signkey_priv;
46 struct GNUNET_CRYPTO_EddsaSignature signature; 46 struct TALER_MINT_SignKeyIssue issue;
47 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
48 struct GNUNET_CRYPTO_EddsaPublicKey master_pub;
49 struct GNUNET_TIME_AbsoluteNBO start;
50 struct GNUNET_TIME_AbsoluteNBO expire;
51 struct GNUNET_CRYPTO_EddsaPublicKey signkey_pub;
52}; 47};
53 48
54struct TALER_MINT_DenomKeyIssue 49
50
51struct TALER_MINT_DenomKeyIssuePriv
55{ 52{
56 /** 53 /**
57 * The private key of the denomination. Will be NULL if the private key is 54 * The private key of the denomination. Will be NULL if the private key is
58 * not available. 55 * not available.
59 */ 56 */
60 struct TALER_RSA_PrivateKey *denom_priv; 57 struct TALER_RSA_PrivateKey *denom_priv;
61 struct GNUNET_CRYPTO_EddsaSignature signature; 58 struct TALER_MINT_DenomKeyIssue issue;
62 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
63 struct GNUNET_CRYPTO_EddsaPublicKey master;
64 struct GNUNET_TIME_AbsoluteNBO start;
65 struct GNUNET_TIME_AbsoluteNBO expire_withdraw;
66 struct GNUNET_TIME_AbsoluteNBO expire_spend;
67 struct TALER_RSA_PublicKeyBinaryEncoded denom_pub;
68 struct TALER_AmountNBO value;
69 struct TALER_AmountNBO fee_withdraw;
70 struct TALER_AmountNBO fee_deposit;
71 struct TALER_AmountNBO fee_refresh;
72};
73
74struct RefreshMeltSignatureBody
75{
76 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
77 struct GNUNET_HashCode melt_hash;
78};
79
80struct RefreshCommitSignatureBody
81{
82 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
83 struct GNUNET_HashCode commit_hash;
84};
85
86struct RefreshCommitResponseSignatureBody
87{
88 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
89 uint16_t noreveal_index;
90};
91
92struct RefreshMeltResponseSignatureBody
93{
94 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
95 struct GNUNET_HashCode melt_response_hash;
96}; 59};
97 60
98 61
99struct RefreshMeltConfirmSignRequestBody
100{
101 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
102 struct GNUNET_CRYPTO_EddsaPublicKey session_pub;
103};
104
105 62
106GNUNET_NETWORK_STRUCT_END
107 63
108 64
109 65
@@ -116,8 +72,9 @@ GNUNET_NETWORK_STRUCT_END
116 * #GNUNET_NO to stop iteration with no error, 72 * #GNUNET_NO to stop iteration with no error,
117 * #GNUNET_SYSERR to abort iteration with error! 73 * #GNUNET_SYSERR to abort iteration with error!
118 */ 74 */
119typedef int (*TALER_MINT_SignkeyIterator)(void *cls, 75typedef int
120 const struct TALER_MINT_SignKeyIssue *ski); 76(*TALER_MINT_SignkeyIterator)(void *cls,
77 const struct TALER_MINT_SignKeyIssuePriv *ski);
121 78
122/** 79/**
123 * Iterator for denomination keys. 80 * Iterator for denomination keys.
@@ -129,9 +86,10 @@ typedef int (*TALER_MINT_SignkeyIterator)(void *cls,
129 * #GNUNET_NO to stop iteration with no error, 86 * #GNUNET_NO to stop iteration with no error,
130 * #GNUNET_SYSERR to abort iteration with error! 87 * #GNUNET_SYSERR to abort iteration with error!
131 */ 88 */
132typedef int (*TALER_MINT_DenomkeyIterator)(void *cls, 89typedef int
133 const char *alias, 90(*TALER_MINT_DenomkeyIterator)(void *cls,
134 const struct TALER_MINT_DenomKeyIssue *dki); 91 const char *alias,
92 const struct TALER_MINT_DenomKeyIssuePriv *dki);
135 93
136 94
137 95
@@ -160,7 +118,7 @@ TALER_MINT_denomkeys_iterate (const char *mint_base_dir,
160 */ 118 */
161int 119int
162TALER_MINT_write_denom_key (const char *filename, 120TALER_MINT_write_denom_key (const char *filename,
163 const struct TALER_MINT_DenomKeyIssue *dki); 121 const struct TALER_MINT_DenomKeyIssuePriv *dki);
164 122
165 123
166/** 124/**
@@ -172,7 +130,7 @@ TALER_MINT_write_denom_key (const char *filename,
172 */ 130 */
173int 131int
174TALER_MINT_read_denom_key (const char *filename, 132TALER_MINT_read_denom_key (const char *filename,
175 struct TALER_MINT_DenomKeyIssue *dki); 133 struct TALER_MINT_DenomKeyIssuePriv *dki);
176 134
177 135
178/** 136/**
diff --git a/src/mint/mint_common.c b/src/mint/mint_common.c
index 4afbf072b..734085e7b 100644
--- a/src/mint/mint_common.c
+++ b/src/mint/mint_common.c
@@ -47,11 +47,12 @@ signkeys_iterate_dir_iter (void *cls,
47 47
48 struct SignkeysIterateContext *skc = cls; 48 struct SignkeysIterateContext *skc = cls;
49 ssize_t nread; 49 ssize_t nread;
50 struct TALER_MINT_SignKeyIssue issue; 50 struct TALER_MINT_SignKeyIssuePriv issue;
51
51 nread = GNUNET_DISK_fn_read (filename, 52 nread = GNUNET_DISK_fn_read (filename,
52 &issue, 53 &issue,
53 sizeof (struct TALER_MINT_SignKeyIssue)); 54 sizeof (struct TALER_MINT_SignKeyIssuePriv));
54 if (nread != sizeof (struct TALER_MINT_SignKeyIssue)) 55 if (nread != sizeof (struct TALER_MINT_SignKeyIssuePriv))
55 { 56 {
56 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid signkey file: '%s'\n", filename); 57 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid signkey file: '%s'\n", filename);
57 return GNUNET_OK; 58 return GNUNET_OK;
@@ -87,7 +88,7 @@ TALER_MINT_signkeys_iterate (const char *mint_base_dir,
87 */ 88 */
88int 89int
89TALER_MINT_read_denom_key (const char *filename, 90TALER_MINT_read_denom_key (const char *filename,
90 struct TALER_MINT_DenomKeyIssue *dki) 91 struct TALER_MINT_DenomKeyIssuePriv *dki)
91{ 92{
92 uint64_t size; 93 uint64_t size;
93 size_t offset; 94 size_t offset;
@@ -97,8 +98,8 @@ TALER_MINT_read_denom_key (const char *filename,
97 98
98 ret = GNUNET_SYSERR; 99 ret = GNUNET_SYSERR;
99 data = NULL; 100 data = NULL;
100 offset = sizeof (struct TALER_MINT_DenomKeyIssue) 101 offset = sizeof (struct TALER_MINT_DenomKeyIssuePriv)
101 - offsetof (struct TALER_MINT_DenomKeyIssue, signature); 102 - offsetof (struct TALER_MINT_DenomKeyIssuePriv, issue.signature);
102 if (GNUNET_OK != GNUNET_DISK_file_size (filename, 103 if (GNUNET_OK != GNUNET_DISK_file_size (filename,
103 &size, 104 &size,
104 GNUNET_YES, 105 GNUNET_YES,
@@ -117,7 +118,7 @@ TALER_MINT_read_denom_key (const char *filename,
117 if (NULL == (priv = TALER_RSA_decode_key (data + offset, size - offset))) 118 if (NULL == (priv = TALER_RSA_decode_key (data + offset, size - offset)))
118 goto cleanup; 119 goto cleanup;
119 dki->denom_priv = priv; 120 dki->denom_priv = priv;
120 (void) memcpy (&dki->signature, data, offset); 121 memcpy (&dki->issue.signature, data, offset);
121 ret = GNUNET_OK; 122 ret = GNUNET_OK;
122 123
123 cleanup: 124 cleanup:
@@ -135,7 +136,7 @@ TALER_MINT_read_denom_key (const char *filename,
135 */ 136 */
136int 137int
137TALER_MINT_write_denom_key (const char *filename, 138TALER_MINT_write_denom_key (const char *filename,
138 const struct TALER_MINT_DenomKeyIssue *dki) 139 const struct TALER_MINT_DenomKeyIssuePriv *dki)
139{ 140{
140 struct TALER_RSA_PrivateKeyBinaryEncoded *priv_enc; 141 struct TALER_RSA_PrivateKeyBinaryEncoded *priv_enc;
141 struct GNUNET_DISK_FileHandle *fh; 142 struct GNUNET_DISK_FileHandle *fh;
@@ -153,10 +154,10 @@ TALER_MINT_write_denom_key (const char *filename,
153 goto cleanup; 154 goto cleanup;
154 if (NULL == (priv_enc = TALER_RSA_encode_key (dki->denom_priv))) 155 if (NULL == (priv_enc = TALER_RSA_encode_key (dki->denom_priv)))
155 goto cleanup; 156 goto cleanup;
156 wsize = sizeof (struct TALER_MINT_DenomKeyIssue) 157 wsize = sizeof (struct TALER_MINT_DenomKeyIssuePriv)
157 - offsetof (struct TALER_MINT_DenomKeyIssue, signature); 158 - offsetof (struct TALER_MINT_DenomKeyIssuePriv, issue.signature);
158 if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, 159 if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
159 &dki->signature, 160 &dki->issue.signature,
160 wsize))) 161 wsize)))
161 goto cleanup; 162 goto cleanup;
162 if (wrote != wsize) 163 if (wrote != wsize)
@@ -183,11 +184,13 @@ denomkeys_iterate_keydir_iter (void *cls,
183{ 184{
184 185
185 struct DenomkeysIterateContext *dic = cls; 186 struct DenomkeysIterateContext *dic = cls;
186 struct TALER_MINT_DenomKeyIssue issue; 187 struct TALER_MINT_DenomKeyIssuePriv issue;
187 188
188 if (GNUNET_OK != TALER_MINT_read_denom_key (filename, &issue)) 189 if (GNUNET_OK != TALER_MINT_read_denom_key (filename, &issue))
189 { 190 {
190 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid denomkey file: '%s'\n", filename); 191 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
192 "Invalid denomkey file: '%s'\n",
193 filename);
191 return GNUNET_OK; 194 return GNUNET_OK;
192 } 195 }
193 return dic->it (dic->it_cls, dic->alias, &issue); 196 return dic->it (dic->it_cls, dic->alias, &issue);
diff --git a/src/mint/mint_db.h b/src/mint/mint_db.h
index 4f47aac1c..eb7a105cb 100644
--- a/src/mint/mint_db.h
+++ b/src/mint/mint_db.h
@@ -26,11 +26,36 @@
26#include <libpq-fe.h> 26#include <libpq-fe.h>
27#include <gnunet/gnunet_util_lib.h> 27#include <gnunet/gnunet_util_lib.h>
28#include "taler_util.h" 28#include "taler_util.h"
29#include "taler_types.h"
30#include "taler_rsa.h" 29#include "taler_rsa.h"
31 30
32 31
33/** 32/**
33 * Public information about a coin.
34 */
35struct TALER_CoinPublicInfo
36{
37 /**
38 * The coin's public key.
39 */
40 struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub;
41
42 /*
43 * The public key signifying the coin's denomination.
44 */
45 struct TALER_RSA_PublicKeyBinaryEncoded denom_pub;
46
47 /**
48 * Signature over coin_pub by denom_pub.
49 */
50 struct TALER_RSA_Signature denom_sig;
51};
52
53
54
55
56
57
58/**
34 * Reserve row. Corresponds to table 'reserves' in 59 * Reserve row. Corresponds to table 'reserves' in
35 * the mint's database. 60 * the mint's database.
36 */ 61 */
diff --git a/src/mint/taler-mint-httpd.c b/src/mint/taler-mint-httpd.c
index 1734e61ef..14dfa657c 100644
--- a/src/mint/taler-mint-httpd.c
+++ b/src/mint/taler-mint-httpd.c
@@ -29,7 +29,6 @@
29#include <pthread.h> 29#include <pthread.h>
30#include "mint.h" 30#include "mint.h"
31#include "mint_db.h" 31#include "mint_db.h"
32#include "taler_types.h"
33#include "taler_signatures.h" 32#include "taler_signatures.h"
34#include "taler_rsa.h" 33#include "taler_rsa.h"
35#include "taler_json_lib.h" 34#include "taler_json_lib.h"
diff --git a/src/mint/taler-mint-httpd_deposit.c b/src/mint/taler-mint-httpd_deposit.c
index 2f6c3bc8f..b8bcc87db 100644
--- a/src/mint/taler-mint-httpd_deposit.c
+++ b/src/mint/taler-mint-httpd_deposit.c
@@ -28,7 +28,6 @@
28#include <pthread.h> 28#include <pthread.h>
29#include "mint.h" 29#include "mint.h"
30#include "mint_db.h" 30#include "mint_db.h"
31#include "taler_types.h"
32#include "taler_signatures.h" 31#include "taler_signatures.h"
33#include "taler_rsa.h" 32#include "taler_rsa.h"
34#include "taler_json_lib.h" 33#include "taler_json_lib.h"
diff --git a/src/mint/taler-mint-httpd_keys.c b/src/mint/taler-mint-httpd_keys.c
index ce8bdf6e0..6d6e9468d 100644
--- a/src/mint/taler-mint-httpd_keys.c
+++ b/src/mint/taler-mint-httpd_keys.c
@@ -28,7 +28,6 @@
28#include <pthread.h> 28#include <pthread.h>
29#include "mint.h" 29#include "mint.h"
30#include "mint_db.h" 30#include "mint_db.h"
31#include "taler_types.h"
32#include "taler_signatures.h" 31#include "taler_signatures.h"
33#include "taler_rsa.h" 32#include "taler_rsa.h"
34#include "taler_json_lib.h" 33#include "taler_json_lib.h"
@@ -145,7 +144,7 @@ TALER_MINT_conf_duration_provide ()
145static int 144static int
146reload_keys_denom_iter (void *cls, 145reload_keys_denom_iter (void *cls,
147 const char *alias, 146 const char *alias,
148 const struct TALER_MINT_DenomKeyIssue *dki) 147 const struct TALER_MINT_DenomKeyIssuePriv *dki)
149{ 148{
150 struct MintKeyState *ctx = cls; 149 struct MintKeyState *ctx = cls;
151 struct GNUNET_TIME_Absolute stamp_provide; 150 struct GNUNET_TIME_Absolute stamp_provide;
@@ -155,28 +154,30 @@ reload_keys_denom_iter (void *cls,
155 stamp_provide = GNUNET_TIME_absolute_add (ctx->reload_time, 154 stamp_provide = GNUNET_TIME_absolute_add (ctx->reload_time,
156 TALER_MINT_conf_duration_provide ()); 155 TALER_MINT_conf_duration_provide ());
157 156
158 if (GNUNET_TIME_absolute_ntoh (dki->expire_spend).abs_value_us < ctx->reload_time.abs_value_us) 157 if (GNUNET_TIME_absolute_ntoh (dki->issue.expire_spend).abs_value_us < ctx->reload_time.abs_value_us)
159 { 158 {
160 // this key is expired 159 // this key is expired
161 return GNUNET_OK; 160 return GNUNET_OK;
162 } 161 }
163 if (GNUNET_TIME_absolute_ntoh (dki->start).abs_value_us > stamp_provide.abs_value_us) 162 if (GNUNET_TIME_absolute_ntoh (dki->issue.start).abs_value_us > stamp_provide.abs_value_us)
164 { 163 {
165 // we are to early for this key 164 // we are to early for this key
166 return GNUNET_OK; 165 return GNUNET_OK;
167 } 166 }
168 167
169 GNUNET_CRYPTO_hash (&dki->denom_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey), &denom_key_hash); 168 GNUNET_CRYPTO_hash (&dki->issue.denom_pub,
169 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey),
170 &denom_key_hash);
170 171
171 res = GNUNET_CONTAINER_multihashmap_put (ctx->denomkey_map, 172 res = GNUNET_CONTAINER_multihashmap_put (ctx->denomkey_map,
172 &denom_key_hash, 173 &denom_key_hash,
173 GNUNET_memdup (dki, sizeof (struct TALER_MINT_DenomKeyIssue)), 174 GNUNET_memdup (dki, sizeof (struct TALER_MINT_DenomKeyIssuePriv)),
174 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 175 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
175 if (GNUNET_OK != res) 176 if (GNUNET_OK != res)
176 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Duplicate denomination key\n"); 177 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Duplicate denomination key\n");
177 178
178 json_array_append_new (ctx->denom_keys_array, 179 json_array_append_new (ctx->denom_keys_array,
179 denom_key_issue_to_json (dki)); 180 denom_key_issue_to_json (&dki->issue));
180 181
181 return GNUNET_OK; 182 return GNUNET_OK;
182} 183}
@@ -193,20 +194,20 @@ reload_keys_denom_iter (void *cls,
193 */ 194 */
194static int 195static int
195reload_keys_sign_iter (void *cls, 196reload_keys_sign_iter (void *cls,
196 const struct TALER_MINT_SignKeyIssue *ski) 197 const struct TALER_MINT_SignKeyIssuePriv *ski)
197{ 198{
198 struct MintKeyState *ctx = cls; 199 struct MintKeyState *ctx = cls;
199 struct GNUNET_TIME_Absolute stamp_provide; 200 struct GNUNET_TIME_Absolute stamp_provide;
200 201
201 stamp_provide = GNUNET_TIME_absolute_add (ctx->reload_time, TALER_MINT_conf_duration_provide (cfg)); 202 stamp_provide = GNUNET_TIME_absolute_add (ctx->reload_time, TALER_MINT_conf_duration_provide (cfg));
202 203
203 if (GNUNET_TIME_absolute_ntoh (ski->expire).abs_value_us < ctx->reload_time.abs_value_us) 204 if (GNUNET_TIME_absolute_ntoh (ski->issue.expire).abs_value_us < ctx->reload_time.abs_value_us)
204 { 205 {
205 // this key is expired 206 // this key is expired
206 return GNUNET_OK; 207 return GNUNET_OK;
207 } 208 }
208 209
209 if (GNUNET_TIME_absolute_ntoh (ski->start).abs_value_us > stamp_provide.abs_value_us) 210 if (GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us > stamp_provide.abs_value_us)
210 { 211 {
211 // we are to early for this key 212 // we are to early for this key
212 return GNUNET_OK; 213 return GNUNET_OK;
@@ -214,16 +215,16 @@ reload_keys_sign_iter (void *cls,
214 215
215 // the signkey is valid for now, check 216 // the signkey is valid for now, check
216 // if it's more recent than the current one! 217 // if it's more recent than the current one!
217 if (GNUNET_TIME_absolute_ntoh (ctx->current_sign_key_issue.start).abs_value_us > 218 if (GNUNET_TIME_absolute_ntoh (ctx->current_sign_key_issue.issue.start).abs_value_us >
218 GNUNET_TIME_absolute_ntoh (ski->start).abs_value_us) 219 GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us)
219 ctx->current_sign_key_issue = *ski; 220 ctx->current_sign_key_issue = *ski;
220 221
221 222
222 ctx->next_reload = GNUNET_TIME_absolute_min (ctx->next_reload, 223 ctx->next_reload = GNUNET_TIME_absolute_min (ctx->next_reload,
223 GNUNET_TIME_absolute_ntoh (ski->expire)); 224 GNUNET_TIME_absolute_ntoh (ski->issue.expire));
224 225
225 json_array_append_new (ctx->sign_keys_array, 226 json_array_append_new (ctx->sign_keys_array,
226 sign_key_issue_to_json (ski)); 227 sign_key_issue_to_json (&ski->issue));
227 228
228 return GNUNET_OK; 229 return GNUNET_OK;
229} 230}
@@ -334,14 +335,16 @@ TALER_MINT_key_state_acquire (void)
334 * @return the denomination key issue, 335 * @return the denomination key issue,
335 * or NULL if denom_pub could not be found 336 * or NULL if denom_pub could not be found
336 */ 337 */
337struct TALER_MINT_DenomKeyIssue * 338struct TALER_MINT_DenomKeyIssuePriv *
338TALER_MINT_get_denom_key (const struct MintKeyState *key_state, 339TALER_MINT_get_denom_key (const struct MintKeyState *key_state,
339 const struct TALER_RSA_PublicKeyBinaryEncoded *denom_pub) 340 const struct TALER_RSA_PublicKeyBinaryEncoded *denom_pub)
340{ 341{
341 struct TALER_MINT_DenomKeyIssue *issue; 342 struct TALER_MINT_DenomKeyIssuePriv *issue;
342 struct GNUNET_HashCode hash; 343 struct GNUNET_HashCode hash;
343 344
344 GNUNET_CRYPTO_hash (denom_pub, sizeof (struct TALER_RSA_PublicKeyBinaryEncoded), &hash); 345 GNUNET_CRYPTO_hash (denom_pub,
346 sizeof (struct TALER_RSA_PublicKeyBinaryEncoded),
347 &hash);
345 issue = GNUNET_CONTAINER_multihashmap_get (key_state->denomkey_map, &hash); 348 issue = GNUNET_CONTAINER_multihashmap_get (key_state->denomkey_map, &hash);
346 return issue; 349 return issue;
347} 350}
@@ -361,7 +364,7 @@ int
361TALER_MINT_test_coin_valid (const struct MintKeyState *key_state, 364TALER_MINT_test_coin_valid (const struct MintKeyState *key_state,
362 struct TALER_CoinPublicInfo *coin_public_info) 365 struct TALER_CoinPublicInfo *coin_public_info)
363{ 366{
364 struct TALER_MINT_DenomKeyIssue *dki; 367 struct TALER_MINT_DenomKeyIssuePriv *dki;
365 368
366 dki = TALER_MINT_get_denom_key (key_state, &coin_public_info->denom_pub); 369 dki = TALER_MINT_get_denom_key (key_state, &coin_public_info->denom_pub);
367 if (NULL == dki) 370 if (NULL == dki)
@@ -369,7 +372,7 @@ TALER_MINT_test_coin_valid (const struct MintKeyState *key_state,
369 if (GNUNET_OK != TALER_RSA_verify (&coin_public_info->coin_pub, 372 if (GNUNET_OK != TALER_RSA_verify (&coin_public_info->coin_pub,
370 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), 373 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
371 &coin_public_info->denom_sig, 374 &coin_public_info->denom_sig,
372 &dki->denom_pub)) 375 &dki->issue.denom_pub))
373 { 376 {
374 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 377 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
375 "coin signature is invalid\n"); 378 "coin signature is invalid\n");
diff --git a/src/mint/taler-mint-httpd_keys.h b/src/mint/taler-mint-httpd_keys.h
index 640a9c916..4fd3d0bdd 100644
--- a/src/mint/taler-mint-httpd_keys.h
+++ b/src/mint/taler-mint-httpd_keys.h
@@ -62,7 +62,7 @@ struct MintKeyState
62 /** 62 /**
63 * Mint signing key that should be used currently. 63 * Mint signing key that should be used currently.
64 */ 64 */
65 struct TALER_MINT_SignKeyIssue current_sign_key_issue; 65 struct TALER_MINT_SignKeyIssuePriv current_sign_key_issue;
66 66
67 /** 67 /**
68 * Cached JSON text that the mint will send for 68 * Cached JSON text that the mint will send for
@@ -105,7 +105,7 @@ TALER_MINT_key_state_acquire (void);
105 * @return the denomination key issue, 105 * @return the denomination key issue,
106 * or NULL if denom_pub could not be found 106 * or NULL if denom_pub could not be found
107 */ 107 */
108struct TALER_MINT_DenomKeyIssue * 108struct TALER_MINT_DenomKeyIssuePriv *
109TALER_MINT_get_denom_key (const struct MintKeyState *key_state, 109TALER_MINT_get_denom_key (const struct MintKeyState *key_state,
110 const struct TALER_RSA_PublicKeyBinaryEncoded *denom_pub); 110 const struct TALER_RSA_PublicKeyBinaryEncoded *denom_pub);
111 111
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c
index 5a9cf1eac..888e7de3b 100644
--- a/src/mint/taler-mint-httpd_refresh.c
+++ b/src/mint/taler-mint-httpd_refresh.c
@@ -28,7 +28,6 @@
28#include <pthread.h> 28#include <pthread.h>
29#include "mint.h" 29#include "mint.h"
30#include "mint_db.h" 30#include "mint_db.h"
31#include "taler_types.h"
32#include "taler_signatures.h" 31#include "taler_signatures.h"
33#include "taler_rsa.h" 32#include "taler_rsa.h"
34#include "taler_json_lib.h" 33#include "taler_json_lib.h"
@@ -152,10 +151,11 @@ refresh_accept_denoms (struct MHD_Connection *connection,
152 if (GNUNET_OK != res) 151 if (GNUNET_OK != res)
153 return res; 152 return res;
154 153
155 dki = TALER_MINT_get_denom_key (key_state, &denom_pub); 154 dki = &(TALER_MINT_get_denom_key (key_state, &denom_pub)->issue);
156 155
157 GNUNET_CRYPTO_hash_context_read (hash_context, 156 GNUNET_CRYPTO_hash_context_read (hash_context,
158 &denom_pub, sizeof (struct TALER_RSA_PublicKeyBinaryEncoded)); 157 &denom_pub,
158 sizeof (struct TALER_RSA_PublicKeyBinaryEncoded));
159 159
160 cost = TALER_amount_add (TALER_amount_ntoh (dki->value), 160 cost = TALER_amount_add (TALER_amount_ntoh (dki->value),
161 TALER_amount_ntoh (dki->fee_withdraw)); 161 TALER_amount_ntoh (dki->fee_withdraw));
@@ -353,7 +353,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
353 GNUNET_CRYPTO_hash_context_read (hash_context, 353 GNUNET_CRYPTO_hash_context_read (hash_context,
354 &coin_public_info.coin_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); 354 &coin_public_info.coin_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
355 355
356 dki = TALER_MINT_get_denom_key (key_state, &coin_public_info.denom_pub); 356 dki = &(TALER_MINT_get_denom_key (key_state, &coin_public_info.denom_pub)->issue);
357 357
358 if (NULL == dki) 358 if (NULL == dki)
359 return (MHD_YES == request_send_json_pack (connection, MHD_HTTP_NOT_FOUND, 359 return (MHD_YES == request_send_json_pack (connection, MHD_HTTP_NOT_FOUND,
@@ -1344,7 +1344,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
1344 { 1344 {
1345 struct RefreshCommitCoin commit_coin; 1345 struct RefreshCommitCoin commit_coin;
1346 struct TALER_RSA_PublicKeyBinaryEncoded denom_pub; 1346 struct TALER_RSA_PublicKeyBinaryEncoded denom_pub;
1347 struct TALER_MINT_DenomKeyIssue *dki; 1347 struct TALER_MINT_DenomKeyIssuePriv *dki;
1348 struct TALER_RSA_Signature ev_sig; 1348 struct TALER_RSA_Signature ev_sig;
1349 1349
1350 res = TALER_MINT_DB_get_refresh_commit_coin (db_conn, 1350 res = TALER_MINT_DB_get_refresh_commit_coin (db_conn,
diff --git a/src/mint/taler-mint-httpd_withdraw.c b/src/mint/taler-mint-httpd_withdraw.c
index 0fd418540..22024e80e 100644
--- a/src/mint/taler-mint-httpd_withdraw.c
+++ b/src/mint/taler-mint-httpd_withdraw.c
@@ -28,7 +28,6 @@
28#include <pthread.h> 28#include <pthread.h>
29#include "mint.h" 29#include "mint.h"
30#include "mint_db.h" 30#include "mint_db.h"
31#include "taler_types.h"
32#include "taler_signatures.h" 31#include "taler_signatures.h"
33#include "taler_rsa.h" 32#include "taler_rsa.h"
34#include "taler_json_lib.h" 33#include "taler_json_lib.h"
@@ -79,7 +78,7 @@ static void
79sign_reserve (struct Reserve *reserve, 78sign_reserve (struct Reserve *reserve,
80 struct MintKeyState *key_state) 79 struct MintKeyState *key_state)
81{ 80{
82 reserve->status_sign_pub = key_state->current_sign_key_issue.signkey_pub; 81 reserve->status_sign_pub = key_state->current_sign_key_issue.issue.signkey_pub;
83 reserve->status_sig_purpose.purpose = htonl (TALER_SIGNATURE_RESERVE_STATUS); 82 reserve->status_sig_purpose.purpose = htonl (TALER_SIGNATURE_RESERVE_STATUS);
84 reserve->status_sig_purpose.size = htonl (sizeof (struct Reserve) - 83 reserve->status_sig_purpose.size = htonl (sizeof (struct Reserve) -
85 offsetof (struct Reserve, status_sig_purpose)); 84 offsetof (struct Reserve, status_sig_purpose));
@@ -151,7 +150,7 @@ TALER_MINT_handler_withdraw_status (struct RequestHandler *rh,
151 return MHD_NO; 150 return MHD_NO;
152 } 151 }
153 key_state = TALER_MINT_key_state_acquire (); 152 key_state = TALER_MINT_key_state_acquire ();
154 if (0 != memcmp (&key_state->current_sign_key_issue.signkey_pub, 153 if (0 != memcmp (&key_state->current_sign_key_issue.issue.signkey_pub,
155 &reserve.status_sign_pub, 154 &reserve.status_sign_pub,
156 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) 155 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
157 { 156 {
@@ -230,7 +229,7 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
230 struct Reserve reserve; 229 struct Reserve reserve;
231 struct MintKeyState *key_state; 230 struct MintKeyState *key_state;
232 struct CollectableBlindcoin collectable; 231 struct CollectableBlindcoin collectable;
233 struct TALER_MINT_DenomKeyIssue *dki; 232 struct TALER_MINT_DenomKeyIssuePriv *dki;
234 struct TALER_RSA_Signature ev_sig; 233 struct TALER_RSA_Signature ev_sig;
235 struct TALER_Amount amount_required; 234 struct TALER_Amount amount_required;
236 235
@@ -342,16 +341,16 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
342 341
343 key_state = TALER_MINT_key_state_acquire (); 342 key_state = TALER_MINT_key_state_acquire ();
344 dki = TALER_MINT_get_denom_key (key_state, 343 dki = TALER_MINT_get_denom_key (key_state,
345 &wsrd.denomination_pub); 344 &wsrd.denomination_pub);
346 TALER_MINT_key_state_release (key_state); 345 TALER_MINT_key_state_release (key_state);
347 if (NULL == dki) 346 if (NULL == dki)
348 return request_send_json_pack (connection, MHD_HTTP_NOT_FOUND, 347 return request_send_json_pack (connection, MHD_HTTP_NOT_FOUND,
349 "{s:s}", 348 "{s:s}",
350 "error", "Denomination not found"); 349 "error", "Denomination not found");
351 350
352 amount_required = TALER_amount_ntoh (dki->value); 351 amount_required = TALER_amount_ntoh (dki->issue.value);
353 amount_required = TALER_amount_add (amount_required, 352 amount_required = TALER_amount_add (amount_required,
354 TALER_amount_ntoh (dki->fee_withdraw)); 353 TALER_amount_ntoh (dki->issue.fee_withdraw));
355 354
356 if (0 < TALER_amount_cmp (amount_required, 355 if (0 < TALER_amount_cmp (amount_required,
357 TALER_amount_ntoh (reserve.balance))) 356 TALER_amount_ntoh (reserve.balance)))
diff --git a/src/mint/taler-mint-keycheck.c b/src/mint/taler-mint-keycheck.c
index c6186859c..419baf501 100644
--- a/src/mint/taler-mint-keycheck.c
+++ b/src/mint/taler-mint-keycheck.c
@@ -32,19 +32,20 @@ static struct GNUNET_CONFIGURATION_Handle *kcfg;
32 32
33 33
34static int 34static int
35signkeys_iter (void *cls, const struct TALER_MINT_SignKeyIssue *ski) 35signkeys_iter (void *cls, const struct TALER_MINT_SignKeyIssuePriv *ski)
36{ 36{
37 struct GNUNET_TIME_Absolute start; 37 struct GNUNET_TIME_Absolute start;
38 38
39 printf ("iterating over key for start time %s\n", 39 printf ("iterating over key for start time %s\n",
40 GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (ski->start))); 40 GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (ski->issue.start)));
41 41
42 start = GNUNET_TIME_absolute_ntoh (ski->start); 42 start = GNUNET_TIME_absolute_ntoh (ski->issue.start);
43 43
44 if (ntohl (ski->purpose.size) != 44 if (ntohl (ski->issue.purpose.size) !=
45 (sizeof (struct TALER_MINT_SignKeyIssue) - offsetof (struct TALER_MINT_SignKeyIssue, purpose))) 45 (sizeof (struct TALER_MINT_SignKeyIssue) - offsetof (struct TALER_MINT_SignKeyIssue, purpose)))
46 { 46 {
47 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Signkey with start %s has invalid purpose field (timestamp: %llu)\n", 47 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
48 "Signkey with start %s has invalid purpose field (timestamp: %llu)\n",
48 GNUNET_STRINGS_absolute_time_to_string (start), 49 GNUNET_STRINGS_absolute_time_to_string (start),
49 (long long) start.abs_value_us); 50 (long long) start.abs_value_us);
50 return GNUNET_SYSERR; 51 return GNUNET_SYSERR;
@@ -52,15 +53,16 @@ signkeys_iter (void *cls, const struct TALER_MINT_SignKeyIssue *ski)
52 53
53 54
54 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY, 55 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY,
55 &ski->purpose, 56 &ski->issue.purpose,
56 &ski->signature, 57 &ski->issue.signature,
57 &ski->master_pub)) 58 &ski->issue.master_pub))
58 { 59 {
59 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Signkey with start %s has invalid signature (timestamp: %llu)\n", 60 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Signkey with start %s has invalid signature (timestamp: %llu)\n",
60 GNUNET_STRINGS_absolute_time_to_string (start), 61 GNUNET_STRINGS_absolute_time_to_string (start),
61 (long long) start.abs_value_us); 62 (long long) start.abs_value_us);
62 return GNUNET_SYSERR; 63 return GNUNET_SYSERR;
63 } 64 }
65 /* FIXME: what about private key matching the public key? */
64 printf ("key valid\n"); 66 printf ("key valid\n");
65 return GNUNET_OK; 67 return GNUNET_OK;
66} 68}
@@ -75,16 +77,17 @@ mint_signkeys_check ()
75} 77}
76 78
77 79
78static int denomkeys_iter (void *cls, 80static int
79 const char *alias, 81denomkeys_iter (void *cls,
80 const struct TALER_MINT_DenomKeyIssue *dki) 82 const char *alias,
83 const struct TALER_MINT_DenomKeyIssuePriv *dki)
81{ 84{
82 struct GNUNET_TIME_Absolute start; 85 struct GNUNET_TIME_Absolute start;
83 86
84 start = GNUNET_TIME_absolute_ntoh (dki->start); 87 start = GNUNET_TIME_absolute_ntoh (dki->issue.start);
85 88
86 if (ntohl (dki->purpose.size) != 89 if (ntohl (dki->issue.purpose.size) !=
87 (sizeof (struct TALER_MINT_DenomKeyIssue) - offsetof (struct TALER_MINT_DenomKeyIssue, purpose))) 90 (sizeof (struct TALER_MINT_DenomKeyIssuePriv) - offsetof (struct TALER_MINT_DenomKeyIssuePriv, issue.purpose)))
88 { 91 {
89 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Denomkey for '%s' with start %s has invalid purpose field (timestamp: %llu)\n", 92 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Denomkey for '%s' with start %s has invalid purpose field (timestamp: %llu)\n",
90 alias, 93 alias,
@@ -93,12 +96,14 @@ static int denomkeys_iter (void *cls,
93 return GNUNET_SYSERR; 96 return GNUNET_SYSERR;
94 } 97 }
95 98
96 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM, 99 if (GNUNET_OK !=
97 &dki->purpose, 100 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM,
98 &dki->signature, 101 &dki->issue.purpose,
99 &dki->master)) 102 &dki->issue.signature,
103 &dki->issue.master))
100 { 104 {
101 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Denomkey for '%s'with start %s has invalid signature (timestamp: %llu)\n", 105 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
106 "Denomkey for '%s'with start %s has invalid signature (timestamp: %llu)\n",
102 alias, 107 alias,
103 GNUNET_STRINGS_absolute_time_to_string (start), 108 GNUNET_STRINGS_absolute_time_to_string (start),
104 (long long) start.abs_value_us); 109 (long long) start.abs_value_us);
@@ -113,7 +118,8 @@ static int denomkeys_iter (void *cls,
113static int 118static int
114mint_denomkeys_check () 119mint_denomkeys_check ()
115{ 120{
116 if (0 > TALER_MINT_denomkeys_iterate (mintdir, denomkeys_iter, NULL)) 121 if (0 > TALER_MINT_denomkeys_iterate (mintdir,
122 &denomkeys_iter, NULL))
117 return GNUNET_NO; 123 return GNUNET_NO;
118 return GNUNET_OK; 124 return GNUNET_OK;
119} 125}
@@ -148,11 +154,11 @@ main (int argc, char *const *argv)
148 154
149 GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-mint-keycheck", "WARNING", NULL)); 155 GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-mint-keycheck", "WARNING", NULL));
150 156
151 if (GNUNET_GETOPT_run ("taler-mint-keyup", options, argc, argv) < 0) 157 if (GNUNET_GETOPT_run ("taler-mint-keyup", options, argc, argv) < 0)
152 return 1; 158 return 1;
153 if (NULL == mintdir) 159 if (NULL == mintdir)
154 { 160 {
155 fprintf (stderr, "mint directory not given\n"); 161 fprintf (stderr, "mint directory not given\n");
156 return 1; 162 return 1;
157 } 163 }
158 164
diff --git a/src/mint/taler-mint-keyup.c b/src/mint/taler-mint-keyup.c
index 8a1a77882..263618ade 100644
--- a/src/mint/taler-mint-keyup.c
+++ b/src/mint/taler-mint-keyup.c
@@ -292,26 +292,27 @@ get_anchor (const char *dir,
292} 292}
293 293
294static void 294static void
295create_signkey_issue (struct GNUNET_TIME_Absolute start, 295create_signkey_issue_priv (struct GNUNET_TIME_Absolute start,
296 struct GNUNET_TIME_Relative duration, 296 struct GNUNET_TIME_Relative duration,
297 struct TALER_MINT_SignKeyIssue *issue) 297 struct TALER_MINT_SignKeyIssuePriv *pi)
298{ 298{
299 struct GNUNET_CRYPTO_EddsaPrivateKey *priv; 299 struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
300 struct TALER_MINT_SignKeyIssue *issue = &pi->issue;
300 301
301 priv = GNUNET_CRYPTO_eddsa_key_create (); 302 priv = GNUNET_CRYPTO_eddsa_key_create ();
302 GNUNET_assert (NULL != priv); 303 GNUNET_assert (NULL != priv);
303 issue->signkey_priv = *priv; 304 pi->signkey_priv = *priv;
304 GNUNET_free (priv); 305 GNUNET_free (priv);
305 issue->master_pub = *master_pub; 306 issue->master_pub = *master_pub;
306 issue->start = GNUNET_TIME_absolute_hton (start); 307 issue->start = GNUNET_TIME_absolute_hton (start);
307 issue->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (start, duration)); 308 issue->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (start, duration));
308 309
309 GNUNET_CRYPTO_eddsa_key_get_public (&issue->signkey_priv, &issue->signkey_pub); 310 GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv, &issue->signkey_pub);
310 311
311 issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY); 312 issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY);
312 issue->purpose.size = htonl (sizeof (struct TALER_MINT_SignKeyIssue) - offsetof (struct TALER_MINT_SignKeyIssue, purpose)); 313 issue->purpose.size = htonl (sizeof (struct TALER_MINT_SignKeyIssue) - offsetof (struct TALER_MINT_SignKeyIssue, purpose));
313 314
314 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (master_priv, &issue->purpose, &issue->signature)) 315 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (master_priv, &issue->purpose, &issue->signature))
315 { 316 {
316 GNUNET_abort (); 317 GNUNET_abort ();
317 } 318 }
@@ -354,10 +355,10 @@ mint_keys_update_signkeys ()
354 skf = get_signkey_file (anchor); 355 skf = get_signkey_file (anchor);
355 if (GNUNET_YES != GNUNET_DISK_file_test (skf)) 356 if (GNUNET_YES != GNUNET_DISK_file_test (skf))
356 { 357 {
357 struct TALER_MINT_SignKeyIssue signkey_issue; 358 struct TALER_MINT_SignKeyIssuePriv signkey_issue;
358 ssize_t nwrite; 359 ssize_t nwrite;
359 printf ("Generating signing key for %s.\n", GNUNET_STRINGS_absolute_time_to_string (anchor)); 360 printf ("Generating signing key for %s.\n", GNUNET_STRINGS_absolute_time_to_string (anchor));
360 create_signkey_issue (anchor, signkey_duration, &signkey_issue); 361 create_signkey_issue_priv (anchor, signkey_duration, &signkey_issue);
361 nwrite = GNUNET_DISK_fn_write (skf, &signkey_issue, sizeof (struct TALER_MINT_SignKeyIssue), 362 nwrite = GNUNET_DISK_fn_write (skf, &signkey_issue, sizeof (struct TALER_MINT_SignKeyIssue),
362 (GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ)); 363 (GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ));
363 if (nwrite != sizeof (struct TALER_MINT_SignKeyIssue)) 364 if (nwrite != sizeof (struct TALER_MINT_SignKeyIssue))
@@ -430,28 +431,32 @@ get_cointype_params (const char *ct, struct CoinTypeParams *params)
430 431
431 432
432static void 433static void
433create_denomkey_issue (struct CoinTypeParams *params, struct TALER_MINT_DenomKeyIssue *dki) 434create_denomkey_issue (struct CoinTypeParams *params,
435 struct TALER_MINT_DenomKeyIssuePriv *dki)
434{ 436{
435 GNUNET_assert (NULL != (dki->denom_priv = TALER_RSA_key_create ())); 437 GNUNET_assert (NULL != (dki->denom_priv = TALER_RSA_key_create ()));
436 TALER_RSA_key_get_public (dki->denom_priv, &dki->denom_pub); 438 TALER_RSA_key_get_public (dki->denom_priv, &dki->issue.denom_pub);
437 dki->master = *master_pub; 439 dki->issue.master = *master_pub;
438 dki->start = GNUNET_TIME_absolute_hton (params->anchor); 440 dki->issue.start = GNUNET_TIME_absolute_hton (params->anchor);
439 dki->expire_withdraw = 441 dki->issue.expire_withdraw =
440 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, 442 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor,
441 params->duration_withdraw)); 443 params->duration_withdraw));
442 dki->expire_spend = 444 dki->issue.expire_spend =
443 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, 445 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor,
444 params->duration_spend)); 446 params->duration_spend));
445 dki->value = TALER_amount_hton (params->value); 447 dki->issue.value = TALER_amount_hton (params->value);
446 dki->fee_withdraw = TALER_amount_hton (params->fee_withdraw); 448 dki->issue.fee_withdraw = TALER_amount_hton (params->fee_withdraw);
447 dki->fee_deposit = TALER_amount_hton (params->fee_deposit); 449 dki->issue.fee_deposit = TALER_amount_hton (params->fee_deposit);
448 dki->fee_refresh = TALER_amount_hton (params->fee_refresh); 450 dki->issue.fee_refresh = TALER_amount_hton (params->fee_refresh);
449 451
450 dki->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOM); 452 dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOM);
451 dki->purpose.size = htonl (sizeof (struct TALER_MINT_DenomKeyIssue) - offsetof (struct TALER_MINT_DenomKeyIssue, purpose)); 453 dki->issue.purpose.size = htonl (sizeof (struct TALER_MINT_DenomKeyIssuePriv) - offsetof (struct TALER_MINT_DenomKeyIssuePriv, issue.purpose));
452 454
453 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (master_priv, &dki->purpose, &dki->signature)) 455 if (GNUNET_OK !=
454 { 456 GNUNET_CRYPTO_eddsa_sign (master_priv,
457 &dki->issue.purpose,
458 &dki->issue.signature))
459 {
455 GNUNET_abort (); 460 GNUNET_abort ();
456 } 461 }
457} 462}
@@ -484,7 +489,7 @@ mint_keys_update_cointype (const char *coin_alias)
484 489
485 if (GNUNET_YES != GNUNET_DISK_file_test (dkf)) 490 if (GNUNET_YES != GNUNET_DISK_file_test (dkf))
486 { 491 {
487 struct TALER_MINT_DenomKeyIssue denomkey_issue; 492 struct TALER_MINT_DenomKeyIssuePriv denomkey_issue;
488 int ret; 493 int ret;
489 printf ("Generating denomination key for type '%s', start %s.\n", 494 printf ("Generating denomination key for type '%s', start %s.\n",
490 coin_alias, GNUNET_STRINGS_absolute_time_to_string (p.anchor)); 495 coin_alias, GNUNET_STRINGS_absolute_time_to_string (p.anchor));
@@ -589,11 +594,11 @@ main (int argc, char *const *argv)
589 594
590 GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-mint-keyup", "WARNING", NULL)); 595 GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-mint-keyup", "WARNING", NULL));
591 596
592 if (GNUNET_GETOPT_run ("taler-mint-keyup", options, argc, argv) < 0) 597 if (GNUNET_GETOPT_run ("taler-mint-keyup", options, argc, argv) < 0)
593 return 1; 598 return 1;
594 if (NULL == mintdir) 599 if (NULL == mintdir)
595 { 600 {
596 fprintf (stderr, "mint directory not given\n"); 601 fprintf (stderr, "mint directory not given\n");
597 return 1; 602 return 1;
598 } 603 }
599 604
@@ -601,7 +606,7 @@ main (int argc, char *const *argv)
601 { 606 {
602 if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (pretend_time_str, &now)) 607 if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (pretend_time_str, &now))
603 { 608 {
604 fprintf (stderr, "timestamp invalid\n"); 609 fprintf (stderr, "timestamp invalid\n");
605 return 1; 610 return 1;
606 } 611 }
607 } 612 }
diff --git a/src/mint/test_mint_common.c b/src/mint/test_mint_common.c
index b7cad3ea4..d4bbb6c46 100644
--- a/src/mint/test_mint_common.c
+++ b/src/mint/test_mint_common.c
@@ -33,9 +33,9 @@
33int 33int
34main (int argc, const char *const argv[]) 34main (int argc, const char *const argv[])
35{ 35{
36 struct TALER_MINT_DenomKeyIssue dki; 36 struct TALER_MINT_DenomKeyIssuePriv dki;
37 struct TALER_RSA_PrivateKeyBinaryEncoded *enc; 37 struct TALER_RSA_PrivateKeyBinaryEncoded *enc;
38 struct TALER_MINT_DenomKeyIssue dki_read; 38 struct TALER_MINT_DenomKeyIssuePriv dki_read;
39 struct TALER_RSA_PrivateKeyBinaryEncoded *enc_read; 39 struct TALER_RSA_PrivateKeyBinaryEncoded *enc_read;
40 char *tmpfile; 40 char *tmpfile;
41 41
@@ -48,7 +48,7 @@ main (int argc, const char *const argv[])
48 dki.denom_priv = NULL; 48 dki.denom_priv = NULL;
49 dki_read.denom_priv = NULL; 49 dki_read.denom_priv = NULL;
50 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, 50 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
51 &dki.signature, 51 &dki.issue.signature,
52 sizeof (dki) - offsetof (struct TALER_MINT_DenomKeyIssue, 52 sizeof (dki) - offsetof (struct TALER_MINT_DenomKeyIssue,
53 signature)); 53 signature));
54 dki.denom_priv = TALER_RSA_key_create (); 54 dki.denom_priv = TALER_RSA_key_create ();
@@ -61,8 +61,8 @@ main (int argc, const char *const argv[])
61 EXITIF (0 != memcmp (enc, 61 EXITIF (0 != memcmp (enc,
62 enc_read, 62 enc_read,
63 ntohs(enc->len))); 63 ntohs(enc->len)));
64 EXITIF (0 != memcmp (&dki.signature, 64 EXITIF (0 != memcmp (&dki.issue.signature,
65 &dki_read.signature, 65 &dki_read.issue.signature,
66 sizeof (dki) - offsetof (struct TALER_MINT_DenomKeyIssue, 66 sizeof (dki) - offsetof (struct TALER_MINT_DenomKeyIssue,
67 signature))); 67 signature)));
68 ret = 0; 68 ret = 0;
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index b74e90da9..480b07a70 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -22,17 +22,11 @@ libtalerutil_la_LDFLAGS = \
22 -export-dynamic -no-undefined 22 -export-dynamic -no-undefined
23 23
24check_PROGRAMS = \ 24check_PROGRAMS = \
25 test-hash-context \
26 test-rsa 25 test-rsa
27 26
28TESTS = \ 27TESTS = \
29 $(check_PROGRAMS) 28 $(check_PROGRAMS)
30 29
31test_hash_context_SOURCES = test_hash_context.c
32test_hash_context_CPPFLAGS = $(AM_CPPFLAGS) $(LIBGCRYPT_CFLAGS)
33test_hash_context_LDADD = libtalerutil.la \
34 -lgnunetutil $(LIBGCRYPT_LIBS)
35
36test_rsa_SOURCES = test_rsa.c 30test_rsa_SOURCES = test_rsa.c
37test_rsa_LDADD = libtalerutil.la \ 31test_rsa_LDADD = libtalerutil.la \
38 -lgnunetutil $(LIBGCRYPT_LIBS) 32 -lgnunetutil $(LIBGCRYPT_LIBS)
diff --git a/src/util/test_hash_context.c b/src/util/test_hash_context.c
deleted file mode 100644
index 4b94e7ffa..000000000
--- a/src/util/test_hash_context.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 This file is part of TALER
3 (C) 2014 Christian Grothoff (and other contributing authors)
4
5 TALER is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/
16
17/**
18 * @file util/test_hash_context.c
19 * @brief test case for incremental hashing
20 * @author Florian Dold
21 */
22
23#include "platform.h"
24#include "taler_util.h"
25#include <gcrypt.h>
26
27#define LEN 1234
28
29int main()
30{
31 char data[1234];
32 struct GNUNET_HashCode hc1;
33 struct GNUNET_HashCode hc2;
34 struct GNUNET_HashContext hctx;
35
36 memset (data, 42, LEN);
37
38 GNUNET_CRYPTO_hash_context_start (&hctx);
39 GNUNET_CRYPTO_hash_context_read (&hctx, data, LEN);
40 GNUNET_CRYPTO_hash_context_finish (&hctx, &hc1);
41
42 GNUNET_CRYPTO_hash (data, LEN, &hc2);
43
44 if (0 == memcmp (&hc1, &hc2, sizeof (struct GNUNET_HashCode)))
45 return 0;
46 return 1;
47}
48