aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-10-07 15:55:19 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-10-07 15:55:19 +0200
commit73b7d234d0fea13897a75c36c5ee73c2c199beca (patch)
treec71c0b4d0a0836306c3ac268fe63169e30ab4a26
parent61cc8f9d3608ca7af2e5f7baedf8ee367bd77b0a (diff)
re-closing #4702
-rw-r--r--src/backend/taler-merchant-httpd_pay.c8
-rw-r--r--src/lib/test_merchant_api.c35
2 files changed, 31 insertions, 12 deletions
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index 8957d7e4..85a8adf4 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -411,15 +411,19 @@ deposit_cb (void *cls,
mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
mr.purpose.size = htonl (sizeof (mr));
+ mr.h_contract = pc->h_contract;
GNUNET_CRYPTO_eddsa_sign (&mi->privkey.eddsa_priv,
&mr.purpose,
&sig);
resume_pay_with_response (pc,
MHD_HTTP_OK,
- TMH_RESPONSE_make_json_pack ("{s:s}",
+ TMH_RESPONSE_make_json_pack ("{s:s, s:o}",
"merchant_sig",
- json_string_value (GNUNET_JSON_from_data_auto (&sig))));
+ json_string_value (GNUNET_JSON_from_data_auto (&sig)),
+ "h_contract",
+ GNUNET_JSON_from_data (&pc->h_contract,
+ sizeof (struct GNUNET_HashCode))));
}
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index fb39097f..cefe4f2f 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1071,7 +1071,9 @@ pay_cb (void *cls,
struct Command *cmd = &is->commands[is->ip];
struct PaymentResponsePS mr;
struct GNUNET_CRYPTO_EddsaSignature sig;
- json_t *jsig;
+ struct GNUNET_HashCode h_contract;
+ const char *error_name;
+ unsigned int error_line;
cmd->details.pay.ph = NULL;
if (cmd->expected_response_code != http_status)
@@ -1087,20 +1089,33 @@ pay_cb (void *cls,
if (MHD_HTTP_OK == http_status)
{
/* Check signature */
- GNUNET_break (NULL !=
- (jsig = json_object_get (obj, "merchant_sig")));
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("merchant_sig", &sig),
+ GNUNET_JSON_spec_fixed_auto ("h_contract", &h_contract),
+ GNUNET_JSON_spec_end ()
+ };
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (obj,
+ spec,
+ &error_name,
+ &error_line))
+ {
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Parser failed on %s:%u\n",
+ error_name,
+ error_line);
+ fail (is);
+ return;
+ }
mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
mr.purpose.size = htonl (sizeof (mr));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_STRINGS_string_to_data (json_string_value (jsig),
- strlen (json_string_value (jsig)),
- &sig,
- sizeof (sig)));
+ mr.h_contract = h_contract;
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
&mr.purpose,
- &sig,
- &cmd->details.pay.merchant_pub.eddsa_pub))
+ &sig,
+ &cmd->details.pay.merchant_pub.eddsa_pub))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Merchant signature given in response to /pay invalid\n");