diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-01 23:38:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-01 23:38:53 +0100 |
commit | c9c8caea1a716d7246853e69b0148ffa3bee696d (patch) | |
tree | dada332f4e98df9eafe48b6ee7de4431d034c1ac | |
parent | e1d16d11269a1fae896e200afd70e38d0040928d (diff) | |
download | merchant-c9c8caea1a716d7246853e69b0148ffa3bee696d.tar.gz merchant-c9c8caea1a716d7246853e69b0148ffa3bee696d.tar.bz2 merchant-c9c8caea1a716d7246853e69b0148ffa3bee696d.zip |
fix fTBFS
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 9 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 7 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_helper.c | 33 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-pay.c | 4 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_post-tips-ID-pickup.c | 25 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-instances-ID.c | 8 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-patch-instances-ID.c | 5 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-instances.c | 23 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 15 | ||||
-rw-r--r-- | src/include/taler_merchant_service.h | 14 | ||||
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 4 | ||||
-rw-r--r-- | src/lib/merchant_api_tip_pickup.c | 6 | ||||
-rw-r--r-- | src/lib/merchant_api_tip_pickup2.c | 9 |
13 files changed, 65 insertions, 97 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 6f3dc784..749fc253 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -218,7 +218,7 @@ instance_decref (struct TMH_MerchantInstance *mi) GNUNET_CONTAINER_DLL_remove (mi->wm_head, mi->wm_tail, wm); - json_decref (wm->j_wire); + GNUNET_free (wm->payto_uri); GNUNET_free (wm->wire_method); GNUNET_free (wm); } @@ -1545,11 +1545,8 @@ add_instance_cb (void *cls, wm = GNUNET_new (struct TMH_WireMethod); wm->h_wire = acc->h_wire; - wm->j_wire = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - acc->payto_uri), - GNUNET_JSON_pack_data_auto ("salt", - &acc->salt)); + wm->payto_uri = GNUNET_strdup (acc->payto_uri); + wm->wire_salt = acc->salt; wm->wire_method = TALER_payto_get_method (acc->payto_uri); wm->active = acc->active; GNUNET_CONTAINER_DLL_insert (mi->wm_head, diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index 1b18cdd4..91d83c53 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -58,7 +58,12 @@ struct TMH_WireMethod /** * Wire details for this instance */ - struct json_t *j_wire; + char *payto_uri; + + /** + * Salt to use when computing @e h_wire from @e payto_uri. + */ + struct TALER_WireSalt wire_salt; /** * Hash of our wire format details as given in #j_wire. diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c index f4129e0e..8c15a542 100644 --- a/src/backend/taler-merchant-httpd_helper.c +++ b/src/backend/taler-merchant-httpd_helper.c @@ -315,26 +315,29 @@ TMH_taxes_array_valid (const json_t *taxes) struct TMH_WireMethod * TMH_setup_wire_account (const char *payto_uri) { - struct TALER_WireSalt salt; struct TMH_WireMethod *wm; + char *emsg; + + if (NULL != (emsg = TALER_payto_validate (payto_uri))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Invalid URI `%s': %s\n", + payto_uri, + emsg); + GNUNET_free (emsg); + return NULL; + } - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, - &salt, - sizeof (salt)); wm = GNUNET_new (struct TMH_WireMethod); - wm->j_wire = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), - GNUNET_JSON_pack_data_auto ("salt", - &salt)); - GNUNET_assert (NULL != wm->j_wire); - /* This also tests for things like the IBAN being malformed */ - GNUNET_assert (GNUNET_OK == - TALER_JSON_merchant_wire_signature_hash (wm->j_wire, - &wm->h_wire)); + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, + &wm->wire_salt, + sizeof (wm->wire_salt)); + wm->payto_uri = GNUNET_strdup (payto_uri); + TALER_merchant_wire_signature_hash (payto_uri, + &wm->wire_salt, + &wm->h_wire); wm->wire_method = TALER_payto_get_method (payto_uri); - GNUNET_assert (NULL != wm->wire_method); /* checked earlier */ wm->active = true; return wm; } diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c index 04d174eb..064b0be5 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -835,12 +835,12 @@ process_pay_with_exchange (void *cls, dc->refund_fee = denom_details->fee_refund; dc->wire_fee = *wire_fee; GNUNET_assert (NULL != pc->wm); - GNUNET_assert (NULL != pc->wm->j_wire); TMH_db->preflight (TMH_db->cls); dc->dh = TALER_EXCHANGE_deposit (exchange_handle, &dc->amount_with_fee, pc->wire_transfer_deadline, - pc->wm->j_wire, + pc->wm->payto_uri, + &pc->wm->wire_salt, &pc->h_contract_terms, NULL, /* FIXME-Oec */ &dc->coin_pub, diff --git a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c index 99d7957e..fc4c6bda 100644 --- a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c +++ b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c @@ -249,9 +249,6 @@ pick_context_cleanup (void *cls) } -/** - * We are shutting down, force resuming all suspended pickup operations. - */ void TMH_force_tip_pickup_resume () { @@ -278,7 +275,7 @@ TMH_force_tip_pickup_resume () static void withdraw_cb (void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, - const struct GNUNET_CRYPTO_RsaSignature *blind_sig) + const struct TALER_BlindedDenominationSignature *blind_sig) { struct PlanchetOperation *po = cls; struct PickupContext *pc = po->pc; @@ -594,15 +591,6 @@ reply_lookup_tip_failed (struct MHD_Connection *connection, } -/** - * Manages a POST /tips/$ID/pickup call, checking that the tip is authorized, - * and if so, returning the blind signatures. - * - * @param rh context of the handler - * @param connection the MHD connection to handle - * @param[in,out] hc context with further information about the request - * @return MHD result code - */ MHD_RESULT TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, @@ -782,7 +770,8 @@ RETRY: NULL); } { - struct GNUNET_CRYPTO_RsaSignature *sigs[GNUNET_NZL (pc->planchets_length)]; + struct TALER_BlindedDenominationSignature sigs[ + GNUNET_NZL (pc->planchets_length)]; memset (sigs, 0, @@ -803,7 +792,7 @@ RETRY: for (unsigned int i = 0; i< pc->planchets_length; i++) { - if (NULL != sigs[i]) + if (TALER_DENOMINATION_INVALID == sigs[i].cipher) continue; if (! rollback) { @@ -847,9 +836,9 @@ RETRY: json_array_append_new ( blind_sigs, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_rsa_signature ("blind_sig", - sigs[i])))); - GNUNET_CRYPTO_rsa_signature_free (sigs[i]); + TALER_JSON_pack_blinded_denom_sig ("blind_sig", + &sigs[i])))); + TALER_blinded_denom_sig_free (&sigs[i]); } return TALER_MHD_REPLY_JSON_PACK ( connection, diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID.c b/src/backend/taler-merchant-httpd_private-get-instances-ID.c index 95a3e5ea..85b3c7df 100644 --- a/src/backend/taler-merchant-httpd_private-get-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-instances-ID.c @@ -51,14 +51,12 @@ get_instances_ID (struct TMH_MerchantInstance *mi, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ( "payto_uri", - json_string_value (json_object_get (wm->j_wire, - "payto_uri"))), + wm->payto_uri), GNUNET_JSON_pack_data_auto ("h_wire", &wm->h_wire), - GNUNET_JSON_pack_string ( + GNUNET_JSON_pack_data_auto ( "salt", - json_string_value (json_object_get (wm->j_wire, - "salt"))), + &wm->wire_salt), GNUNET_JSON_pack_bool ("active", wm->active)))); } diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c index 607c3593..d7ebc1f2 100644 --- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -42,7 +42,7 @@ static void free_wm (struct TMH_WireMethod *wm) { - json_decref (wm->j_wire); + GNUNET_free (wm->payto_uri); GNUNET_free (wm->wire_method); GNUNET_free (wm); } @@ -208,8 +208,7 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, NULL != wm; wm = wm->next) { - const char *uri = json_string_value (json_object_get (wm->j_wire, - "payto_uri")); + const char *uri = wm->payto_uri; GNUNET_assert (NULL != uri); matched = false; diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 7951652a..71be2673 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -60,8 +60,7 @@ accounts_equal (const struct TMH_MerchantInstance *mi, NULL != wm; wm = wm->next) { - const char *uri = json_string_value (json_object_get (wm->j_wire, - "payto_uri")); + const char *uri = wm->payto_uri; GNUNET_assert (NULL != uri); for (unsigned int i = 0; i<len; i++) @@ -99,7 +98,7 @@ accounts_equal (const struct TMH_MerchantInstance *mi, static void free_wm (struct TMH_WireMethod *wm) { - json_decref (wm->j_wire); + GNUNET_free (wm->payto_uri); GNUNET_free (wm->wire_method); GNUNET_free (wm); } @@ -411,21 +410,13 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, NULL != wm; wm = wm->next) { - struct TALER_MERCHANTDB_AccountDetails ad; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("payto_uri", - &ad.payto_uri), - GNUNET_JSON_spec_fixed_auto ("salt", - &ad.salt), - GNUNET_JSON_spec_end () + struct TALER_MERCHANTDB_AccountDetails ad = { + .payto_uri = wm->payto_uri, + .salt = wm->wire_salt, + .h_wire = wm->h_wire, + .active = wm->active }; - GNUNET_assert (GNUNET_OK == - TALER_MHD_parse_json_data (NULL, - wm->j_wire, - spec)); - ad.h_wire = wm->h_wire; - ad.active = wm->active; qs = TMH_db->insert_account (TMH_db->cls, mi->settings.id, &ad); diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index ffd8fd71..4f4966f6 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -6122,7 +6122,7 @@ struct LookupSignaturesContext /** * Where to store the signatures. */ - struct GNUNET_CRYPTO_RsaSignature **sigs; + struct TALER_BlindedDenominationSignature *sigs; }; @@ -6144,12 +6144,12 @@ lookup_signatures_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { uint32_t offset; - struct GNUNET_CRYPTO_RsaSignature *bsig; + struct TALER_BlindedDenominationSignature bsig; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint32 ("coin_offset", &offset), - GNUNET_PQ_result_spec_rsa_signature ("blind_sig", - &bsig), + TALER_PQ_result_spec_blinded_denom_sig ("blind_sig", + &bsig), GNUNET_PQ_result_spec_end }; @@ -6170,7 +6170,6 @@ lookup_signatures_cb (void *cls, /* Must be NULL due to UNIQUE constraint on offset and requirement that client launched us with 'sigs' pre-initialized to NULL. */ - GNUNET_assert (NULL == lsc->sigs[offset]); lsc->sigs[offset] = bsig; } } @@ -6198,7 +6197,7 @@ postgres_lookup_pickup (void *cls, char **exchange_url, struct TALER_ReservePrivateKeyP *reserve_priv, unsigned int sigs_length, - struct GNUNET_CRYPTO_RsaSignature *sigs[]) + struct TALER_BlindedDenominationSignature sigs[]) { struct PostgresClosure *pg = cls; uint64_t pickup_serial; @@ -6732,13 +6731,13 @@ postgres_insert_pickup_blind_signature ( void *cls, const struct GNUNET_HashCode *pickup_id, uint32_t offset, - const struct GNUNET_CRYPTO_RsaSignature *blind_sig) + const struct TALER_BlindedDenominationSignature *blind_sig) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (pickup_id), GNUNET_PQ_query_param_uint32 (&offset), - GNUNET_PQ_query_param_rsa_signature (blind_sig), + TALER_PQ_query_param_blinded_denom_sig (blind_sig), GNUNET_PQ_query_param_end }; diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 9ba1b628..92ea69d2 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -3671,18 +3671,6 @@ TALER_MERCHANT_tip_pickup_cancel (struct TALER_MERCHANT_TipPickupHandle *tph); */ struct TALER_MERCHANT_TipPickup2Handle; -/** - * A blind signature returned via tipping API. - */ - -struct TALER_MERCHANT_BlindSignature -{ - /** - * We use RSA. - */ - const struct GNUNET_CRYPTO_RsaSignature *blind_sig; -}; - /** * Callback for a POST /tips/$TIP_ID/pickup request. Returns the result of @@ -3699,7 +3687,7 @@ typedef void void *cls, const struct TALER_MERCHANT_HttpResponse *hr, unsigned int num_blind_sigs, - const struct TALER_MERCHANT_BlindSignature blind_sigs[]); + const struct TALER_BlindedDenominationSignature blind_sigs[]); /** diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 929ad7af..19e59812 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -2194,7 +2194,7 @@ struct TALER_MERCHANTDB_Plugin char **exchange_url, struct TALER_ReservePrivateKeyP *reserve_priv, unsigned int sigs_length, - struct GNUNET_CRYPTO_RsaSignature *sigs[]); + struct TALER_BlindedDenominationSignature sigs[]); /** @@ -2318,7 +2318,7 @@ struct TALER_MERCHANTDB_Plugin void *cls, const struct GNUNET_HashCode *pickup_id, uint32_t offset, - const struct GNUNET_CRYPTO_RsaSignature *blind_sig); + const struct TALER_BlindedDenominationSignature *blind_sig); }; diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c index 5538d71c..9d3a27d7 100644 --- a/src/lib/merchant_api_tip_pickup.c +++ b/src/lib/merchant_api_tip_pickup.c @@ -101,7 +101,7 @@ static void pickup_done_cb (void *cls, const struct TALER_MERCHANT_HttpResponse *hr, unsigned int num_blind_sigs, - const struct TALER_MERCHANT_BlindSignature *blind_sigs) + const struct TALER_BlindedDenominationSignature *blind_sigs) { struct TALER_MERCHANT_TipPickupHandle *tp = cls; @@ -117,7 +117,7 @@ pickup_done_cb (void *cls, } { struct TALER_DenominationSignature sigs[num_blind_sigs]; - int ok; + enum GNUNET_GenericReturnValue ok; ok = GNUNET_OK; memset (sigs, @@ -129,7 +129,7 @@ pickup_done_cb (void *cls, if (GNUNET_OK != TALER_planchet_to_coin (&tp->planchets[i].pk.key, - blind_sigs[i].blind_sig, + &blind_sigs[i], &tp->planchets[i].ps, &tp->planchets[i].c_hash, &fc)) diff --git a/src/lib/merchant_api_tip_pickup2.c b/src/lib/merchant_api_tip_pickup2.c index 38ad77d8..ab5418f2 100644 --- a/src/lib/merchant_api_tip_pickup2.c +++ b/src/lib/merchant_api_tip_pickup2.c @@ -115,14 +115,14 @@ check_ok (struct TALER_MERCHANT_TipPickup2Handle *tpo, return GNUNET_SYSERR; } { - struct TALER_MERCHANT_BlindSignature mblind_sigs[ja_len]; - struct GNUNET_CRYPTO_RsaSignature *blind_sigs[ja_len]; + struct TALER_BlindedDenominationSignature mblind_sigs[ja_len]; for (unsigned int i = 0; i<ja_len; i++) { json_t *pj = json_array_get (ja, i); struct GNUNET_JSON_Specification ispec[] = { - GNUNET_JSON_spec_rsa_signature ("blind_sig", &blind_sigs[i]), + TALER_JSON_spec_blinded_denom_sig ("blind_sig", + &mblind_sigs[i]), GNUNET_JSON_spec_end () }; @@ -135,14 +135,13 @@ check_ok (struct TALER_MERCHANT_TipPickup2Handle *tpo, GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } - mblind_sigs[i].blind_sig = blind_sigs[i]; } tpo->cb (tpo->cb_cls, &hr, ja_len, mblind_sigs); for (unsigned int i = 0; i<ja_len; i++) - GNUNET_CRYPTO_rsa_signature_free (blind_sigs[i]); + TALER_blinded_denom_sig_free (&mblind_sigs[i]); tpo->cb = NULL; /* do not call twice */ } GNUNET_JSON_parse_free (spec); |