diff options
author | Lucien Heuzeveldt <lucienclaude.heuzeveldt@students.bfh.ch> | 2022-01-16 17:02:15 +0100 |
---|---|---|
committer | Gian Demarmels <gian@demarmels.org> | 2022-02-04 15:37:30 +0100 |
commit | 8d85c8b5b6c514ce093d856a2e4b931b4108ece5 (patch) | |
tree | 6ab878e42ad4a99337b7d42e7d89f358429165dd /src/util/crypto.c | |
parent | ea97729ba891dc94ed2323aba01b15ca8e6a52d4 (diff) | |
download | exchange-8d85c8b5b6c514ce093d856a2e4b931b4108ece5.tar.xz |
implement feedback
Diffstat (limited to 'src/util/crypto.c')
-rw-r--r-- | src/util/crypto.c | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/src/util/crypto.c b/src/util/crypto.c index 3e759e71b..50f2d97d3 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -209,11 +209,10 @@ TALER_cs_withdraw_nonce_derive (const struct void TALER_planchet_blinding_secret_create (struct TALER_PlanchetSecretsP *ps, - enum TALER_DenominationCipher cipher, const struct TALER_ExchangeWithdrawValues *alg_values) { - switch (cipher) + switch (alg_values->cipher) { case TALER_DENOMINATION_INVALID: GNUNET_break (0); @@ -244,18 +243,20 @@ TALER_planchet_blinding_secret_create (struct TALER_PlanchetSecretsP *ps, */ void TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps, - enum TALER_DenominationCipher cipher) + const struct + TALER_ExchangeWithdrawValues *alg_values) { GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, &ps->coin_priv, sizeof (struct TALER_CoinSpendPrivateKeyP)); - switch (cipher) + switch (alg_values->cipher) { case TALER_DENOMINATION_INVALID: GNUNET_break (0); return; case TALER_DENOMINATION_RSA: - TALER_planchet_blinding_secret_create (ps, TALER_DENOMINATION_RSA, NULL); + TALER_planchet_blinding_secret_create (ps, + alg_values); return; case TALER_DENOMINATION_CS: // Will be set in a later stage for Clause Blind Schnorr Scheme @@ -275,6 +276,8 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, { struct TALER_CoinSpendPublicKeyP coin_pub; + GNUNET_assert (alg_values->cipher == dk->cipher); + GNUNET_CRYPTO_eddsa_key_get_public (&ps->coin_priv.eddsa_priv, &coin_pub.eddsa_pub); @@ -286,7 +289,7 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, &ps->blinding_key, NULL, /* FIXME-Oec */ &coin_pub, - NULL, /* RSA has no alg Values */ + alg_values, c_hash, &pd->blinded_planchet)) { @@ -320,6 +323,23 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, } +void +TALER_blinded_planchet_free (struct TALER_BlindedPlanchet *blinded_planchet) +{ + switch (blinded_planchet->cipher) + { + case TALER_DENOMINATION_RSA: + GNUNET_free (blinded_planchet->details.rsa_blinded_planchet.blinded_msg); + break; + case TALER_DENOMINATION_CS: + // nothing to do for CS + break; + default: + GNUNET_break (0); + } +} + + enum GNUNET_GenericReturnValue TALER_planchet_to_coin (const struct TALER_DenominationPublicKey *dk, const struct @@ -471,14 +491,28 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc, } -void -TALER_coin_ev_hash (const void *coin_ev, - size_t coin_ev_size, +enum GNUNET_GenericReturnValue +TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet, struct TALER_BlindedCoinHash *bch) { - GNUNET_CRYPTO_hash (coin_ev, - coin_ev_size, - &bch->hash); + switch (blinded_planchet->cipher) + { + case TALER_DENOMINATION_RSA: + GNUNET_CRYPTO_hash ( + blinded_planchet->details.rsa_blinded_planchet.blinded_msg, + blinded_planchet->details.rsa_blinded_planchet.blinded_msg_size, + &bch->hash); + return GNUNET_OK; + case TALER_DENOMINATION_CS: + GNUNET_CRYPTO_hash ( + &blinded_planchet->details.cs_blinded_planchet, + sizeof (blinded_planchet->details.cs_blinded_planchet), + &bch->hash); + return GNUNET_OK; + default: + GNUNET_break (0); + return GNUNET_SYSERR; + } } |