-more test fixes

This commit is contained in:
Christian Grothoff 2022-02-08 14:02:27 +01:00
parent 8cbe16a220
commit b3cf788424
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
10 changed files with 69 additions and 25 deletions

View File

@ -1705,9 +1705,9 @@ TALER_EXCHANGE_melt_cancel (struct TALER_EXCHANGE_MeltHandle *mh);
* *
* @param cls closure * @param cls closure
* @param hr HTTP response data * @param hr HTTP response data
* @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed * @param num_coins number of fresh coins created, length of the @a sigs, @a psa and @a coin_privs arrays, 0 if the operation failed
* @param exchange_vals array of contributions from the exchange on the refreshes
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error * @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
* @param psa array of @a num_coins planchet secrets (derived from the transfer secret) for each of the coins
* @param sigs array of signature over @a num_coins coins, NULL on error * @param sigs array of signature over @a num_coins coins, NULL on error
*/ */
typedef void typedef void
@ -1716,6 +1716,7 @@ typedef void
const struct TALER_EXCHANGE_HttpResponse *hr, const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins, unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs, const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_PlanchetSecretsP *psa,
const struct TALER_DenominationSignature *sigs); const struct TALER_DenominationSignature *sigs);

View File

@ -111,6 +111,12 @@ struct TALER_EXCHANGE_MeltHandle
* @brief Public information about the coin's denomination key * @brief Public information about the coin's denomination key
*/ */
const struct TALER_EXCHANGE_DenomPublicKey *dki; const struct TALER_EXCHANGE_DenomPublicKey *dki;
/**
* Gamma value chosen by the exchange during melt.
*/
uint32_t noreveal_index;
}; };
@ -118,17 +124,15 @@ struct TALER_EXCHANGE_MeltHandle
* Verify that the signature on the "200 OK" response * Verify that the signature on the "200 OK" response
* from the exchange is valid. * from the exchange is valid.
* *
* @param mh melt handle * @param[in,out] mh melt handle
* @param json json reply with the signature * @param json json reply with the signature
* @param[out] exchange_pub public key of the exchange used for the signature * @param[out] exchange_pub public key of the exchange used for the signature
* @param[out] noreveal_index set to the noreveal index selected by the exchange
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
*/ */
static enum GNUNET_GenericReturnValue static enum GNUNET_GenericReturnValue
verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh, verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh,
const json_t *json, const json_t *json,
struct TALER_ExchangePublicKeyP *exchange_pub, struct TALER_ExchangePublicKeyP *exchange_pub)
uint32_t *noreveal_index)
{ {
struct TALER_ExchangeSignatureP exchange_sig; struct TALER_ExchangeSignatureP exchange_sig;
const struct TALER_EXCHANGE_Keys *key_state; const struct TALER_EXCHANGE_Keys *key_state;
@ -138,7 +142,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh,
GNUNET_JSON_spec_fixed_auto ("exchange_pub", GNUNET_JSON_spec_fixed_auto ("exchange_pub",
exchange_pub), exchange_pub),
GNUNET_JSON_spec_uint32 ("noreveal_index", GNUNET_JSON_spec_uint32 ("noreveal_index",
noreveal_index), &mh->noreveal_index),
GNUNET_JSON_spec_end () GNUNET_JSON_spec_end ()
}; };
@ -161,7 +165,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh,
} }
/* check that noreveal index is in permitted range */ /* check that noreveal index is in permitted range */
if (TALER_CNC_KAPPA <= *noreveal_index) if (TALER_CNC_KAPPA <= mh->noreveal_index)
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -173,7 +177,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh,
.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT), .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT),
.purpose.size = htonl (sizeof (confirm)), .purpose.size = htonl (sizeof (confirm)),
.rc = mh->md.rc, .rc = mh->md.rc,
.noreveal_index = htonl (*noreveal_index) .noreveal_index = htonl (mh->noreveal_index)
}; };
if (GNUNET_OK != if (GNUNET_OK !=
@ -341,7 +345,6 @@ handle_melt_finished (void *cls,
const void *response) const void *response)
{ {
struct TALER_EXCHANGE_MeltHandle *mh = cls; struct TALER_EXCHANGE_MeltHandle *mh = cls;
uint32_t noreveal_index = TALER_CNC_KAPPA; /* invalid value */
struct TALER_ExchangePublicKeyP exchange_pub; struct TALER_ExchangePublicKeyP exchange_pub;
const json_t *j = response; const json_t *j = response;
struct TALER_EXCHANGE_HttpResponse hr = { struct TALER_EXCHANGE_HttpResponse hr = {
@ -359,8 +362,7 @@ handle_melt_finished (void *cls,
if (GNUNET_OK != if (GNUNET_OK !=
verify_melt_signature_ok (mh, verify_melt_signature_ok (mh,
j, j,
&exchange_pub, &exchange_pub))
&noreveal_index))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
hr.http_status = 0; hr.http_status = 0;
@ -379,7 +381,7 @@ handle_melt_finished (void *cls,
(0 == hr.http_status) (0 == hr.http_status)
? NULL ? NULL
: mh->bks, : mh->bks,
noreveal_index, mh->noreveal_index,
(0 == hr.http_status) (0 == hr.http_status)
? NULL ? NULL
: &exchange_pub); : &exchange_pub);
@ -469,6 +471,13 @@ handle_melt_finished (void *cls,
} }
/**
* Start the actual melt operation, now that we have
* the exchange's input values.
*
* @param[in,out] mh melt operation to run
* @return #GNUNET_OK if we could start the operation
*/
static enum GNUNET_GenericReturnValue static enum GNUNET_GenericReturnValue
start_melt (struct TALER_EXCHANGE_MeltHandle *mh) start_melt (struct TALER_EXCHANGE_MeltHandle *mh)
{ {
@ -644,6 +653,7 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
TEAH_handle_is_ready (exchange)); TEAH_handle_is_ready (exchange));
mh = GNUNET_new (struct TALER_EXCHANGE_MeltHandle); mh = GNUNET_new (struct TALER_EXCHANGE_MeltHandle);
mh->noreveal_index = TALER_CNC_KAPPA; /* invalid value */
mh->exchange = exchange; mh->exchange = exchange;
mh->rd = rd; mh->rd = rd;
mh->ps = ps; mh->ps = ps;

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2015-2021 Taler Systems SA Copyright (C) 2015-2022 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software terms of the GNU General Public License as published by the Free Software

View File

@ -250,10 +250,12 @@ handle_refresh_reveal_finished (void *cls,
} }
else else
{ {
GNUNET_assert (rrh->noreveal_index < TALER_CNC_KAPPA);
rrh->reveal_cb (rrh->reveal_cb_cls, rrh->reveal_cb (rrh->reveal_cb_cls,
&hr, &hr,
rrh->md.num_fresh_coins, rrh->md.num_fresh_coins,
coin_privs, coin_privs,
rrh->md.fresh_coins[rrh->noreveal_index],
sigs); sigs);
rrh->reveal_cb = NULL; rrh->reveal_cb = NULL;
} }
@ -302,6 +304,7 @@ handle_refresh_reveal_finished (void *cls,
&hr, &hr,
0, 0,
NULL, NULL,
NULL,
NULL); NULL);
TALER_EXCHANGE_refreshes_reveal_cancel (rrh); TALER_EXCHANGE_refreshes_reveal_cancel (rrh);
} }

