diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-28 15:03:47 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-28 15:03:47 +0100 |
commit | 9cbc31afc495ebdfe7b24535ca2eee54b5a17ab7 (patch) | |
tree | 00c1a871b8987f58442f77a2040deef8618932b1 | |
parent | b6154af448264daa814623bfb71edff642be1a14 (diff) | |
download | exchange-9cbc31afc495ebdfe7b24535ca2eee54b5a17ab7.tar.gz exchange-9cbc31afc495ebdfe7b24535ca2eee54b5a17ab7.zip |
move key IO routines into aptly named files
-rw-r--r-- | src/mint/Makefile.am | 2 | ||||
-rw-r--r-- | src/mint/key_io.c (renamed from src/mint/mint_common.c) | 18 | ||||
-rw-r--r-- | src/mint/key_io.h | 137 | ||||
-rw-r--r-- | src/mint/mint.h | 102 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_keys.h | 2 | ||||
-rw-r--r-- | src/mint/taler-mint-keycheck.c | 1 | ||||
-rw-r--r-- | src/mint/taler-mint-keyup.c | 1 |
7 files changed, 156 insertions, 107 deletions
diff --git a/src/mint/Makefile.am b/src/mint/Makefile.am index c0fd6949b..17b82dc51 100644 --- a/src/mint/Makefile.am +++ b/src/mint/Makefile.am | |||
@@ -4,7 +4,7 @@ lib_LTLIBRARIES = \ | |||
4 | libtalermint_common.la | 4 | libtalermint_common.la |
5 | 5 | ||
6 | libtalermint_common_la_SOURCES = \ | 6 | libtalermint_common_la_SOURCES = \ |
7 | mint_common.c \ | 7 | key_io.c key_io.h \ |
8 | mint_db.c | 8 | mint_db.c |
9 | 9 | ||
10 | libtalermint_common_la_LIBADD = \ | 10 | libtalermint_common_la_LIBADD = \ |
diff --git a/src/mint/mint_common.c b/src/mint/key_io.c index 41b9d6ed5..f401a1268 100644 --- a/src/mint/mint_common.c +++ b/src/mint/key_io.c | |||
@@ -15,15 +15,17 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * @file mint_common.c | 18 | * @file key_io.c |
19 | * @brief Common functionality for the mint | 19 | * @brief I/O operations for the Mint's private keys |
20 | * @author Florian Dold | 20 | * @author Florian Dold |
21 | * @author Benedikt Mueller | 21 | * @author Benedikt Mueller |
22 | * @author Sree Harsha Totakura | 22 | * @author Sree Harsha Totakura |
23 | * @author Christian Grothoff | ||
23 | */ | 24 | */ |
24 | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "mint.h" | 26 | #include "mint.h" |
27 | #include "key_io.h" | ||
28 | |||
27 | 29 | ||
28 | struct SignkeysIterateContext | 30 | struct SignkeysIterateContext |
29 | { | 31 | { |
@@ -201,8 +203,8 @@ static int | |||
201 | denomkeys_iterate_topdir_iter (void *cls, | 203 | denomkeys_iterate_topdir_iter (void *cls, |
202 | const char *filename) | 204 | const char *filename) |
203 | { | 205 | { |
204 | |||
205 | struct DenomkeysIterateContext *dic = cls; | 206 | struct DenomkeysIterateContext *dic = cls; |
207 | |||
206 | dic->alias = GNUNET_STRINGS_get_short_name (filename); | 208 | dic->alias = GNUNET_STRINGS_get_short_name (filename); |
207 | 209 | ||
208 | // FIXME: differentiate between error case and normal iteration abortion | 210 | // FIXME: differentiate between error case and normal iteration abortion |
@@ -219,7 +221,9 @@ TALER_MINT_denomkeys_iterate (const char *mint_base_dir, | |||
219 | char *dir; | 221 | char *dir; |
220 | size_t len; | 222 | size_t len; |
221 | struct DenomkeysIterateContext dic; | 223 | struct DenomkeysIterateContext dic; |
222 | len = GNUNET_asprintf (&dir, ("%s" DIR_SEPARATOR_STR DIR_DENOMKEYS), | 224 | |
225 | len = GNUNET_asprintf (&dir, | ||
226 | "%s" DIR_SEPARATOR_STR DIR_DENOMKEYS, | ||
223 | mint_base_dir); | 227 | mint_base_dir); |
224 | GNUNET_assert (len > 0); | 228 | GNUNET_assert (len > 0); |
225 | 229 | ||
@@ -227,7 +231,9 @@ TALER_MINT_denomkeys_iterate (const char *mint_base_dir, | |||
227 | dic.it_cls = cls; | 231 | dic.it_cls = cls; |
228 | 232 | ||
229 | // scan over alias dirs | 233 | // scan over alias dirs |
230 | return GNUNET_DISK_directory_scan (dir, &denomkeys_iterate_topdir_iter, &dic); | 234 | return GNUNET_DISK_directory_scan (dir, |
235 | &denomkeys_iterate_topdir_iter, | ||
236 | &dic); | ||
231 | } | 237 | } |
232 | 238 | ||
233 | 239 | ||
diff --git a/src/mint/key_io.h b/src/mint/key_io.h new file mode 100644 index 000000000..44665e379 --- /dev/null +++ b/src/mint/key_io.h | |||
@@ -0,0 +1,137 @@ | |||
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 | * @file key_io.h | ||
18 | * @brief IO operations for the mint's private keys | ||
19 | * @author Florian Dold | ||
20 | * @author Benedikt Mueller | ||
21 | * @author Christian Grothoff | ||
22 | * | ||
23 | * TODO: | ||
24 | * - document better | ||
25 | */ | ||
26 | #ifndef KEY_IO_H | ||
27 | #define KEY_IO_H | ||
28 | |||
29 | #include <gnunet/gnunet_util_lib.h> | ||
30 | #include <gnunet/gnunet_common.h> | ||
31 | #include "taler_util.h" | ||
32 | #include "taler_signatures.h" | ||
33 | |||
34 | #define DIR_SIGNKEYS "signkeys" | ||
35 | #define DIR_DENOMKEYS "denomkeys" | ||
36 | |||
37 | /** | ||
38 | * On disk format used for a mint signing key. | ||
39 | * Includes the private key followed by the signed | ||
40 | * issue message. | ||
41 | */ | ||
42 | struct TALER_MINT_SignKeyIssuePriv | ||
43 | { | ||
44 | struct GNUNET_CRYPTO_EddsaPrivateKey signkey_priv; | ||
45 | struct TALER_MINT_SignKeyIssue issue; | ||
46 | }; | ||
47 | |||
48 | |||
49 | |||
50 | struct TALER_MINT_DenomKeyIssuePriv | ||
51 | { | ||
52 | /** | ||
53 | * The private key of the denomination. Will be NULL if the private key is | ||
54 | * not available. | ||
55 | */ | ||
56 | struct GNUNET_CRYPTO_rsa_PrivateKey *denom_priv; | ||
57 | |||
58 | struct TALER_MINT_DenomKeyIssue issue; | ||
59 | }; | ||
60 | |||
61 | |||
62 | |||
63 | |||
64 | /** | ||
65 | * Iterator for sign keys. | ||
66 | * | ||
67 | * @param cls closure | ||
68 | * @param ski the sign key issue | ||
69 | * @return #GNUNET_OK to continue to iterate, | ||
70 | * #GNUNET_NO to stop iteration with no error, | ||
71 | * #GNUNET_SYSERR to abort iteration with error! | ||
72 | */ | ||
73 | typedef int | ||
74 | (*TALER_MINT_SignkeyIterator)(void *cls, | ||
75 | const struct TALER_MINT_SignKeyIssuePriv *ski); | ||
76 | |||
77 | /** | ||
78 | * Iterator for denomination keys. | ||
79 | * | ||
80 | * @param cls closure | ||
81 | * @param dki the denomination key issue | ||
82 | * @param alias coin alias | ||
83 | * @return #GNUNET_OK to continue to iterate, | ||
84 | * #GNUNET_NO to stop iteration with no error, | ||
85 | * #GNUNET_SYSERR to abort iteration with error! | ||
86 | */ | ||
87 | typedef int | ||
88 | (*TALER_MINT_DenomkeyIterator)(void *cls, | ||
89 | const char *alias, | ||
90 | const struct TALER_MINT_DenomKeyIssuePriv *dki); | ||
91 | |||
92 | |||
93 | |||
94 | /** | ||
95 | * FIXME | ||
96 | */ | ||
97 | int | ||
98 | TALER_MINT_signkeys_iterate (const char *mint_base_dir, | ||
99 | TALER_MINT_SignkeyIterator it, void *cls); | ||
100 | |||
101 | |||
102 | /** | ||
103 | * FIXME | ||
104 | */ | ||
105 | int | ||
106 | TALER_MINT_denomkeys_iterate (const char *mint_base_dir, | ||
107 | TALER_MINT_DenomkeyIterator it, void *cls); | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Exports a denomination key to the given file | ||
112 | * | ||
113 | * @param filename the file where to write the denomination key | ||
114 | * @param dki the denomination key | ||
115 | * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure. | ||
116 | */ | ||
117 | int | ||
118 | TALER_MINT_write_denom_key (const char *filename, | ||
119 | const struct TALER_MINT_DenomKeyIssuePriv *dki); | ||
120 | |||
121 | |||
122 | /** | ||
123 | * Import a denomination key from the given file | ||
124 | * | ||
125 | * @param filename the file to import the key from | ||
126 | * @param dki pointer to return the imported denomination key | ||
127 | * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure | ||
128 | */ | ||
129 | int | ||
130 | TALER_MINT_read_denom_key (const char *filename, | ||
131 | struct TALER_MINT_DenomKeyIssuePriv *dki); | ||
132 | |||
133 | |||
134 | |||
135 | |||
136 | |||
137 | #endif | ||
diff --git a/src/mint/mint.h b/src/mint/mint.h index 0a0e00d04..1c5e9802e 100644 --- a/src/mint/mint.h +++ b/src/mint/mint.h | |||
@@ -20,20 +20,18 @@ | |||
20 | * @author Benedikt Mueller | 20 | * @author Benedikt Mueller |
21 | * | 21 | * |
22 | * TODO: | 22 | * TODO: |
23 | * - revisit and document `struct Deposit` members. | 23 | * - move DB functions to mint_db.h |
24 | */ | 24 | */ |
25 | #ifndef _MINT_H | 25 | #ifndef _MINT_H |
26 | #define _MINT_H | 26 | #define _MINT_H |
27 | 27 | ||
28 | #include <gnunet/gnunet_util_lib.h> | 28 | #include <gnunet/gnunet_util_lib.h> |
29 | #include <gnunet/gnunet_common.h> | 29 | #include <gnunet/gnunet_common.h> |
30 | #include <libpq-fe.h> | ||
31 | #include <jansson.h> | 30 | #include <jansson.h> |
31 | #include <libpq-fe.h> | ||
32 | #include "taler_util.h" | 32 | #include "taler_util.h" |
33 | #include "taler_signatures.h" | 33 | #include "taler_signatures.h" |
34 | 34 | ||
35 | #define DIR_SIGNKEYS "signkeys" | ||
36 | #define DIR_DENOMKEYS "denomkeys" | ||
37 | 35 | ||
38 | /** | 36 | /** |
39 | * For now, we just do EUR. Should become configurable | 37 | * For now, we just do EUR. Should become configurable |
@@ -41,31 +39,6 @@ | |||
41 | */ | 39 | */ |
42 | #define MINT_CURRENCY "EUR" | 40 | #define MINT_CURRENCY "EUR" |
43 | 41 | ||
44 | /** | ||
45 | * On disk format used for a mint signing key. | ||
46 | * Includes the private key followed by the signed | ||
47 | * issue message. | ||
48 | */ | ||
49 | struct TALER_MINT_SignKeyIssuePriv | ||
50 | { | ||
51 | struct GNUNET_CRYPTO_EddsaPrivateKey signkey_priv; | ||
52 | struct TALER_MINT_SignKeyIssue issue; | ||
53 | }; | ||
54 | |||
55 | |||
56 | |||
57 | struct TALER_MINT_DenomKeyIssuePriv | ||
58 | { | ||
59 | /** | ||
60 | * The private key of the denomination. Will be NULL if the private key is | ||
61 | * not available. | ||
62 | */ | ||
63 | struct GNUNET_CRYPTO_rsa_PrivateKey *denom_priv; | ||
64 | |||
65 | struct TALER_MINT_DenomKeyIssue issue; | ||
66 | }; | ||
67 | |||
68 | |||
69 | 42 | ||
70 | /** | 43 | /** |
71 | * Public information about a coin (including the public key | 44 | * Public information about a coin (including the public key |
@@ -357,77 +330,6 @@ struct Reserve | |||
357 | 330 | ||
358 | 331 | ||
359 | 332 | ||
360 | /** | ||
361 | * Iterator for sign keys. | ||
362 | * | ||
363 | * @param cls closure | ||
364 | * @param ski the sign key issue | ||
365 | * @return #GNUNET_OK to continue to iterate, | ||
366 | * #GNUNET_NO to stop iteration with no error, | ||
367 | * #GNUNET_SYSERR to abort iteration with error! | ||
368 | */ | ||
369 | typedef int | ||
370 | (*TALER_MINT_SignkeyIterator)(void *cls, | ||
371 | const struct TALER_MINT_SignKeyIssuePriv *ski); | ||
372 | |||
373 | /** | ||
374 | * Iterator for denomination keys. | ||
375 | * | ||
376 | * @param cls closure | ||
377 | * @param dki the denomination key issue | ||
378 | * @param alias coin alias | ||
379 | * @return #GNUNET_OK to continue to iterate, | ||
380 | * #GNUNET_NO to stop iteration with no error, | ||
381 | * #GNUNET_SYSERR to abort iteration with error! | ||
382 | */ | ||
383 | typedef int | ||
384 | (*TALER_MINT_DenomkeyIterator)(void *cls, | ||
385 | const char *alias, | ||
386 | const struct TALER_MINT_DenomKeyIssuePriv *dki); | ||
387 | |||
388 | |||
389 | |||
390 | /** | ||
391 | * FIXME | ||
392 | */ | ||
393 | int | ||
394 | TALER_MINT_signkeys_iterate (const char *mint_base_dir, | ||
395 | TALER_MINT_SignkeyIterator it, void *cls); | ||
396 | |||
397 | |||
398 | /** | ||
399 | * FIXME | ||
400 | */ | ||
401 | int | ||
402 | TALER_MINT_denomkeys_iterate (const char *mint_base_dir, | ||
403 | TALER_MINT_DenomkeyIterator it, void *cls); | ||
404 | |||
405 | |||
406 | /** | ||
407 | * Exports a denomination key to the given file | ||
408 | * | ||
409 | * @param filename the file where to write the denomination key | ||
410 | * @param dki the denomination key | ||
411 | * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure. | ||
412 | */ | ||
413 | int | ||
414 | TALER_MINT_write_denom_key (const char *filename, | ||
415 | const struct TALER_MINT_DenomKeyIssuePriv *dki); | ||
416 | |||
417 | |||
418 | /** | ||
419 | * Import a denomination key from the given file | ||
420 | * | ||
421 | * @param filename the file to import the key from | ||
422 | * @param dki pointer to return the imported denomination key | ||
423 | * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure | ||
424 | */ | ||
425 | int | ||
426 | TALER_MINT_read_denom_key (const char *filename, | ||
427 | struct TALER_MINT_DenomKeyIssuePriv *dki); | ||
428 | |||
429 | |||
430 | |||
431 | int | 333 | int |
432 | TALER_TALER_DB_extract_amount (PGresult *result, | 334 | TALER_TALER_DB_extract_amount (PGresult *result, |
433 | unsigned int row, | 335 | unsigned int row, |
diff --git a/src/mint/taler-mint-httpd_keys.h b/src/mint/taler-mint-httpd_keys.h index 4182c25ea..eeeb21ef3 100644 --- a/src/mint/taler-mint-httpd_keys.h +++ b/src/mint/taler-mint-httpd_keys.h | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <jansson.h> | 28 | #include <jansson.h> |
29 | #include "taler-mint-httpd.h" | 29 | #include "taler-mint-httpd.h" |
30 | #include "mint.h" | 30 | #include "mint.h" |
31 | #include "key_io.h" | ||
32 | |||
31 | 33 | ||
32 | /** | 34 | /** |
33 | * Snapshot of the (coin and signing) | 35 | * Snapshot of the (coin and signing) |
diff --git a/src/mint/taler-mint-keycheck.c b/src/mint/taler-mint-keycheck.c index 09f59ab2f..c2deec0c2 100644 --- a/src/mint/taler-mint-keycheck.c +++ b/src/mint/taler-mint-keycheck.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <gnunet/gnunet_util_lib.h> | 25 | #include <gnunet/gnunet_util_lib.h> |
26 | #include "mint.h" | 26 | #include "mint.h" |
27 | #include "taler_signatures.h" | 27 | #include "taler_signatures.h" |
28 | #include "key_io.h" | ||
28 | 29 | ||
29 | 30 | ||
30 | static char *mintdir; | 31 | static char *mintdir; |
diff --git a/src/mint/taler-mint-keyup.c b/src/mint/taler-mint-keyup.c index f8670eb97..03c66216b 100644 --- a/src/mint/taler-mint-keyup.c +++ b/src/mint/taler-mint-keyup.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "taler_util.h" | 27 | #include "taler_util.h" |
28 | #include "taler_signatures.h" | 28 | #include "taler_signatures.h" |
29 | #include "mint.h" | 29 | #include "mint.h" |
30 | #include "key_io.h" | ||
30 | 31 | ||
31 | /** | 32 | /** |
32 | * FIXME: allow user to specify (within reason). | 33 | * FIXME: allow user to specify (within reason). |