From a351bfc4b4ca15ce7fd998cf9691e85cf84dc426 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 17 Feb 2022 15:10:14 +0100 Subject: -fix CS nonce reuse check logic --- src/util/crypto.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/util/crypto.c') diff --git a/src/util/crypto.c b/src/util/crypto.c index 6bea984f..d3f3cd3f 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -193,6 +193,7 @@ TALER_transfer_secret_to_planchet_secret ( void TALER_planchet_secret_to_transfer_priv ( const struct TALER_RefreshMasterSecretP *rms, + const struct TALER_CoinSpendPrivateKeyP *old_coin_priv, uint32_t cnc_num, struct TALER_TransferPrivateKeyP *tpriv) { @@ -203,6 +204,8 @@ TALER_planchet_secret_to_transfer_priv ( sizeof (*tpriv), &be_salt, sizeof (be_salt), + old_coin_priv, + sizeof (*old_coin_priv), rms, sizeof (*rms), "taler-transfer-priv-derivation", @@ -337,6 +340,7 @@ TALER_planchet_to_coin ( void TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc, uint32_t kappa, + const struct TALER_RefreshMasterSecretP *rms, uint32_t num_new_coins, const struct TALER_RefreshCommitmentEntry *rcs, const struct TALER_CoinSpendPublicKeyP *coin_pub, @@ -345,6 +349,10 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc, struct GNUNET_HashContext *hash_context; hash_context = GNUNET_CRYPTO_hash_context_start (); + if (NULL != rms) + GNUNET_CRYPTO_hash_context_read (hash_context, + rms, + sizeof (*rms)); /* first, iterate over transfer public keys for hash_context */ for (unsigned int i = 0; inew_coins[j]; - TALER_blinded_planchet_hash (&rcd->blinded_planchet, - hash_context); + TALER_blinded_planchet_hash_ (&rcd->blinded_planchet, + hash_context); } } @@ -702,9 +710,27 @@ TALER_age_restriction_commmitment_free_inside ( GNUNET_free (commitment->pub); commitment->priv = NULL; } - /* Caller is responsible for commitment itself */ } +enum GNUNET_GenericReturnValue +TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet, + const struct TALER_DenominationHash *denom_hash, + struct TALER_BlindedCoinHash *bch) +{ + struct GNUNET_HashContext *hash_context; + + hash_context = GNUNET_CRYPTO_hash_context_start (); + GNUNET_CRYPTO_hash_context_read (hash_context, + denom_hash, + sizeof(*denom_hash)); + TALER_blinded_planchet_hash_ (blinded_planchet, + hash_context); + GNUNET_CRYPTO_hash_context_finish (hash_context, + &bch->hash); + return GNUNET_OK; +} + + /* end of crypto.c */ -- cgit v1.2.3