View File

@ -503,7 +503,8 @@ EXTRA_DIST = \
test_exchange_api_twisted.conf \ test_exchange_api_twisted.conf \
test_exchange_api_keys_cherry_picking-cs.conf \ test_exchange_api_keys_cherry_picking-cs.conf \
test_exchange_api_keys_cherry_picking-rsa.conf \ test_exchange_api_keys_cherry_picking-rsa.conf \
test_exchange_api_expire_reserve_now.conf \ test_exchange_api_expire_reserve_now-cs.conf \
test_exchange_api_expire_reserve_now-rsa.conf \
test_taler_exchange_httpd_home/.config/taler/account-1.json \ test_taler_exchange_httpd_home/.config/taler/account-1.json \
test_taler_exchange_httpd_home/.local/share/taler/exchange-offline/master.priv \ test_taler_exchange_httpd_home/.local/share/taler/exchange-offline/master.priv \
test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \ test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \

View File

@ -1,4 +1,4 @@
@INLINE@ test_exchange_api.conf @INLINE@ test_exchange_api-cs.conf
[exchangedb] [exchangedb]
IDLE_RESERVE_EXPIRATION_TIME = 0 s IDLE_RESERVE_EXPIRATION_TIME = 0 s

View File

@ -0,0 +1,4 @@
@INLINE@ test_exchange_api-rsa.conf
[exchangedb]
IDLE_RESERVE_EXPIRATION_TIME = 0 s

View File

