donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 20adecc9bbab9a6e5550e7c05816171720a0f329
parent 4298e37a3606fa7136b336ad03f6bba4c6f1cf56
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Fri, 12 Apr 2024 11:29:44 +0200

[util] solve charity signature problem

Diffstat:
Msrc/donau/donau-httpd_post-batch-issue.c | 27+++++++++++++--------------
Msrc/include/donau_crypto_lib.h | 4++--
Msrc/util/charity_signatures.c | 36++++++++++++++++++++++++++++--------
3 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/src/donau/donau-httpd_post-batch-issue.c b/src/donau/donau-httpd_post-batch-issue.c @@ -234,19 +234,19 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc, "got charity from db!\n"); /* verify charity signature */ // FIXME -// if (GNUNET_OK != -// DONAU_charity_budi_key_pair_verify (num_bkp, -// irc.bkp, -// &charity_meta.charity_pub, -// &irc.charity_sig)) -// { -// GNUNET_break_op (0); -// return TALER_MHD_reply_with_error ( -// rc->connection, -// MHD_HTTP_FORBIDDEN, -// TALER_EC_DONAU_CHARITY_SIGNATURE_INVALID, -// NULL); -// } + if (GNUNET_OK != + DONAU_charity_budi_key_pair_verify (num_bkp, + irc.bkp, + &charity_meta.charity_pub, + &irc.charity_sig)) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_DONAU_CHARITY_SIGNATURE_INVALID, + NULL); + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "charity signature valid!\n"); @@ -321,7 +321,6 @@ start: MHD_RESULT mret; struct DH_DonationUnitKey *dk; - // FIXME always public key not found if (NULL == (dk = DH_keys_donation_unit_by_hash ( &irc.bkp[i].h_donation_unit_pub))) return TALER_MHD_reply_with_error (rc->connection, diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -304,7 +304,7 @@ struct DONAU_BudiHashP */ void DONAU_charity_budi_key_pair_sign ( - const unsigned int num_bkp, + const size_t num_bkp, const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPrivateKeyP *charity_priv, struct DONAU_CharitySignatureP *charity_sig); @@ -321,7 +321,7 @@ DONAU_charity_budi_key_pair_sign ( */ enum GNUNET_GenericReturnValue DONAU_charity_budi_key_pair_verify ( - const unsigned int num_bkp, + const size_t num_bkp, const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPublicKeyP *charity_pub, const struct DONAU_CharitySignatureP *charity_sig); diff --git a/src/util/charity_signatures.c b/src/util/charity_signatures.c @@ -58,7 +58,7 @@ GNUNET_NETWORK_STRUCT_END void DONAU_charity_budi_key_pair_sign ( - const unsigned int num_bkp, + const size_t num_bkp, const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPrivateKeyP *charity_priv, struct DONAU_CharitySignatureP *charity_sig) @@ -69,9 +69,19 @@ DONAU_charity_budi_key_pair_sign ( .num_bkp = htonl (num_bkp) }; - GNUNET_CRYPTO_hash (bkp, - sizeof (struct DONAU_BlindedUniqueDonationIdentifierKeyPair) * num_bkp, - &tps.bkps_hash); + struct GNUNET_HashContext *hc; + hc = GNUNET_CRYPTO_hash_context_start (); + for (unsigned int i = 0; i < num_bkp; i++) + { + GNUNET_CRYPTO_hash_context_read (hc, + &bkp[i].h_donation_unit_pub, + sizeof (bkp[i].h_donation_unit_pub)); + GNUNET_CRYPTO_hash_context_read (hc, + bkp[i].blinded_udi.blinded_message, + sizeof (bkp[i].blinded_udi.blinded_message)); + } + GNUNET_CRYPTO_hash_context_finish (hc, + &tps.bkps_hash); GNUNET_CRYPTO_eddsa_sign (&charity_priv->eddsa_priv, &tps, @@ -81,7 +91,7 @@ DONAU_charity_budi_key_pair_sign ( enum GNUNET_GenericReturnValue DONAU_charity_budi_key_pair_verify ( - const unsigned int num_bkp, + const size_t num_bkp, const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPublicKeyP *charity_pub, const struct DONAU_CharitySignatureP *charity_sig) @@ -92,9 +102,19 @@ DONAU_charity_budi_key_pair_verify ( .num_bkp = htonl (num_bkp) }; - GNUNET_CRYPTO_hash (bkp, - sizeof (struct DONAU_BlindedUniqueDonationIdentifierKeyPair) * num_bkp, - &tps.bkps_hash); + struct GNUNET_HashContext *hc; + hc = GNUNET_CRYPTO_hash_context_start (); + for (unsigned int i = 0; i < num_bkp; i++) + { + GNUNET_CRYPTO_hash_context_read (hc, + &bkp[i].h_donation_unit_pub, + sizeof (bkp[i].h_donation_unit_pub)); + GNUNET_CRYPTO_hash_context_read (hc, + bkp[i].blinded_udi.blinded_message, + sizeof (bkp[i].blinded_udi.blinded_message)); + } + GNUNET_CRYPTO_hash_context_finish (hc, + &tps.bkps_hash); return GNUNET_CRYPTO_eddsa_verify (DONAU_SIGNATURE_CHARITY_DONATION_CONFIRMATION,