diff options
Diffstat (limited to 'src/mint/taler-mint-httpd_withdraw.c')
-rw-r--r-- | src/mint/taler-mint-httpd_withdraw.c | 54 |
1 files changed, 25 insertions, 29 deletions
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; |