diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-05-02 21:16:51 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-05-02 21:16:51 +0200 |
commit | de9fdf860af9bdeadee4ed21a2c03dc34d58dd86 (patch) | |
tree | 3d675e05534998a94087dc2d626566eceb0ade91 /src/util | |
parent | d821ecc3bb23df1a326fcbdf4cb08841322db7aa (diff) | |
download | exchange-de9fdf860af9bdeadee4ed21a2c03dc34d58dd86.tar.xz |
replace denom_pub with denom_pub_hash in exchange API to reduce bandwidth
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/crypto.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/util/crypto.c b/src/util/crypto.c index b44c31ff7..95eb11eba 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -77,22 +77,33 @@ TALER_gcrypt_init () * is not expired, and the signature is correct. * * @param coin_public_info the coin public info to check for validity + * @param denom_pub denomination key, must match @a coin_public_info's `denom_pub_hash` * @return #GNUNET_YES if the coin is valid, * #GNUNET_NO if it is invalid * #GNUNET_SYSERR if an internal error occured */ int -TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info) +TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info, + const struct TALER_DenominationPublicKey *denom_pub) { struct GNUNET_HashCode c_hash; - +#if 1 /* sanity check of invariant, could probably be disabled in production + for slightly more performance */ + struct GNUNET_HashCode d_hash; + + GNUNET_CRYPTO_rsa_public_key_hash (denom_pub->rsa_public_key, + &d_hash); + GNUNET_assert (0 == + GNUNET_memcmp (&d_hash, + &coin_public_info->denom_pub_hash)); +#endif GNUNET_CRYPTO_hash (&coin_public_info->coin_pub, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), &c_hash); if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (&c_hash, coin_public_info->denom_sig.rsa_signature, - coin_public_info->denom_pub.rsa_public_key)) + denom_pub->rsa_public_key)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "coin signature is invalid\n"); |