-fix exchange FTBFS

This commit is contained in:
Christian Grothoff 2021-10-26 09:30:54 +02:00
parent 8a6d9da545
commit fd615f3e33
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
11 changed files with 70 additions and 41 deletions

@ -1 +1 @@
Subproject commit 17555514bd2866e0d45b23e4a1c198415205c8f2 Subproject commit 8c7d9be40ba627348da3e01b91b4f1d3cc78631f

View File

@ -540,7 +540,7 @@ handle_post_management (struct TEH_RequestContext *rc,
if (0 == strcmp (args[0], if (0 == strcmp (args[0],
"denominations")) "denominations"))
{ {
struct GNUNET_HashCode h_denom_pub; struct TALER_DenominationHash h_denom_pub;
if ( (NULL == args[0]) || if ( (NULL == args[0]) ||
(NULL == args[1]) || (NULL == args[1]) ||
@ -681,7 +681,7 @@ handle_post_auditors (struct TEH_RequestContext *rc,
const char *const args[]) const char *const args[])
{ {
struct TALER_AuditorPublicKeyP auditor_pub; struct TALER_AuditorPublicKeyP auditor_pub;
struct GNUNET_HashCode h_denom_pub; struct TALER_DenominationHash h_denom_pub;
if ( (NULL == args[0]) || if ( (NULL == args[0]) ||
(NULL == args[1]) || (NULL == args[1]) ||

View File

@ -64,7 +64,7 @@ TEH_handler_management_auditors_AP_disable (
MHD_RESULT MHD_RESULT
TEH_handler_management_denominations_HDP_revoke ( TEH_handler_management_denominations_HDP_revoke (
struct MHD_Connection *connection, struct MHD_Connection *connection,
const struct GNUNET_HashCode *h_denom_pub, const struct TALER_DenominationHash *h_denom_pub,
const json_t *root); const json_t *root);

View File

@ -34,7 +34,7 @@
MHD_RESULT MHD_RESULT
TEH_handler_management_denominations_HDP_revoke ( TEH_handler_management_denominations_HDP_revoke (
struct MHD_Connection *connection, struct MHD_Connection *connection,
const struct GNUNET_HashCode *h_denom_pub, const struct TALER_DenominationHash *h_denom_pub,
const json_t *root) const json_t *root)
{ {
struct TALER_MasterSignatureP master_sig; struct TALER_MasterSignatureP master_sig;

View File

@ -40,7 +40,7 @@ struct DenomSig
/** /**
* Hash of a denomination public key. * Hash of a denomination public key.
*/ */
struct GNUNET_HashCode h_denom_pub; struct TALER_DenominationHash h_denom_pub;
/** /**
* Master signature for the @e h_denom_pub. * Master signature for the @e h_denom_pub.
@ -156,14 +156,14 @@ add_keys (void *cls,
connection, connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION,
GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
case GNUNET_NO: case GNUNET_NO:
*mhd_ret = TALER_MHD_reply_with_error ( *mhd_ret = TALER_MHD_reply_with_error (
connection, connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN, TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN,
GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
case GNUNET_OK: case GNUNET_OK:
break; break;
@ -196,7 +196,7 @@ add_keys (void *cls,
connection, connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_EXCHANGE_MANAGEMENT_KEYS_DENOMKEY_ADD_SIGNATURE_INVALID, TALER_EC_EXCHANGE_MANAGEMENT_KEYS_DENOMKEY_ADD_SIGNATURE_INVALID,
GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} }
@ -208,7 +208,7 @@ add_keys (void *cls,
&denom_pub, &denom_pub,
&meta, &meta,
&akc->d_sigs[i].master_sig); &akc->d_sigs[i].master_sig);
GNUNET_CRYPTO_rsa_public_key_free (denom_pub.rsa_public_key); TALER_denom_pub_free (&denom_pub);
if (qs < 0) if (qs < 0)
{ {
if (GNUNET_DB_STATUS_SOFT_ERROR == qs) if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@ -222,7 +222,7 @@ add_keys (void *cls,
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Added offline signature for denomination `%s'\n", "Added offline signature for denomination `%s'\n",
GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));
GNUNET_assert (0 != qs); GNUNET_assert (0 != qs);
} }
@ -284,7 +284,7 @@ add_keys (void *cls,
connection, connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_ADD_SIGNATURE_INVALID, TALER_EC_EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_ADD_SIGNATURE_INVALID,
GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} }

View File

@ -68,8 +68,8 @@ reply_refreshes_reveal_success (struct MHD_Connection *connection,
json_t *obj; json_t *obj;
obj = GNUNET_JSON_PACK ( obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_rsa_signature ("ev_sig", TALER_JSON_pack_denomination_signature ("ev_sig",
sigs[freshcoin_index].rsa_signature)); &sigs[freshcoin_index]));
GNUNET_assert (0 == GNUNET_assert (0 ==
json_array_append_new (list, json_array_append_new (list,
obj)); obj));
@ -189,8 +189,8 @@ check_exists_cb (void *cls,
rctx->ev_sigs = GNUNET_new_array (num_freshcoins, rctx->ev_sigs = GNUNET_new_array (num_freshcoins,
struct TALER_DenominationSignature); struct TALER_DenominationSignature);
for (unsigned int i = 0; i<num_freshcoins; i++) for (unsigned int i = 0; i<num_freshcoins; i++)
rctx->ev_sigs[i].rsa_signature TALER_denom_sig_deep_copy (&rctx->ev_sigs[i],
= GNUNET_CRYPTO_rsa_signature_dup (rrcs[i].coin_sig.rsa_signature); &rrcs[i].coin_sig);
} }
} }
@ -334,7 +334,7 @@ refreshes_reveal_transaction (void *cls,
struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
struct TALER_PlanchetSecretsP ps; struct TALER_PlanchetSecretsP ps;
struct TALER_PlanchetDetail pd; struct TALER_PlanchetDetail pd;
struct GNUNET_HashCode c_hash; struct TALER_CoinPubHash c_hash;
rcd->dk = &rctx->dks[j]->denom_pub; rcd->dk = &rctx->dks[j]->denom_pub;
TALER_planchet_setup_refresh (&ts, TALER_planchet_setup_refresh (&ts,
@ -500,7 +500,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
unsigned int num_fresh_coins = json_array_size (new_denoms_h_json); unsigned int num_fresh_coins = json_array_size (new_denoms_h_json);
/* We know num_fresh_coins is bounded by #MAX_FRESH_COINS, so this is safe */ /* We know num_fresh_coins is bounded by #MAX_FRESH_COINS, so this is safe */
const struct TEH_DenominationKey *dks[num_fresh_coins]; const struct TEH_DenominationKey *dks[num_fresh_coins];
struct GNUNET_HashCode dk_h[num_fresh_coins]; struct TALER_DenominationHash dk_h[num_fresh_coins];
struct TALER_RefreshCoinData rcds[num_fresh_coins]; struct TALER_RefreshCoinData rcds[num_fresh_coins];
struct TALER_CoinSpendSignatureP link_sigs[num_fresh_coins]; struct TALER_CoinSpendSignatureP link_sigs[num_fresh_coins];
struct TALER_EXCHANGEDB_Melt melt; struct TALER_EXCHANGEDB_Melt melt;
@ -686,7 +686,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
struct TALER_DenominationSignature); struct TALER_DenominationSignature);
for (unsigned int i = 0; i<rctx->num_fresh_coins; i++) for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
{ {
enum TALER_ErrorCode ec; enum TALER_ErrorCode ec = TALER_EC_NONE;
rctx->ev_sigs[i] rctx->ev_sigs[i]
= TEH_keys_denomination_sign ( = TEH_keys_denomination_sign (
@ -694,7 +694,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
rctx->rcds[i].coin_ev, rctx->rcds[i].coin_ev,
rctx->rcds[i].coin_ev_size, rctx->rcds[i].coin_ev_size,
&ec); &ec);
if (NULL == rctx->ev_sigs[i].rsa_signature) if (TALER_EC_NONE != ec)
{ {
GNUNET_break (0); GNUNET_break (0);
ret = TALER_MHD_reply_with_ec (connection, ret = TALER_MHD_reply_with_ec (connection,
@ -769,8 +769,7 @@ cleanup:
if (NULL != rctx->ev_sigs) if (NULL != rctx->ev_sigs)
{ {
for (unsigned int i = 0; i<num_fresh_coins; i++) for (unsigned int i = 0; i<num_fresh_coins; i++)
if (NULL != rctx->ev_sigs[i].rsa_signature) TALER_denom_sig_free (&rctx->ev_sigs[i]);
GNUNET_CRYPTO_rsa_signature_free (rctx->ev_sigs[i].rsa_signature);
GNUNET_free (rctx->ev_sigs); GNUNET_free (rctx->ev_sigs);
rctx->ev_sigs = NULL; /* just to be safe... */ rctx->ev_sigs = NULL; /* just to be safe... */
} }

View File

@ -370,7 +370,7 @@ static MHD_RESULT
verify_and_execute_refund (struct MHD_Connection *connection, verify_and_execute_refund (struct MHD_Connection *connection,
struct TALER_EXCHANGEDB_Refund *refund) struct TALER_EXCHANGEDB_Refund *refund)
{ {
struct GNUNET_HashCode denom_hash; struct TALER_DenominationHash denom_hash;
{ {
struct TALER_RefundRequestPS rr = { struct TALER_RefundRequestPS rr = {

View File

@ -779,9 +779,8 @@ TEH_RESPONSE_compile_reserve_history (
&value); &value);
TALER_amount_hton (&rcc.closing_fee, TALER_amount_hton (&rcc.closing_fee,
&closing->closing_fee); &closing->closing_fee);
GNUNET_CRYPTO_hash (closing->receiver_account_details, TALER_payto_hash (closing->receiver_account_details,
strlen (closing->receiver_account_details) + 1, &rcc.h_payto);
&rcc.h_wire);
if (TALER_EC_NONE != if (TALER_EC_NONE !=
TEH_keys_exchange_sign (&rcc, TEH_keys_exchange_sign (&rcc,
&pub, &pub,

View File

@ -107,7 +107,7 @@ struct WithdrawContext
/** /**
* Hash of the denomination public key. * Hash of the denomination public key.
*/ */
struct GNUNET_HashCode denom_pub_hash; struct TALER_DenominationHash denom_pub_hash;
/** /**
* Signature over the request. * Signature over the request.
@ -205,7 +205,9 @@ withdraw_transaction (void *cls,
/* store away optimistic signature to protect /* store away optimistic signature to protect
it from being overwritten by get_withdraw_info */ it from being overwritten by get_withdraw_info */
denom_sig = wc->collectable.sig; denom_sig = wc->collectable.sig;
wc->collectable.sig.rsa_signature = NULL; memset (&wc->collectable.sig,
0,
sizeof (wc->collectable.sig));
#endif #endif
qs = TEH_plugin->get_withdraw_info (TEH_plugin->cls, qs = TEH_plugin->get_withdraw_info (TEH_plugin->cls,
&wc->wsrd.h_coin_envelope, &wc->wsrd.h_coin_envelope,
@ -229,7 +231,7 @@ withdraw_transaction (void *cls,
optimization trade-off loses in this case: we unnecessarily computed optimization trade-off loses in this case: we unnecessarily computed
a signature :-( */ a signature :-( */
#if OPTIMISTIC_SIGN #if OPTIMISTIC_SIGN
GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature); TALER_denom_sig_free (&denom_sig);
#endif #endif
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
} }
@ -364,14 +366,14 @@ withdraw_transaction (void *cls,
#if ! OPTIMISTIC_SIGN #if ! OPTIMISTIC_SIGN
if (NULL == wc->collectable.sig.rsa_signature) if (NULL == wc->collectable.sig.rsa_signature)
{ {
enum TALER_ErrorCode ec; enum TALER_ErrorCode ec = TALER_EC_NONE;
wc->collectable.sig wc->collectable.sig
= TEH_keys_denomination_sign (&wc->denom_pub_hash, = TEH_keys_denomination_sign (&wc->denom_pub_hash,
wc->blinded_msg, wc->blinded_msg,
wc->blinded_msg_len, wc->blinded_msg_len,
&ec); &ec);
if (NULL == wc->collectable.sig.rsa_signature) if (TALER_EC_NONE != ec)
{ {
GNUNET_break (0); GNUNET_break (0);
*mhd_ret = TALER_MHD_reply_with_ec (connection, *mhd_ret = TALER_MHD_reply_with_ec (connection,
@ -530,7 +532,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
= htonl (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW); = htonl (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW);
wc.wsrd.h_denomination_pub wc.wsrd.h_denomination_pub
= wc.denom_pub_hash; = wc.denom_pub_hash;
GNUNET_CRYPTO_hash (wc.blinded_msg, TALER_coin_ev_hash (wc.blinded_msg,
wc.blinded_msg_len, wc.blinded_msg_len,
&wc.wsrd.h_coin_envelope); &wc.wsrd.h_coin_envelope);
if (GNUNET_OK != if (GNUNET_OK !=
@ -550,12 +552,13 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
#if OPTIMISTIC_SIGN #if OPTIMISTIC_SIGN
/* Sign before transaction! */ /* Sign before transaction! */
ec = TALER_EC_NONE;
wc.collectable.sig wc.collectable.sig
= TEH_keys_denomination_sign (&wc.denom_pub_hash, = TEH_keys_denomination_sign (&wc.denom_pub_hash,
wc.blinded_msg, wc.blinded_msg,
wc.blinded_msg_len, wc.blinded_msg_len,
&ec); &ec);
if (NULL == wc.collectable.sig.rsa_signature) if (TALER_EC_NONE != ec)
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
@ -579,8 +582,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
{ {
/* Even if #withdraw_transaction() failed, it may have created a signature /* Even if #withdraw_transaction() failed, it may have created a signature
(or we might have done it optimistically above). */ (or we might have done it optimistically above). */
if (NULL != wc.collectable.sig.rsa_signature) TALER_denom_sig_free (&wc.collectable.sig);
GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature);
GNUNET_JSON_parse_free (spec); GNUNET_JSON_parse_free (spec);
return mhd_ret; return mhd_ret;
} }
@ -591,9 +593,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
if (wc.kyc_denied) if (wc.kyc_denied)
{ {
if (NULL != wc.collectable.sig.rsa_signature) TALER_denom_sig_free (&wc.collectable.sig);
GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature);
return TALER_MHD_REPLY_JSON_PACK ( return TALER_MHD_REPLY_JSON_PACK (
rc->connection, rc->connection,
MHD_HTTP_ACCEPTED, MHD_HTTP_ACCEPTED,
@ -607,9 +607,9 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
ret = TALER_MHD_REPLY_JSON_PACK ( ret = TALER_MHD_REPLY_JSON_PACK (
rc->connection, rc->connection,
MHD_HTTP_OK, MHD_HTTP_OK,
GNUNET_JSON_pack_rsa_signature ("ev_sig", TALER_JSON_pack_denomination_signature ("ev_sig",
wc.collectable.sig.rsa_signature)); &wc.collectable.sig));
GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); TALER_denom_sig_free (&wc.collectable.sig);
return ret; return ret;
} }
} }

View File

@ -673,6 +673,18 @@ TALER_denom_pub_deep_copy (struct TALER_DenominationPublicKey *denom_dst,
const struct TALER_DenominationPublicKey *denom_src); const struct TALER_DenominationPublicKey *denom_src);
/**
* Make a (deep) copy of the given @a denom_src to
* @a denom_dst.
*
* @param[out] denom_dst target to copy to
* @param denom_str public key to copy
*/
void
TALER_denom_sig_deep_copy (struct TALER_DenominationSignature *denom_dst,
const struct TALER_DenominationSignature *denom_src);
/** /**
* Compare two denomination public keys. * Compare two denomination public keys.
* *

View File

@ -195,6 +195,25 @@ TALER_denom_pub_deep_copy (struct TALER_DenominationPublicKey *denom_dst,
} }
void
TALER_denom_sig_deep_copy (struct TALER_DenominationSignature *denom_dst,
const struct TALER_DenominationSignature *denom_src)
{
*denom_dst = *denom_src; /* shallow copy */
switch (denom_src->cipher)
{
case TALER_DENOMINATION_RSA:
denom_dst->details.rsa_signature
= GNUNET_CRYPTO_rsa_signature_dup (
denom_src->details.rsa_signature);
return;
// TODO: add case for Clause-Schnorr
default:
GNUNET_assert (0);
}
}
/** /**
* Compare two denomination public keys. * Compare two denomination public keys.
* *