fix refreshes_reveal FTBFS

This commit is contained in:
Christian Grothoff 2022-02-07 13:41:55 +01:00
parent 169d684342
commit b84fb618c3
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 66 additions and 21 deletions

View File

@ -200,10 +200,7 @@ check_commitment (struct RevealContext *rctx,
&coin_priv, &coin_priv,
&c_hash, &c_hash,
&pd)); &pd));
rcd->coin_ev = rcd->blinded_planchet = pd.blinded_planchet;
pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg;
rcd->coin_ev_size =
pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg_size;
} }
} }
} }
@ -225,7 +222,7 @@ check_commitment (struct RevealContext *rctx,
{ {
struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
GNUNET_free (rcd->coin_ev); TALER_blinded_planchet_free (&rcd->blinded_planchet);
} }
GNUNET_free (rce->new_coins); GNUNET_free (rce->new_coins);
} }
@ -493,9 +490,18 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i]; const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
struct TALER_RefreshCoinData *rcd = &rcds[i]; struct TALER_RefreshCoinData *rcd = &rcds[i];
rcd->coin_ev = rrc->coin_ev; rcd->blinded_planchet = rrc->blinded_planchet;
rcd->coin_ev_size = rrc->coin_ev_size;
rcd->dk = &dks[i]->denom_pub; rcd->dk = &dks[i]->denom_pub;
if (rcd->blinded_planchet.cipher != rcd->dk->cipher)
{
GNUNET_break_op (0);
ret = TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_BAD_REQUEST,
TALER_JSON_pack_ec (
TALER_EC_EXCHANGE_GENERIC_CIPHER_MISMATCH));
goto cleanup;
}
} }
rctx->dks = dks; rctx->dks = dks;
rctx->rcds = rcds; rctx->rcds = rcds;
@ -513,11 +519,13 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
{ {
enum TALER_ErrorCode ec = TALER_EC_NONE; enum TALER_ErrorCode ec = TALER_EC_NONE;
struct TEH_SignDetails sign_details; struct TEH_SignDetails sign_details;
const struct TALER_BlindedRsaPlanchet *rp;
// FIXME: implement cipher handling // FIXME: implement cipher handling
rp = &rcds[i].blinded_planchet.details.rsa_blinded_planchet;
sign_details.cipher = TALER_DENOMINATION_RSA; sign_details.cipher = TALER_DENOMINATION_RSA;
sign_details.details.rsa_message.msg = rcds[i].coin_ev; sign_details.details.rsa_message.msg = rp->blinded_msg;
sign_details.details.rsa_message.msg_size = rcds[i].coin_ev_size; sign_details.details.rsa_message.msg_size = rp->blinded_msg_size;
rrcs[i].coin_sig rrcs[i].coin_sig
= TEH_keys_denomination_sign ( = TEH_keys_denomination_sign (
&rrcs[i].h_denom_pub, &rrcs[i].h_denom_pub,
@ -542,8 +550,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
{ {
struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i]; struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
rrc->coin_ev = rcds[i].coin_ev; rrc->blinded_planchet = rcds[i].blinded_planchet;
rrc->coin_ev_size = rcds[i].coin_ev_size;
} }
qs = TEH_plugin->insert_refresh_reveal (TEH_plugin->cls, qs = TEH_plugin->insert_refresh_reveal (TEH_plugin->cls,
melt_serial_id, melt_serial_id,

View File

@ -1589,6 +1589,18 @@ TALER_planchet_to_coin (
struct TALER_FreshCoin *coin); struct TALER_FreshCoin *coin);
/**
* Add the hash of the @a bp (in some canonicalized form)
* to the @a hash_context.
*
* @param bp blinded planchet to hash
* @param[in,out] hash_context hash context to use
*/
void
TALER_blinded_planchet_hash (const struct TALER_BlindedPlanchet *bp,
struct GNUNET_HashContext *hash_context);
/** /**
* Given the coin and the transfer private keys, compute the * Given the coin and the transfer private keys, compute the
* transfer secret. (Technically, we only need one of the two * transfer secret. (Technically, we only need one of the two
@ -1649,14 +1661,9 @@ struct TALER_RefreshCoinData
const struct TALER_DenominationPublicKey *dk; const struct TALER_DenominationPublicKey *dk;
/** /**
* The envelope with the blinded coin. * The blinded planchet (details depend on cipher).
*/ */
void *coin_ev; struct TALER_BlindedPlanchet blinded_planchet;
/**
* Number of bytes in @a coin_ev
*/
size_t coin_ev_size;
}; };

View File

@ -519,9 +519,8 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
{ {
const struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; const struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
GNUNET_CRYPTO_hash_context_read (hash_context, TALER_blinded_planchet_hash (&rcd->blinded_planchet,
rcd->coin_ev, hash_context);
rcd->coin_ev_size);
} }
} }

View File

@ -691,4 +691,36 @@ TALER_blinded_denom_sig_cmp (
} }
void
TALER_blinded_planchet_hash (const struct TALER_BlindedPlanchet *bp,
struct GNUNET_HashContext *hash_context)
{
uint32_t cipher = htonl (bp->cipher);
GNUNET_CRYPTO_hash_context_read (hash_context,
&cipher,
sizeof (cipher));
switch (bp->cipher)
{
case TALER_DENOMINATION_INVALID:
break;
case TALER_DENOMINATION_RSA:
GNUNET_CRYPTO_hash_context_read (
hash_context,
bp->details.rsa_blinded_planchet.blinded_msg,
bp->details.rsa_blinded_planchet.blinded_msg_size);
break;
case TALER_DENOMINATION_CS:
GNUNET_CRYPTO_hash_context_read (
hash_context,
&bp->details.cs_blinded_planchet,
sizeof (bp->details.cs_blinded_planchet));
break;
default:
GNUNET_assert (0);
break;
}
}
/* end of denom.c */ /* end of denom.c */