diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-27 22:17:08 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-27 22:17:08 +0100 |
commit | 8fd46396d7cc84e1ea86413b3d48ab1fc4fb86d7 (patch) | |
tree | b0757b2e936403a0e5549ff086f8f9102f1fc684 | |
parent | 162af316d39f1bf526e3dc63e67dd6ae6f7be91b (diff) | |
download | exchange-8fd46396d7cc84e1ea86413b3d48ab1fc4fb86d7.tar.gz exchange-8fd46396d7cc84e1ea86413b3d48ab1fc4fb86d7.zip |
polishing taler-mint-http_withdraw.c logic
-rw-r--r-- | src/mint/taler-mint-httpd_parsing.h | 3 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 2 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_withdraw.c | 54 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_withdraw.h | 1 |
4 files changed, 25 insertions, 35 deletions
diff --git a/src/mint/taler-mint-httpd_parsing.h b/src/mint/taler-mint-httpd_parsing.h index 5f5f35dfc..c8e946077 100644 --- a/src/mint/taler-mint-httpd_parsing.h +++ b/src/mint/taler-mint-httpd_parsing.h | |||
@@ -13,7 +13,6 @@ | |||
13 | You should have received a copy of the GNU Affero 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 taler-mint-httpd_parsing.h | 17 | * @file taler-mint-httpd_parsing.h |
19 | * @brief functions to parse incoming requests | 18 | * @brief functions to parse incoming requests |
@@ -21,11 +20,9 @@ | |||
21 | * @author Benedikt Mueller | 20 | * @author Benedikt Mueller |
22 | * @author Christian Grothoff | 21 | * @author Christian Grothoff |
23 | */ | 22 | */ |
24 | |||
25 | #ifndef TALER_MICROHTTPD_LIB_H_ | 23 | #ifndef TALER_MICROHTTPD_LIB_H_ |
26 | #define TALER_MICROHTTPD_LIB_H_ | 24 | #define TALER_MICROHTTPD_LIB_H_ |
27 | 25 | ||
28 | |||
29 | #include <microhttpd.h> | 26 | #include <microhttpd.h> |
30 | #include <jansson.h> | 27 | #include <jansson.h> |
31 | 28 | ||
diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index 1f698905a..51abd9fb4 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h | |||
@@ -28,11 +28,9 @@ | |||
28 | #include <gnunet/gnunet_util_lib.h> | 28 | #include <gnunet/gnunet_util_lib.h> |
29 | #include <jansson.h> | 29 | #include <jansson.h> |
30 | #include <microhttpd.h> | 30 | #include <microhttpd.h> |
31 | #include <libpq-fe.h> | ||
32 | #include <pthread.h> | 31 | #include <pthread.h> |
33 | #include "taler-mint-httpd.h" | 32 | #include "taler-mint-httpd.h" |
34 | #include "taler-mint-httpd_db.h" | 33 | #include "taler-mint-httpd_db.h" |
35 | #include "taler-mint-httpd_mhd.h" | ||
36 | 34 | ||
37 | 35 | ||
38 | /** | 36 | /** |
diff --git a/src/mint/taler-mint-httpd_withdraw.c b/src/mint/taler-mint-httpd_withdraw.c index c23aa70e2..8c74b72b6 100644 --- a/src/mint/taler-mint-httpd_withdraw.c +++ b/src/mint/taler-mint-httpd_withdraw.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | (C) 2014 GNUnet e.V. | 3 | (C) 2014,2015 GNUnet e.V. |
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 Affero General Public License as published by the Free Software | 6 | terms of the GNU Affero General Public License as published by the Free Software |
@@ -19,25 +19,12 @@ | |||
19 | * @author Florian Dold | 19 | * @author Florian Dold |
20 | * @author Benedikt Mueller | 20 | * @author Benedikt Mueller |
21 | * @author Christian Grothoff | 21 | * @author Christian Grothoff |
22 | * | ||
23 | * TODO: | ||
24 | * - support variable-size RSA keys | ||
25 | */ | 22 | */ |
26 | #include "platform.h" | 23 | #include "platform.h" |
27 | #include <gnunet/gnunet_util_lib.h> | 24 | #include <gnunet/gnunet_util_lib.h> |
28 | #include <jansson.h> | 25 | #include <jansson.h> |
29 | #include <microhttpd.h> | ||
30 | #include <libpq-fe.h> | ||
31 | #include <pthread.h> | ||
32 | #include "mint.h" | ||
33 | #include "mint_db.h" | ||
34 | #include "taler_signatures.h" | ||
35 | #include "taler_json_lib.h" | ||
36 | #include "taler-mint-httpd_parsing.h" | ||
37 | #include "taler-mint-httpd_keys.h" | ||
38 | #include "taler-mint-httpd_db.h" | ||
39 | #include "taler-mint-httpd_mhd.h" | ||
40 | #include "taler-mint-httpd_withdraw.h" | 26 | #include "taler-mint-httpd_withdraw.h" |
27 | #include "taler-mint-httpd_parsing.h" | ||
41 | #include "taler-mint-httpd_responses.h" | 28 | #include "taler-mint-httpd_responses.h" |
42 | 29 | ||
43 | 30 | ||
@@ -108,8 +95,14 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, | |||
108 | return MHD_NO; /* internal error */ | 95 | return MHD_NO; /* internal error */ |
109 | if (GNUNET_NO == res) | 96 | if (GNUNET_NO == res) |
110 | return MHD_YES; /* invalid request */ | 97 | return MHD_YES; /* invalid request */ |
111 | 98 | res = TALER_MINT_mhd_request_arg_data (connection, | |
112 | /* FIXME: handle variable-size signing keys! */ | 99 | "reserve_sig", |
100 | &signature, | ||
101 | sizeof (struct GNUNET_CRYPTO_EddsaSignature)); | ||
102 | if (GNUNET_SYSERR == res) | ||
103 | return MHD_NO; /* internal error */ | ||
104 | if (GNUNET_NO == res) | ||
105 | return MHD_YES; /* invalid request */ | ||
113 | res = TALER_MINT_mhd_request_var_arg_data (connection, | 106 | res = TALER_MINT_mhd_request_var_arg_data (connection, |
114 | "denom_pub", | 107 | "denom_pub", |
115 | (void **) &denomination_pub_data, | 108 | (void **) &denomination_pub_data, |
@@ -123,17 +116,15 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, | |||
123 | (void **) &blinded_msg, | 116 | (void **) &blinded_msg, |
124 | &blinded_msg_len); | 117 | &blinded_msg_len); |
125 | if (GNUNET_SYSERR == res) | 118 | if (GNUNET_SYSERR == res) |
119 | { | ||
120 | GNUNET_free (denomination_pub_data); | ||
126 | return MHD_NO; /* internal error */ | 121 | return MHD_NO; /* internal error */ |
122 | } | ||
127 | if (GNUNET_NO == res) | 123 | if (GNUNET_NO == res) |
124 | { | ||
125 | GNUNET_free (denomination_pub_data); | ||
128 | return MHD_YES; /* invalid request */ | 126 | return MHD_YES; /* invalid request */ |
129 | res = TALER_MINT_mhd_request_arg_data (connection, | 127 | } |
130 | "reserve_sig", | ||
131 | &signature, | ||
132 | sizeof (struct GNUNET_CRYPTO_EddsaSignature)); | ||
133 | if (GNUNET_SYSERR == res) | ||
134 | return MHD_NO; /* internal error */ | ||
135 | if (GNUNET_NO == res) | ||
136 | return MHD_YES; /* invalid request */ | ||
137 | 128 | ||
138 | /* verify signature! */ | 129 | /* verify signature! */ |
139 | wsrd.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest)); | 130 | wsrd.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest)); |
@@ -150,15 +141,21 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, | |||
150 | &signature, | 141 | &signature, |
151 | &wsrd.reserve_pub)) | 142 | &wsrd.reserve_pub)) |
152 | { | 143 | { |
153 | return 42; // FIXME: generate error reply | 144 | LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n"); |
145 | GNUNET_free (denomination_pub_data); | ||
146 | GNUNET_free (blinded_msg); | ||
147 | return TALER_MINT_reply_arg_invalid (connection, | ||
148 | "reserve_sig"); | ||
154 | } | 149 | } |
155 | denomination_pub = GNUNET_CRYPTO_rsa_public_key_decode (denomination_pub_data, | 150 | denomination_pub = GNUNET_CRYPTO_rsa_public_key_decode (denomination_pub_data, |
156 | denomination_pub_data_size); | 151 | denomination_pub_data_size); |
152 | GNUNET_free (denomination_pub_data); | ||
157 | if (NULL == denomination_pub) | 153 | if (NULL == denomination_pub) |
158 | { | 154 | { |
159 | GNUNET_free (denomination_pub_data); | 155 | LOG_WARNING ("Client supplied ill-formed denomination public key for /withdraw/sign request\n"); |
160 | GNUNET_free (blinded_msg); | 156 | GNUNET_free (blinded_msg); |
161 | return 42; // FIXME: generate error reply | 157 | return TALER_MINT_reply_arg_invalid (connection, |
158 | "denom_pub"); | ||
162 | } | 159 | } |
163 | res = TALER_MINT_db_execute_withdraw_sign (connection, | 160 | res = TALER_MINT_db_execute_withdraw_sign (connection, |
164 | &wsrd.reserve_pub, | 161 | &wsrd.reserve_pub, |
@@ -166,7 +163,6 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, | |||
166 | blinded_msg, | 163 | blinded_msg, |
167 | blinded_msg_len, | 164 | blinded_msg_len, |
168 | &signature); | 165 | &signature); |
169 | GNUNET_free (denomination_pub_data); | ||
170 | GNUNET_free (blinded_msg); | 166 | GNUNET_free (blinded_msg); |
171 | GNUNET_CRYPTO_rsa_public_key_free (denomination_pub); | 167 | GNUNET_CRYPTO_rsa_public_key_free (denomination_pub); |
172 | return res; | 168 | return res; |
diff --git a/src/mint/taler-mint-httpd_withdraw.h b/src/mint/taler-mint-httpd_withdraw.h index 1d292ebd9..6587a194f 100644 --- a/src/mint/taler-mint-httpd_withdraw.h +++ b/src/mint/taler-mint-httpd_withdraw.h | |||
@@ -23,7 +23,6 @@ | |||
23 | #ifndef TALER_MINT_HTTPD_WITHDRAW_H | 23 | #ifndef TALER_MINT_HTTPD_WITHDRAW_H |
24 | #define TALER_MINT_HTTPD_WITHDRAW_H | 24 | #define TALER_MINT_HTTPD_WITHDRAW_H |
25 | 25 | ||
26 | #include <gnunet/gnunet_util_lib.h> | ||
27 | #include <microhttpd.h> | 26 | #include <microhttpd.h> |
28 | #include "taler-mint-httpd.h" | 27 | #include "taler-mint-httpd.h" |
29 | 28 | ||