commit 2fb11e8cd2b200c252ecfbf00dc5b1d2ff1fc485
parent 5d579f975b92a0f9a49f71d0740c6e95b49fa32b
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 11 Oct 2026 14:11:27 +0200
improve CS handling
Diffstat:
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_post-reveal-withdraw.c b/src/exchange/taler-exchange-httpd_post-reveal-withdraw.c
@@ -401,22 +401,44 @@ verify_commitment_and_max_age (
}
}
+ /**
+ * Sanity check:
+ * The number of CS denominations must match the R-values that were
+ * persisted with the original /withdraw request.
+ */
+ if ( (cs_count != wd->num_cs_r_values) ||
+ ( (0 < cs_count) &&
+ (wd->no_blinding_seed ||
+ (NULL == wd->cs_r_values) ) ) )
+ {
+ GNUNET_break (0);
+ *result = TALER_MHD_reply_with_error (
+ con,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+ NULL);
+ return GNUNET_SYSERR;
+ }
+
hash_context = GNUNET_CRYPTO_hash_context_start ();
{
- uint32_t cs_indices[cs_count];
- union GNUNET_CRYPTO_BlindSessionNonce nonces[cs_count];
+ uint32_t cs_indices[GNUNET_NZL (cs_count)];
+ union GNUNET_CRYPTO_BlindSessionNonce nonces[GNUNET_NZL (cs_count)];
size_t cs_idx = 0; /* [0...cs_count) */
- for (size_t i = 0; i < wd->num_coins; i++)
- if (is_cs[i])
- cs_indices[cs_idx++] = i;
-
- TALER_cs_derive_only_cs_blind_nonces_from_seed (&wd->blinding_seed,
- false, /* not for melt */
- cs_count,
- cs_indices,
- nonces);
+ if (0 < cs_count)
+ {
+ for (size_t i = 0; i < wd->num_coins; i++)
+ if (is_cs[i])
+ cs_indices[cs_idx++] = i;
+
+ TALER_cs_derive_only_cs_blind_nonces_from_seed (&wd->blinding_seed,
+ false, /* not for melt */
+ cs_count,
+ cs_indices,
+ nonces);
+ }
for (uint8_t gamma = 0; gamma<TALER_CNC_KAPPA; gamma++)
{