commit 5e7641445e8e5f424608b03befee306d8ae6502c
parent 9b2dab911b874eb8dc4ac500a244863391df492e
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date: Tue, 21 May 2024 23:54:33 +0200
[testing] rsa donation unit signature verification works
Diffstat:
2 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/src/donau/donau-httpd_batch-issue.c b/src/donau/donau-httpd_batch-issue.c
@@ -105,9 +105,6 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
unsigned long long charity_id;
char dummy;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "issue receipts request! \n");
-
if ( (NULL == args[0]) ||
(1 != sscanf (args[0],
"%llu%c",
@@ -150,8 +147,6 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "parse some values!\n");
/* parse the budikeypairs array */
const size_t num_bkps
= json_array_size (budikeypairs);
@@ -161,7 +156,6 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
json_t *bkp_obj;
size_t index;
-
bkps = GNUNET_new_array
(num_bkps,
struct DONAU_BlindedUniqueDonorIdentifierKeyPair);
@@ -188,8 +182,6 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
"budikeypairs");
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "budi key pairs array is parsed!\n");
// Get charity pub
struct DONAUDB_CharityMetaData charity_meta;
enum GNUNET_DB_QueryStatus qs_charity;
@@ -218,8 +210,6 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
break;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "got charity from db!\n");
/* verify charity signature */
if (GNUNET_OK !=
DONAU_charity_bkp_verify (num_bkps,
@@ -235,8 +225,6 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
NULL);
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "charity signature valid!\n");
/* request already made? -> idempotent */
enum GNUNET_DB_QueryStatus qs_check_receipts;
struct DONAUDB_IssuedReceiptsMetaData check_receipts_meta;
@@ -338,11 +326,12 @@ start:
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
- batch_sign_ec, // TODO:other EC
+ batch_sign_ec,
NULL);
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"made blind signatures!\n");
+
/* save new receipts to date and save receipts Request (blinded signatures,
* charity id, amount, hash over bkps) to make it idempotent*/
enum GNUNET_DB_QueryStatus qs_insert_ir;
diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c
@@ -90,7 +90,7 @@ struct StatusState
/**
* Hashed and salted tax id of the donor.
*/
- struct DONAU_HashDonorTaxId *h_donor_tax_id;
+ struct DONAU_HashDonorTaxId h_donor_tax_id;
/**
* Array of donation receipts;
@@ -156,8 +156,6 @@ issue_receipts_status_cb (void *cls,
{
struct StatusState *ss = cls;
- // TODO: use the public donation unit keys from the DONAU to verify the signatures
-
ss->birh = NULL;
if (ss->expected_response_code != biresp->hr.http_status)
{
@@ -176,14 +174,36 @@ issue_receipts_status_cb (void *cls,
biresp->details.ok.blinded_sigs;
for (size_t i = 0; i < ss->num_bkp; i++)
{
- GNUNET_assert (GNUNET_OK ==
- DONAU_donation_unit_sig_unblind (
- &ss->receipts[i].donation_unit_sig,
- &blinded_sigs[i],
- &ss->blinding_secrets[i],
- &ss->h_udis[i],
- ss->alg_values[i],
- &ss->keys->donation_unit_keys[0].key));
+ GNUNET_assert (GNUNET_OK ==
+ DONAU_donation_unit_sig_unblind (
+ &ss->receipts[i].donation_unit_sig,
+ &blinded_sigs[i],
+ &ss->blinding_secrets[i],
+ &ss->h_udis[i],
+ ss->alg_values[i],
+ &ss->keys->donation_unit_keys[0].key));
+
+ /* check udi message */
+ struct DONAU_UniqueDonorIdentifierHashP checkudi_hash;
+ DONAU_unique_donor_id_hash (
+ &ss->h_donor_tax_id,
+ &ss->receipts[i].nonce,
+ &checkudi_hash);
+ GNUNET_assert(0 == GNUNET_CRYPTO_hash_cmp(&checkudi_hash.hash, &ss->h_udis[i].hash));
+ /* check signature */
+ if (GNUNET_OK != DONAU_donation_receipt_verify (
+ &ss->keys->donation_unit_keys[0].key,
+ &checkudi_hash,
+ &ss->receipts[i].donation_unit_sig))
+ {
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Donation receipt signature invalid!\n");
+ } else {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "!!!!!Donation receipt signature valid!\n");
+ }
+
}
TALER_TESTING_interpreter_next (ss->is);
}
@@ -254,7 +274,7 @@ cs_stage_two_callback (
struct DONAU_BatchIssueValues *alg_values = GNUNET_new (struct
DONAU_BatchIssueValues);
struct DONAU_BudiMasterSecretP ps;
- struct DONAU_UniqueDonorIdentifierHashP *udi_hash = csr_data->ss->h_udis;
+ struct DONAU_UniqueDonorIdentifierHashP *udi_hash = &csr_data->ss->h_udis[csr_data->position];
union GNUNET_CRYPTO_BlindingSecretP *blinding_secret =
&csr_data->ss->blinding_secrets[csr_data->position];
struct DONAU_UniqueDonorIdentifierNonce *udi_nonce =
@@ -277,7 +297,7 @@ cs_stage_two_callback (
blinding_secret,
&csr_data->nonce, /* nonce only needed for cs */
udi_nonce,
- csr_data->ss->h_donor_tax_id,
+ &csr_data->ss->h_donor_tax_id,
alg_values,
udi_hash,
blinded_udi));
@@ -369,7 +389,7 @@ status_run (void *cls,
const struct DONAU_BatchIssueValues *alg_values;
struct DONAU_BlindedUniqueDonorIdentifier *blinded_udi =
&ss->bkps[cnt].blinded_udi;
- struct DONAU_UniqueDonorIdentifierHashP *udi_hash = ss->h_udis;
+ struct DONAU_UniqueDonorIdentifierHashP *udi_hash = &ss->h_udis[cnt];
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
&ps,
sizeof (ps));
@@ -389,7 +409,7 @@ status_run (void *cls,
&ss->blinding_secrets[cnt],
NULL, /* no cs-nonce needed for rsa */
udi_nonce,
- ss->h_donor_tax_id,
+ &ss->h_donor_tax_id,
alg_values,
udi_hash,
blinded_udi));
@@ -478,7 +498,7 @@ issue_receipts_traits (void *cls,
struct StatusState *ss = cls;
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_salted_tax_id_hash (
- (const struct DONAU_HashDonorTaxId *) ss->h_donor_tax_id),
+ (const struct DONAU_HashDonorTaxId *) &ss->h_donor_tax_id),
TALER_TESTING_make_trait_donation_receipts (
(const struct DONAU_DonationReceipt **) &ss->receipts),
TALER_TESTING_make_trait_number_receipts ((const size_t *) &ss->num_bkp),
@@ -522,7 +542,7 @@ TALER_TESTING_cmd_issue_receipts (const char *label,
sizeof((*salt)));
GNUNET_CRYPTO_hash_context_finish (hash_context,
&h_donor_tax_id.hash);
- ss->h_donor_tax_id = &h_donor_tax_id;
+ ss->h_donor_tax_id = h_donor_tax_id;
{
struct TALER_TESTING_Command cmd = {
.cls = ss,