aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_helper_cs.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-02-11 17:44:18 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-11 17:44:18 +0100
commit9f77398fe25bb041e58ddd4c994062493275e615 (patch)
treec38d39b6da9d928307db32ec11ea7e2ee405f752 /src/util/test_helper_cs.c
parent0eb5b08d50df7ea31d6cf25c4fa41c8686c06e77 (diff)
downloadexchange-9f77398fe25bb041e58ddd4c994062493275e615.tar.xz
-fix use of uninit memory in test
Diffstat (limited to 'src/util/test_helper_cs.c')
-rw-r--r--src/util/test_helper_cs.c107
1 files changed, 49 insertions, 58 deletions
diff --git a/src/util/test_helper_cs.c b/src/util/test_helper_cs.c
index 562cd16bf..dd807b254 100644
--- a/src/util/test_helper_cs.c
+++ b/src/util/test_helper_cs.c
@@ -273,38 +273,28 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh)
struct TALER_ExchangeWithdrawValues alg_values;
TALER_planchet_master_setup_random (&ps);
- alg_values.cipher = TALER_DENOMINATION_CS;
- TALER_planchet_setup_coin_priv (&ps,
- &alg_values,
- &coin_priv);
- TALER_planchet_blinding_secret_create (&ps,
- &alg_values,
- &bks);
for (unsigned int i = 0; i<MAX_KEYS; i++)
{
struct TALER_PlanchetDetail pd;
+
if (! keys[i].valid)
continue;
// TODO: insert assertion into other checks
- GNUNET_assert (TALER_DENOMINATION_CS == keys[i].denom_pub.cipher);
- {
- pd.blinded_planchet.cipher = TALER_DENOMINATION_CS;
-
- TALER_cs_withdraw_nonce_derive (&ps,
- &pd.blinded_planchet.details.
- cs_blinded_planchet.nonce);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Requesting R derivation with key %s\n",
- GNUNET_h2s (&keys[i].h_cs.hash));
-
- alg_values.details.cs_values
- = TALER_CRYPTO_helper_cs_r_derive (dh,
- &keys[i].h_cs,
- &pd.blinded_planchet.
- details.
- cs_blinded_planchet.nonce,
- &ec);
- }
+ GNUNET_assert (TALER_DENOMINATION_CS ==
+ keys[i].denom_pub.cipher);
+ pd.blinded_planchet.cipher = TALER_DENOMINATION_CS;
+ TALER_cs_withdraw_nonce_derive (
+ &ps,
+ &pd.blinded_planchet.details.cs_blinded_planchet.nonce);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Requesting R derivation with key %s\n",
+ GNUNET_h2s (&keys[i].h_cs.hash));
+ alg_values.cipher = TALER_DENOMINATION_CS;
+ ec = TALER_CRYPTO_helper_cs_r_derive (
+ dh,
+ &keys[i].h_cs,
+ &pd.blinded_planchet.details.cs_blinded_planchet.nonce,
+ &alg_values.details.cs_values);
switch (ec)
{
case TALER_EC_NONE:
@@ -330,7 +320,9 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received valid R for key %s\n",
GNUNET_h2s (&keys[i].h_cs.hash));
-
+ TALER_planchet_setup_coin_priv (&ps,
+ &alg_values,
+ &coin_priv);
TALER_planchet_blinding_secret_create (&ps,
&alg_values,
&bks);
@@ -381,6 +373,7 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh)
{
struct TALER_CsPubHashP rnd;
struct TALER_CsNonce nonce;
+ struct TALER_DenominationCSPublicRPairP crp;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&rnd,
@@ -388,10 +381,10 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh)
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&nonce,
sizeof (nonce));
- TALER_CRYPTO_helper_cs_r_derive (dh,
- &rnd,
- &nonce,
- &ec);
+ ec = TALER_CRYPTO_helper_cs_r_derive (dh,
+ &rnd,
+ &nonce,
+ &crp);
if (TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN != ec)
{
GNUNET_break (0);
@@ -424,29 +417,31 @@ test_signing (struct TALER_CRYPTO_CsDenominationHelper *dh)
struct TALER_ExchangeWithdrawValues alg_values;
TALER_planchet_master_setup_random (&ps);
- alg_values.cipher = TALER_DENOMINATION_CS;
- TALER_planchet_setup_coin_priv (&ps, &alg_values, &coin_priv);
- TALER_planchet_blinding_secret_create (&ps, &alg_values, &bks);
-
for (unsigned int i = 0; i<MAX_KEYS; i++)
{
if (! keys[i].valid)
continue;
{
struct TALER_PlanchetDetail pd;
+
pd.blinded_planchet.cipher = TALER_DENOMINATION_CS;
// keys[i].denom_pub.cipher = TALER_DENOMINATION_CS;
TALER_cs_withdraw_nonce_derive (&ps,
&pd.blinded_planchet.details.
cs_blinded_planchet.nonce);
- alg_values.details.cs_values
- = TALER_CRYPTO_helper_cs_r_derive (dh,
- &keys[i].h_cs,
- &pd.blinded_planchet.
- details.
- cs_blinded_planchet.nonce,
- &ec);
+ alg_values.cipher = TALER_DENOMINATION_CS;
+ ec = TALER_CRYPTO_helper_cs_r_derive (dh,
+ &keys[i].h_cs,
+ &pd.blinded_planchet.
+ details.
+ cs_blinded_planchet.nonce,
+ &alg_values.details.cs_values);
+ if (TALER_EC_NONE != ec)
+ continue;
+ TALER_planchet_setup_coin_priv (&ps,
+ &alg_values,
+ &coin_priv);
TALER_planchet_blinding_secret_create (&ps,
&alg_values,
&bks);
@@ -596,13 +591,6 @@ perf_signing (struct TALER_CRYPTO_CsDenominationHelper *dh,
struct TALER_ExchangeWithdrawValues alg_values;
TALER_planchet_master_setup_random (&ps);
- alg_values.cipher = TALER_DENOMINATION_CS;
- TALER_planchet_setup_coin_priv (&ps,
- &alg_values,
- &coin_priv);
- TALER_planchet_blinding_secret_create (&ps,
- &alg_values,
- &bks);
duration = GNUNET_TIME_UNIT_ZERO;
TALER_CRYPTO_helper_cs_poll (dh);
for (unsigned int j = 0; j<NUM_SIGN_PERFS;)
@@ -629,18 +617,21 @@ perf_signing (struct TALER_CRYPTO_CsDenominationHelper *dh,
TALER_cs_withdraw_nonce_derive (&ps,
&pd.blinded_planchet.details.
cs_blinded_planchet.nonce);
-
- alg_values.details.cs_values
- = TALER_CRYPTO_helper_cs_r_derive (dh,
- &keys[i].h_cs,
- &pd.blinded_planchet.
- details.
- cs_blinded_planchet.nonce,
- &ec);
+ alg_values.cipher = TALER_DENOMINATION_CS;
+ ec = TALER_CRYPTO_helper_cs_r_derive (dh,
+ &keys[i].h_cs,
+ &pd.blinded_planchet.
+ details.
+ cs_blinded_planchet.nonce,
+ &alg_values.details.cs_values);
+ if (TALER_EC_NONE != ec)
+ continue;
+ TALER_planchet_setup_coin_priv (&ps,
+ &alg_values,
+ &coin_priv);
TALER_planchet_blinding_secret_create (&ps,
&alg_values,
&bks);
-
GNUNET_assert (GNUNET_YES ==
TALER_planchet_prepare (&keys[i].denom_pub,
&alg_values,