diff options
Diffstat (limited to 'src/mint/taler-mint-httpd_withdraw.c')
-rw-r--r-- | src/mint/taler-mint-httpd_withdraw.c | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/src/mint/taler-mint-httpd_withdraw.c b/src/mint/taler-mint-httpd_withdraw.c index 5259c7fbf..1cf410910 100644 --- a/src/mint/taler-mint-httpd_withdraw.c +++ b/src/mint/taler-mint-httpd_withdraw.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include "mint.h" | 32 | #include "mint.h" |
33 | #include "mint_db.h" | 33 | #include "mint_db.h" |
34 | #include "taler_signatures.h" | 34 | #include "taler_signatures.h" |
35 | #include "taler_rsa.h" | ||
36 | #include "taler_json_lib.h" | 35 | #include "taler_json_lib.h" |
37 | #include "taler-mint-httpd_parsing.h" | 36 | #include "taler-mint-httpd_parsing.h" |
38 | #include "taler-mint-httpd_keys.h" | 37 | #include "taler-mint-httpd_keys.h" |
@@ -94,6 +93,12 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, | |||
94 | { | 93 | { |
95 | struct TALER_WithdrawRequest wsrd; | 94 | struct TALER_WithdrawRequest wsrd; |
96 | int res; | 95 | int res; |
96 | const struct GNUNET_CRYPTO_rsa_PublicKey *denomination_pub; | ||
97 | char *denomination_pub_data; | ||
98 | size_t denomination_pub_data_size; | ||
99 | char *blinded_msg; | ||
100 | size_t blinded_msg_len; | ||
101 | const struct GNUNET_CRYPTO_EddsaSignature signature; | ||
97 | 102 | ||
98 | res = TALER_MINT_mhd_request_arg_data (connection, | 103 | res = TALER_MINT_mhd_request_arg_data (connection, |
99 | "reserve_pub", | 104 | "reserve_pub", |
@@ -105,33 +110,66 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, | |||
105 | return MHD_YES; /* invalid request */ | 110 | return MHD_YES; /* invalid request */ |
106 | 111 | ||
107 | /* FIXME: handle variable-size signing keys! */ | 112 | /* FIXME: handle variable-size signing keys! */ |
108 | res = TALER_MINT_mhd_request_arg_data (connection, | 113 | res = TALER_MINT_mhd_request_var_arg_data (connection, |
109 | "denom_pub", | 114 | "denom_pub", |
110 | &wsrd.denomination_pub, | 115 | &denomination_pub_data, |
111 | sizeof (struct TALER_RSA_PublicKeyBinaryEncoded)); | 116 | &denomination_pub_data_size); |
112 | if (GNUNET_SYSERR == res) | 117 | if (GNUNET_SYSERR == res) |
113 | return MHD_NO; /* internal error */ | 118 | return MHD_NO; /* internal error */ |
114 | if (GNUNET_NO == res) | 119 | if (GNUNET_NO == res) |
115 | return MHD_YES; /* invalid request */ | 120 | return MHD_YES; /* invalid request */ |
116 | res = TALER_MINT_mhd_request_arg_data (connection, | 121 | res = TALER_MINT_mhd_request_var_arg_data (connection, |
117 | "coin_ev", | 122 | "coin_ev", |
118 | &wsrd.coin_envelope, | 123 | &blinded_msg, |
119 | sizeof (struct TALER_RSA_Signature)); | 124 | &blinded_msg_len); |
120 | if (GNUNET_SYSERR == res) | 125 | if (GNUNET_SYSERR == res) |
121 | return MHD_NO; /* internal error */ | 126 | return MHD_NO; /* internal error */ |
122 | if (GNUNET_NO == res) | 127 | if (GNUNET_NO == res) |
123 | return MHD_YES; /* invalid request */ | 128 | return MHD_YES; /* invalid request */ |
124 | res = TALER_MINT_mhd_request_arg_data (connection, | 129 | res = TALER_MINT_mhd_request_arg_data (connection, |
125 | "reserve_sig", | 130 | "reserve_sig", |
126 | &wsrd.sig, | 131 | &signature, |
127 | sizeof (struct GNUNET_CRYPTO_EddsaSignature)); | 132 | sizeof (struct GNUNET_CRYPTO_EddsaSignature)); |
128 | if (GNUNET_SYSERR == res) | 133 | if (GNUNET_SYSERR == res) |
129 | return MHD_NO; /* internal error */ | 134 | return MHD_NO; /* internal error */ |
130 | if (GNUNET_NO == res) | 135 | if (GNUNET_NO == res) |
131 | return MHD_YES; /* invalid request */ | 136 | return MHD_YES; /* invalid request */ |
132 | 137 | ||
133 | return TALER_MINT_db_execute_withdraw_sign (connection, | 138 | /* verify signature! */ |
134 | &wsrd); | 139 | wsrd.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest)); |
140 | wsrd.purpose.type = htonl (TALER_SIGNATURE_WITHDRAW); | ||
141 | GNUNET_CRYPTO_hash (denomination_pub_data, | ||
142 | denomination_pub_data_size, | ||
143 | &wsrd.h_denomination_pub); | ||
144 | GNUNET_CRYPTO_hash (blinded_msg, | ||
145 | blinded_msg_len, | ||
146 | &wsrd.h_coin_envelope); | ||
147 | if (GNUNET_OK != | ||
148 | GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WITHDRAW, | ||
149 | &wsrd.purpose, | ||
150 | &signature, | ||
151 | &wsrd.reserve_pub)) | ||
152 | { | ||
153 | return 42; // FIXME: generate error reply | ||
154 | } | ||
155 | denomination_pub = GNUNET_CRYPTO_rsa_private_key_decode (denomination_pub_data, | ||
156 | denomination_pub_data_size); | ||
157 | if (NULL == denomination_pub) | ||
158 | { | ||
159 | GNUNET_free (denomination_pub_data); | ||
160 | GNUNET_free (blinded_msg); | ||
161 | return 42; // FIXME: generate error reply | ||
162 | } | ||
163 | res = TALER_MINT_db_execute_withdraw_sign (connection, | ||
164 | &wsrd.reserve_pub, | ||
165 | denomination_pub, | ||
166 | blinded_msg, | ||
167 | blinded_msg_len, | ||
168 | &signature); | ||
169 | GNUNET_free (denomination_pub_data); | ||
170 | GNUNET_free (blinded_msg); | ||
171 | GNUNET_CRYPTO_rsa_public_key_free (denomination_pub); | ||
172 | return res; | ||
135 | } | 173 | } |
136 | 174 | ||
137 | /* end of taler-mint-httpd_withdraw.c */ | 175 | /* end of taler-mint-httpd_withdraw.c */ |