-fix test_crypto

This commit is contained in:
Christian Grothoff 2022-02-07 11:23:53 +01:00
parent adeca20fe2
commit d850ed9ca1
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 35 additions and 11 deletions

View File

@ -1530,12 +1530,21 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
* Frees blinded message inside blinded planchet depending on blinded_planchet->cipher * Frees blinded message inside blinded planchet depending on blinded_planchet->cipher
* Does not free the @a blinded_planchet itself! * Does not free the @a blinded_planchet itself!
* *
* @param blinded_planchet blnded planchet * @param[in] blinded_planchet blinded planchet
*/ */
void void
TALER_blinded_planchet_free (struct TALER_BlindedPlanchet *blinded_planchet); TALER_blinded_planchet_free (struct TALER_BlindedPlanchet *blinded_planchet);
/**
* Frees blinded message inside planchet detail.
*
* @param[in] pd planchet detail to free
*/
void
TALER_planchet_detail_free (struct TALER_PlanchetDetail *pd);
/** /**
* Obtain a coin from the planchet's secrets and the blind signature * Obtain a coin from the planchet's secrets and the blind signature
* of the exchange. * of the exchange.

View File

@ -384,6 +384,13 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
} }
void
TALER_planchet_detail_free (struct TALER_PlanchetDetail *pd)
{
TALER_blinded_planchet_free (&pd->blinded_planchet);
}
void void
TALER_blinded_planchet_free (struct TALER_BlindedPlanchet *blinded_planchet) TALER_blinded_planchet_free (struct TALER_BlindedPlanchet *blinded_planchet)
{ {

View File

@ -82,12 +82,15 @@ test_high_level (void)
TALER_planchet_setup_refresh (&secret, TALER_planchet_setup_refresh (&secret,
1, 1,
&ps2); &ps2);
TALER_planchet_setup_coin_priv (&ps1, TALER_planchet_setup_coin_priv (&ps2,
&alg2, &alg2,
&coin_priv2); &coin_priv2);
TALER_planchet_blinding_secret_create (&ps2, TALER_planchet_blinding_secret_create (&ps2,
&alg2, &alg2,
&bks2); &bks2);
GNUNET_assert (0 !=
GNUNET_memcmp (&ps1,
&ps2));
GNUNET_assert (0 != GNUNET_assert (0 !=
GNUNET_memcmp (&coin_priv1, GNUNET_memcmp (&coin_priv1,
&coin_priv2)); &coin_priv2));
@ -138,10 +141,12 @@ test_planchets_rsa (void)
TALER_DENOMINATION_RSA, TALER_DENOMINATION_RSA,
1024)); 1024));
alg_values.cipher = TALER_DENOMINATION_RSA; alg_values.cipher = TALER_DENOMINATION_RSA;
TALER_planchet_setup_coin_priv (&ps,
TALER_planchet_setup_coin_priv (&ps, &alg_values, &coin_priv); &alg_values,
TALER_planchet_blinding_secret_create (&ps, &alg_values, &bks); &coin_priv);
TALER_planchet_blinding_secret_create (&ps,
&alg_values,
&bks);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_planchet_prepare (&dk_pub, TALER_planchet_prepare (&dk_pub,
&alg_values, &alg_values,
@ -153,6 +158,7 @@ test_planchets_rsa (void)
TALER_denom_sign_blinded (&blind_sig, TALER_denom_sign_blinded (&blind_sig,
&dk_priv, &dk_priv,
&pd.blinded_planchet)); &pd.blinded_planchet));
TALER_planchet_detail_free (&pd);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_planchet_to_coin (&dk_pub, TALER_planchet_to_coin (&dk_pub,
&blind_sig, &blind_sig,
@ -200,16 +206,18 @@ test_planchets_cs (void)
alg_values.cipher = TALER_DENOMINATION_CS; alg_values.cipher = TALER_DENOMINATION_CS;
TALER_cs_withdraw_nonce_derive (&ps, TALER_cs_withdraw_nonce_derive (
&pd.blinded_planchet.details. &ps,
cs_blinded_planchet.nonce); &pd.blinded_planchet.details.cs_blinded_planchet.nonce);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_denom_cs_derive_r_public ( TALER_denom_cs_derive_r_public (
&pd.blinded_planchet.details.cs_blinded_planchet.nonce, &pd.blinded_planchet.details.cs_blinded_planchet.nonce,
&dk_priv, &dk_priv,
&alg_values.details.cs_values.r_pub)); &alg_values.details.cs_values.r_pub));
TALER_planchet_setup_coin_priv (&ps, &alg_values, &coin_priv); TALER_planchet_setup_coin_priv (&ps,
&alg_values,
&coin_priv);
TALER_planchet_blinding_secret_create (&ps, TALER_planchet_blinding_secret_create (&ps,
&alg_values, &alg_values,
&bks); &bks);
@ -226,7 +234,7 @@ test_planchets_cs (void)
TALER_denom_sign_blinded (&blind_sig, TALER_denom_sign_blinded (&blind_sig,
&dk_priv, &dk_priv,
&pd.blinded_planchet)); &pd.blinded_planchet));
TALER_planchet_detail_free (&pd);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_planchet_to_coin (&dk_pub, TALER_planchet_to_coin (&dk_pub,
&blind_sig, &blind_sig,