diff options
author | Gian Demarmels <gian@demarmels.org> | 2022-01-17 19:36:19 +0100 |
---|---|---|
committer | Gian Demarmels <gian@demarmels.org> | 2022-02-04 15:37:34 +0100 |
commit | 086cf05794e2936370223c97b35c1909fbc1a2c1 (patch) | |
tree | 93f247e39b4bf020f99f44fd02da1284a49c8dff /src/util/crypto.c | |
parent | 22130128663a00760b83789437985711028d169e (diff) | |
download | exchange-086cf05794e2936370223c97b35c1909fbc1a2c1.tar.xz |
refactor TALER_coin_ev_hash
Diffstat (limited to 'src/util/crypto.c')
-rw-r--r-- | src/util/crypto.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/util/crypto.c b/src/util/crypto.c index bed70f3d3..fee3f31ea 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -502,43 +502,46 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc, enum GNUNET_GenericReturnValue TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet, - const struct TALER_DenominationPublicKey *denom_pub, + const struct TALER_DenominationHash *denom_hash, struct TALER_BlindedCoinHash *bch) { switch (blinded_planchet->cipher) { case TALER_DENOMINATION_RSA: - // FIXME: Include denom_pub into hash - 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: { - char delim = ':'; - size_t buf_len = sizeof(denom_pub->details.cs_public_key) - + sizeof (blinded_planchet->details.cs_blinded_planchet. - nonce) - + sizeof(delim); - void*buf = GNUNET_malloc (buf_len); - memcpy (buf, - &denom_pub->details.cs_public_key, - sizeof(denom_pub->details.cs_public_key)); - memcpy (buf + sizeof(denom_pub->details.cs_public_key), - &delim, - sizeof(delim)); - memcpy (buf + sizeof(denom_pub->details.cs_public_key) + sizeof(delim), - &blinded_planchet->details.cs_blinded_planchet.nonce, - sizeof (blinded_planchet->details.cs_blinded_planchet.nonce)); - GNUNET_CRYPTO_hash ( - buf, - buf_len, - &bch->hash); - GNUNET_free (buf); + struct GNUNET_HashContext *hash_context; + hash_context = GNUNET_CRYPTO_hash_context_start (); + + // // FIXME: Include denom_pub into hash + // GNUNET_CRYPTO_hash_context_read (hash_context, + // &denom_hash->hash, + // sizeof(denom_hash->hash)); + GNUNET_CRYPTO_hash_context_read (hash_context, + blinded_planchet->details. + rsa_blinded_planchet.blinded_msg, + blinded_planchet->details. + rsa_blinded_planchet.blinded_msg_size); + GNUNET_CRYPTO_hash_context_finish (hash_context, + &bch->hash); return GNUNET_OK; } + case TALER_DENOMINATION_CS: + { + struct GNUNET_HashContext *hash_context; + hash_context = GNUNET_CRYPTO_hash_context_start (); + GNUNET_CRYPTO_hash_context_read (hash_context, + &denom_hash->hash, + sizeof(denom_hash->hash)); + GNUNET_CRYPTO_hash_context_read (hash_context, + &blinded_planchet->details. + cs_blinded_planchet.nonce, + sizeof (blinded_planchet->details. + cs_blinded_planchet.nonce)); + GNUNET_CRYPTO_hash_context_finish (hash_context, + &bch->hash); + return GNUNET_OK; + } default: GNUNET_break (0); return GNUNET_SYSERR; |