summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-02-07 13:41:55 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-07 13:41:55 +0100
commitb84fb618c3c0f7492f609949f5202c75882d7b68 (patch)
treec36bad8f6b304f27582e0006f7a4a123c41f653b
parent169d6843420df99dfcfb8089d03fc5c9bf68e8ef (diff)
downloadexchange-b84fb618c3c0f7492f609949f5202c75882d7b68.tar.gz
exchange-b84fb618c3c0f7492f609949f5202c75882d7b68.tar.bz2
exchange-b84fb618c3c0f7492f609949f5202c75882d7b68.zip
fix refreshes_reveal FTBFS
-rw-r--r--src/exchange/taler-exchange-httpd_refreshes_reveal.c29
-rw-r--r--src/include/taler_crypto_lib.h21
-rw-r--r--src/util/crypto.c5
-rw-r--r--src/util/denom.c32
4 files changed, 66 insertions, 21 deletions
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index 63a611594..f9330ebe9 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -200,10 +200,7 @@ check_commitment (struct RevealContext *rctx,
&coin_priv,
&c_hash,
&pd));
- rcd->coin_ev =
- pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg;
- rcd->coin_ev_size =
- pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg_size;
+ rcd->blinded_planchet = pd.blinded_planchet;
}
}
}
@@ -225,7 +222,7 @@ check_commitment (struct RevealContext *rctx,
{
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);
}
@@ -493,9 +490,18 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
struct TALER_RefreshCoinData *rcd = &rcds[i];
- rcd->coin_ev = rrc->coin_ev;
- rcd->coin_ev_size = rrc->coin_ev_size;
+ rcd->blinded_planchet = rrc->blinded_planchet;
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->rcds = rcds;
@@ -513,11 +519,13 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
{
enum TALER_ErrorCode ec = TALER_EC_NONE;
struct TEH_SignDetails sign_details;
+ const struct TALER_BlindedRsaPlanchet *rp;
// FIXME: implement cipher handling
+ rp = &rcds[i].blinded_planchet.details.rsa_blinded_planchet;
sign_details.cipher = TALER_DENOMINATION_RSA;
- sign_details.details.rsa_message.msg = rcds[i].coin_ev;
- sign_details.details.rsa_message.msg_size = rcds[i].coin_ev_size;
+ sign_details.details.rsa_message.msg = rp->blinded_msg;
+ sign_details.details.rsa_message.msg_size = rp->blinded_msg_size;
rrcs[i].coin_sig
= TEH_keys_denomination_sign (
&rrcs[i].h_denom_pub,
@@ -542,8 +550,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
{
struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
- rrc->coin_ev = rcds[i].coin_ev;
- rrc->coin_ev_size = rcds[i].coin_ev_size;
+ rrc->blinded_planchet = rcds[i].blinded_planchet;
}
qs = TEH_plugin->insert_refresh_reveal (TEH_plugin->cls,
melt_serial_id,
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 189d4b063..dbf390ea9 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1590,6 +1590,18 @@ TALER_planchet_to_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
* transfer secret. (Technically, we only need one of the two
* private keys, but the caller currently trivially only has
@@ -1649,14 +1661,9 @@ struct TALER_RefreshCoinData
const struct TALER_DenominationPublicKey *dk;
/**
- * The envelope with the blinded coin.
+ * The blinded planchet (details depend on cipher).
*/
- void *coin_ev;
-
- /**
- * Number of bytes in @a coin_ev
- */
- size_t coin_ev_size;
+ struct TALER_BlindedPlanchet blinded_planchet;
};
diff --git a/src/util/crypto.c b/src/util/crypto.c
index c239f7970..8e48b48d1 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -519,9 +519,8 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
{
const struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
- GNUNET_CRYPTO_hash_context_read (hash_context,
- rcd->coin_ev,
- rcd->coin_ev_size);
+ TALER_blinded_planchet_hash (&rcd->blinded_planchet,
+ hash_context);
}
}
diff --git a/src/util/denom.c b/src/util/denom.c
index caaa4f4e8..0c1f99225 100644
--- a/src/util/denom.c
+++ b/src/util/denom.c
@@ -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 */