From 0995bdd1d05356ed5f97954449f5a5c74a41bdc5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 11 Feb 2022 09:36:01 +0100 Subject: -get tests to pass --- src/util/crypto.c | 51 ++++++++++++++++++++++++++++++++-------------- src/util/test_crypto.c | 8 ++++---- src/util/test_helper_cs.c | 30 +++++++++++---------------- src/util/test_helper_rsa.c | 9 +++----- 4 files changed, 55 insertions(+), 43 deletions(-) (limited to 'src/util') diff --git a/src/util/crypto.c b/src/util/crypto.c index 76657f41d..49d5bcab5 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -146,8 +146,8 @@ TALER_link_recover_transfer_secret ( void -TALER_planchet_setup_random ( - struct TALER_PlanchetSecretsP *ps) +TALER_planchet_master_setup_random ( + struct TALER_PlanchetMasterSecretP *ps) { GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, ps, @@ -155,11 +155,21 @@ TALER_planchet_setup_random ( } +void +TALER_refresh_master_setup_random ( + struct TALER_RefreshMasterSecretP *rms) +{ + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, + rms, + sizeof (*rms)); +} + + void TALER_transfer_secret_to_planchet_secret ( const struct TALER_TransferSecretP *secret_seed, uint32_t coin_num_salt, - struct TALER_PlanchetSecretsP *ps) + struct TALER_PlanchetMasterSecretP *ps) { uint32_t be_salt = htonl (coin_num_salt); @@ -178,7 +188,7 @@ TALER_transfer_secret_to_planchet_secret ( void TALER_planchet_secret_to_transfer_priv ( - const struct TALER_PlanchetSecretsP *ps, + const struct TALER_RefreshMasterSecretP *rms, uint32_t cnc_num, struct TALER_TransferPrivateKeyP *tpriv) { @@ -189,8 +199,8 @@ TALER_planchet_secret_to_transfer_priv ( sizeof (*tpriv), &be_salt, sizeof (be_salt), - ps, - sizeof (*ps), + rms, + sizeof (*rms), "taler-transfer-priv-derivation", strlen ("taler-transfer-priv-derivation"), NULL, 0)); @@ -199,7 +209,7 @@ TALER_planchet_secret_to_transfer_priv ( void TALER_cs_withdraw_nonce_derive ( - const struct TALER_PlanchetSecretsP *ps, + const struct TALER_PlanchetMasterSecretP *ps, struct TALER_CsNonce *nonce) { GNUNET_assert (GNUNET_YES == @@ -216,7 +226,7 @@ TALER_cs_withdraw_nonce_derive ( void TALER_cs_refresh_nonce_derive ( - const struct TALER_PlanchetSecretsP *ps, + const struct TALER_RefreshMasterSecretP *rms, uint32_t coin_num_salt, struct TALER_CsNonce *nonce) { @@ -229,8 +239,8 @@ TALER_cs_refresh_nonce_derive ( sizeof (be_salt), "refresh-n", // FIXME: value used in spec? strlen ("refresh-n"), - ps, - sizeof(*ps), + rms, + sizeof(*rms), NULL, 0)); } @@ -238,7 +248,7 @@ TALER_cs_refresh_nonce_derive ( void TALER_planchet_blinding_secret_create ( - const struct TALER_PlanchetSecretsP *ps, + const struct TALER_PlanchetMasterSecretP *ps, const struct TALER_ExchangeWithdrawValues *alg_values, union TALER_DenominationBlindingKeyP *bks) { @@ -280,7 +290,7 @@ TALER_planchet_blinding_secret_create ( // FIXME: move to denom.c? void TALER_planchet_setup_coin_priv ( - const struct TALER_PlanchetSecretsP *ps, + const struct TALER_PlanchetMasterSecretP *ps, const struct TALER_ExchangeWithdrawValues *alg_values, struct TALER_CoinSpendPrivateKeyP *coin_priv) { @@ -305,8 +315,8 @@ TALER_planchet_setup_coin_priv ( strlen ("coin"), ps, sizeof(*ps), - &alg_values->details, /* Could be null on RSA case*/ - sizeof(alg_values->details), + &alg_values->details.cs_values, + sizeof(alg_values->details.cs_values), NULL, 0)); break; @@ -512,11 +522,22 @@ TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet, nonce here; if we omit this, we could skip sending the nonce in the /recoup protocol. OTOH, there is certainly no further harm (beyond the extra - bytes send on /recoup) from including it. */ + bytes send on /recoup) from including it. + **** + UPDATE: hashing 'nonce' here kills link, as + link does not HAVE the 'rms' to derive the nonce + from! (see FIXME_OMIT in exchange_api_link.c) + *** + => either figure elegant way to resolve this, + or omit hashing nonce and ALSO skip sending + nonce in /recoup! + */ +#if FIXME_OMIT GNUNET_CRYPTO_hash_context_read ( hash_context, &blinded_planchet->details.cs_blinded_planchet.nonce, sizeof (blinded_planchet->details.cs_blinded_planchet.nonce)); +#endif GNUNET_CRYPTO_hash_context_read ( hash_context, &blinded_planchet->details.cs_blinded_planchet.c[0], diff --git a/src/util/test_crypto.c b/src/util/test_crypto.c index 0681fc865..0c83555d7 100644 --- a/src/util/test_crypto.c +++ b/src/util/test_crypto.c @@ -42,8 +42,8 @@ test_high_level (void) union TALER_DenominationBlindingKeyP bks2; struct TALER_CoinSpendPrivateKeyP coin_priv1; struct TALER_CoinSpendPrivateKeyP coin_priv2; - struct TALER_PlanchetSecretsP ps1; - struct TALER_PlanchetSecretsP ps2; + struct TALER_PlanchetMasterSecretP ps1; + struct TALER_PlanchetMasterSecretP ps2; struct TALER_ExchangeWithdrawValues alg1; struct TALER_ExchangeWithdrawValues alg2; @@ -110,7 +110,7 @@ test_high_level (void) static int test_planchets_rsa (void) { - struct TALER_PlanchetSecretsP ps; + struct TALER_PlanchetMasterSecretP ps; struct TALER_CoinSpendPrivateKeyP coin_priv; union TALER_DenominationBlindingKeyP bks; struct TALER_DenominationPrivateKey dk_priv; @@ -184,7 +184,7 @@ test_planchets_rsa (void) static int test_planchets_cs (void) { - struct TALER_PlanchetSecretsP ps; + struct TALER_PlanchetMasterSecretP ps; struct TALER_CoinSpendPrivateKeyP coin_priv; union TALER_DenominationBlindingKeyP bks; struct TALER_DenominationPrivateKey dk_priv; diff --git a/src/util/test_helper_cs.c b/src/util/test_helper_cs.c index 4a3208e8a..3298834a6 100644 --- a/src/util/test_helper_cs.c +++ b/src/util/test_helper_cs.c @@ -266,20 +266,20 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh) { enum TALER_ErrorCode ec; bool success = false; - struct TALER_PlanchetSecretsP ps; + struct TALER_PlanchetMasterSecretP ps; struct TALER_CoinSpendPrivateKeyP coin_priv; union TALER_DenominationBlindingKeyP bks; struct TALER_CoinPubHash c_hash; struct TALER_ExchangeWithdrawValues alg_values; - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, - &ps, - sizeof (ps)); - + 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); - + 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