@ -230,6 +230,7 @@ recoup_refresh_run (void *cls,
{ {
struct RecoupRefreshState *ps = cls; struct RecoupRefreshState *ps = cls;
const struct TALER_TESTING_Command *coin_cmd; const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_TESTING_Command *melt_cmd;
const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_CoinSpendPrivateKeyP *coin_priv;
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *coin_sig; const struct TALER_DenominationSignature *coin_sig;
@ -251,13 +252,21 @@ recoup_refresh_run (void *cls,
coin_cmd = TALER_TESTING_interpreter_lookup_command (is, coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
cref); cref);
GNUNET_free (cref); GNUNET_free (cref);
if (NULL == coin_cmd) if (NULL == coin_cmd)
{ {
GNUNET_break (0); GNUNET_break (0);
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
melt_cmd = TALER_TESTING_interpreter_lookup_command (is,
ps->melt_reference);
if (NULL == melt_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_OK != if (GNUNET_OK !=
TALER_TESTING_get_trait_coin_priv (coin_cmd, TALER_TESTING_get_trait_coin_priv (coin_cmd,
idx, idx,
@ -268,7 +277,7 @@ recoup_refresh_run (void *cls,
return; return;
} }
if (GNUNET_OK != if (GNUNET_OK !=
TALER_TESTING_get_trait_exchange_wd_value (coin_cmd, TALER_TESTING_get_trait_exchange_wd_value (melt_cmd,
idx, idx,
&ewv)) &ewv))
{ {

View File

@ -117,12 +117,12 @@ struct RefreshMeltState
struct TALER_EXCHANGE_DenomPublicKey *fresh_pks; struct TALER_EXCHANGE_DenomPublicKey *fresh_pks;
/** /**
* Array of @a num_fresh_coins of exchange values contributed to the refresh operation * Array of @e num_fresh_coins of exchange values contributed to the refresh operation
*/ */
struct TALER_ExchangeWithdrawValues *alg_values; struct TALER_ExchangeWithdrawValues *alg_values;
/** /**
* Array of @a num_fresh_coins of blinding key secrets * Array of @e num_fresh_coins of blinding key secrets
* created during the melt operation. * created during the melt operation.
*/ */
union TALER_DenominationBlindingKeyP *bks; union TALER_DenominationBlindingKeyP *bks;
@ -214,6 +214,12 @@ struct RefreshRevealState
*/ */
struct TALER_TESTING_FreshCoinData *fresh_coins; struct TALER_TESTING_FreshCoinData *fresh_coins;
/**
* Array of @e num_fresh_coins planchet secrets derived
* from the transfer secret per fresh coin.
*/
struct TALER_PlanchetSecretsP *psa;
/** /**
* Interpreter state. * Interpreter state.
*/ */
@ -346,6 +352,7 @@ do_reveal_retry (void *cls)
* failed. * failed.
* @param coin_privs array of @a num_coins private keys for the * @param coin_privs array of @a num_coins private keys for the
* coins that were created, NULL on error. * coins that were created, NULL on error.
* @param psa array of @a num_coins planchet secrets (derived from the transfer secret) for each of the coins
* @param sigs array of signature over @a num_coins coins, * @param sigs array of signature over @a num_coins coins,
* NULL on error. * NULL on error.
*/ */
@ -354,6 +361,7 @@ reveal_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr, const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins, unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs, const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_PlanchetSecretsP *psa,
const struct TALER_DenominationSignature *sigs) const struct TALER_DenominationSignature *sigs)
{ {
struct RefreshRevealState *rrs = cls; struct RefreshRevealState *rrs = cls;
@ -413,6 +421,9 @@ reveal_cb (void *cls,
switch (hr->http_status) switch (hr->http_status)
{ {
case MHD_HTTP_OK: case MHD_HTTP_OK:
rrs->psa = GNUNET_memdup (psa,
num_coins
* sizeof (struct TALER_PlanchetSecretsP));
rrs->fresh_coins = GNUNET_new_array (num_coins, rrs->fresh_coins = GNUNET_new_array (num_coins,
struct TALER_TESTING_FreshCoinData); struct TALER_TESTING_FreshCoinData);
for (unsigned int i = 0; i<num_coins; i++) for (unsigned int i = 0; i<num_coins; i++)
@ -540,7 +551,7 @@ refresh_reveal_cleanup (void *cls,
TALER_denom_sig_free (&rrs->fresh_coins[j].sig); TALER_denom_sig_free (&rrs->fresh_coins[j].sig);
GNUNET_free (rrs->fresh_coins); GNUNET_free (rrs->fresh_coins);
rrs->fresh_coins = NULL; GNUNET_free (rrs->psa);
rrs->num_fresh_coins = 0; rrs->num_fresh_coins = 0;
GNUNET_free (rrs); GNUNET_free (rrs);
} }
@ -806,8 +817,10 @@ refresh_link_run (void *cls,
} }
const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_CoinSpendPrivateKeyP *coin_priv;
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv if (GNUNET_OK !=
(coin_cmd, 0, &coin_priv)) TALER_TESTING_get_trait_coin_priv (coin_cmd,
0,
&coin_priv))
{ {
GNUNET_break (0); GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is); TALER_TESTING_interpreter_fail (rls->is);
@ -1216,9 +1229,10 @@ melt_traits (void *cls,
&rms->fresh_pks[index]), &rms->fresh_pks[index]),
TALER_TESTING_make_trait_coin_priv (0, TALER_TESTING_make_trait_coin_priv (0,
rms->melt_priv), rms->melt_priv),
// ????
TALER_TESTING_make_trait_blinding_key (index, TALER_TESTING_make_trait_blinding_key (index,
&rms->bks[index]), &rms->bks[index]),
TALER_TESTING_make_trait_exchange_wd_value (index,
&rms->alg_values[index]),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
}; };
@ -1392,6 +1406,8 @@ refresh_reveal_traits (void *cls,
&rrs->num_fresh_coins), &rrs->num_fresh_coins),
TALER_TESTING_make_trait_fresh_coins ( TALER_TESTING_make_trait_fresh_coins (
(const struct TALER_TESTING_FreshCoinData **) &rrs->fresh_coins), (const struct TALER_TESTING_FreshCoinData **) &rrs->fresh_coins),
TALER_TESTING_make_trait_planchet_secrets (index,
&rrs->psa[index]),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
}; };

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2018-2021 Taler Systems SA Copyright (C) 2018-2022 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it TALER is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by