diff options
author | Matyja Lukas Adam <lukas.matyja@students.bfh.ch> | 2024-05-01 14:59:44 +0200 |
---|---|---|
committer | Matyja Lukas Adam <lukas.matyja@students.bfh.ch> | 2024-05-01 14:59:44 +0200 |
commit | d0193143677cbc1ca1111be1b3f4177ada5b1f04 (patch) | |
tree | f85679b657db6cd04510ab7545dc22e5d7032501 | |
parent | 60260ddf5253fb107a86c93b1e0b9c5487ee9452 (diff) | |
download | donau-d0193143677cbc1ca1111be1b3f4177ada5b1f04.tar.gz donau-d0193143677cbc1ca1111be1b3f4177ada5b1f04.tar.bz2 donau-d0193143677cbc1ca1111be1b3f4177ada5b1f04.zip |
[testing] finish issue receipts rsa tests with blind/unblind
-rw-r--r-- | src/testing/test_donau_api.c | 8 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_issue_receipts.c | 104 | ||||
-rw-r--r-- | src/util/donau_crypto.c | 4 |
3 files changed, 50 insertions, 66 deletions
diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c index a0e9eca..d5039f7 100644 --- a/src/testing/test_donau_api.c +++ b/src/testing/test_donau_api.c @@ -98,10 +98,10 @@ run (void *cls, "7560001010000", // tax id "1234", //salt for tax id hash MHD_HTTP_CREATED), - TALER_TESTING_cmd_submit_receipts ("submit-receipts", - "issue-receipts", // cmd trait reference - 2024, - MHD_HTTP_OK), +// TALER_TESTING_cmd_submit_receipts ("submit-receipts", +// "issue-receipts", // cmd trait reference +// 2024, +// MHD_HTTP_OK), TALER_TESTING_cmd_charity_delete ("delete-charity", "post-charity", // cmd trait reference &bearer, diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c index 2660428..dba0a0d 100644 --- a/src/testing/testing_api_cmd_issue_receipts.c +++ b/src/testing/testing_api_cmd_issue_receipts.c @@ -101,7 +101,7 @@ struct StatusState /** * Blinding values. Cs-nonces, cipher. */ - struct DONAU_BatchIssueValues *alg_values; + const struct DONAU_BatchIssueValues **alg_values; /** * Array of hashed udis. @@ -139,17 +139,17 @@ issue_receipts_status_cb (void *cls, TALER_TESTING_interpreter_fail (ss->is); return; } -// struct DONAU_BlindedDonationUnitSignature *blinded_sigs = 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->blinded_secrets[i], -// &ss->h_udis[i], -// &ss->alg_values[i], -// &ss->keys->donation_unit_keys[0].key)); -// } + struct DONAU_BlindedDonationUnitSignature *blinded_sigs = 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->blinded_secrets[i], + &ss->h_udis[i], + ss->alg_values[i], + &ss->keys->donation_unit_keys[0].key)); + } TALER_TESTING_interpreter_next (ss->is); } @@ -211,66 +211,50 @@ status_run (void *cls, ss->keys = keys; } - //TODO: Free - ss->bkps - = GNUNET_new_array (ss->num_bkp, - struct DONAU_BlindedUniqueDonorIdentifierKeyPair); + // TODO: Free + ss->bkps = + GNUNET_new_array (ss->num_bkp, struct DONAU_BlindedUniqueDonorIdentifierKeyPair); ss->blinded_secrets = - GNUNET_malloc (sizeof(union GNUNET_CRYPTO_BlindingSecretP) - * ss->num_bkp); + GNUNET_new_array (ss->num_bkp, union GNUNET_CRYPTO_BlindingSecretP); ss->receipts = - GNUNET_malloc (sizeof(struct DONAU_DonationReceipt) - * ss->num_bkp); + GNUNET_new_array (ss->num_bkp, struct DONAU_DonationReceipt); ss->alg_values = - GNUNET_malloc (sizeof(struct DONAU_BatchIssueValues) - * ss->num_bkp); + GNUNET_new_array (ss->num_bkp, const struct DONAU_BatchIssueValues*); ss->h_udis = - GNUNET_malloc (sizeof(struct DONAU_UniqueDonorIdentifierHashP) - * ss->num_bkp); + GNUNET_new_array (ss->num_bkp, struct DONAU_UniqueDonorIdentifierHashP); for (size_t cnt = 0; cnt < ss->num_bkp; cnt++) { - struct DONAU_UniqueDonorIdentifierNonce *udi_nonce = &ss->receipts[cnt].nonce; + struct DONAU_UniqueDonorIdentifierNonce *udi_nonce = + &ss->receipts[cnt].nonce; struct DONAU_BudiMasterSecretP ps; - const struct DONAU_BatchIssueValues *alg_values = &ss->alg_values[cnt]; - struct DONAU_BlindedUniqueDonorIdentifier *blinded_udi = &ss->bkps[cnt].blinded_udi; + const struct DONAU_BatchIssueValues *alg_values; + struct DONAU_BlindedUniqueDonorIdentifier *blinded_udi = + &ss->bkps[cnt].blinded_udi; struct DONAU_UniqueDonorIdentifierHashP *udi_hash = ss->h_udis; - alg_values = DONAU_donation_unit_ewv_rsa_singleton (); + alg_values = DONAU_donation_unit_ewv_rsa_singleton (); // FIXME: support cs and rsa GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, - &ps, - sizeof (ps)); + &ps, + sizeof (ps)); DONAU_budi_secret_create (&ps, alg_values, &ss->blinded_secrets[cnt]); GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, - udi_nonce, - sizeof (*udi_nonce)); + udi_nonce, + sizeof (*udi_nonce)); GNUNET_assert (GNUNET_OK == - DONAU_donation_unit_blind (&ss->keys->donation_unit_keys[0].key, - &ss->blinded_secrets[cnt], - NULL, /* no cs-nonce needed for rsa */ - udi_nonce, - ss->h_donor_tax_id, - alg_values, - udi_hash, - blinded_udi)); - + DONAU_donation_unit_blind ( + &ss->keys->donation_unit_keys[0].key, + &ss->blinded_secrets[cnt], + NULL, /* no cs-nonce needed for rsa */ + udi_nonce, + ss->h_donor_tax_id, + alg_values, + udi_hash, + blinded_udi)); + ss->alg_values[cnt] = alg_values; DONAU_donation_unit_pub_hash (&ss->keys->donation_unit_keys[0].key, &ss->bkps[cnt].h_donation_unit_pub); - // struct GNUNET_CRYPTO_RsaBlindedMessage *rp; - // bp = &ss->bkps[cnt].blinded_udi; - // bp->blinded_message = GNUNET_new (struct GNUNET_CRYPTO_BlindedMessage); - // bp->blinded_message->cipher = GNUNET_CRYPTO_BSA_RSA; - // bp->blinded_message->rc = 1; - // rp = &bp->blinded_message->details.rsa_blinded_message; - // rp->blinded_msg_size = 1 + (size_t) GNUNET_CRYPTO_random_u64 ( - // GNUNET_CRYPTO_QUALITY_WEAK, - // (1024 / 8) - 1); // 1024 is the RSA key size - // rp->blinded_msg = GNUNET_malloc (rp->blinded_msg_size); - // GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - // rp->blinded_msg, - // rp->blinded_msg_size); - } const struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkps = ss->bkps; ss->birh = DONAU_charity_issue_receipt ( @@ -334,9 +318,9 @@ cleanup (void *cls, */ static enum GNUNET_GenericReturnValue issue_receipts_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) + const void **ret, + const char *trait, + unsigned int index) { struct StatusState *ss = cls; struct TALER_TESTING_Trait traits[] = { @@ -375,10 +359,10 @@ TALER_TESTING_cmd_issue_receipts (const char *label, donor_tax_id, sizeof((*donor_tax_id))), GNUNET_CRYPTO_hash_context_read (hash_context, - salt, + salt, sizeof((*salt))); GNUNET_CRYPTO_hash_context_finish (hash_context, - &h_donor_tax_id.hash); + &h_donor_tax_id.hash); ss->h_donor_tax_id = &h_donor_tax_id; { struct TALER_TESTING_Command cmd = { diff --git a/src/util/donau_crypto.c b/src/util/donau_crypto.c index ffe7b53..9d7b6a3 100644 --- a/src/util/donau_crypto.c +++ b/src/util/donau_crypto.c @@ -189,10 +189,10 @@ DONAU_donation_unit_blind ( GNUNET_CRYPTO_hash_context_read (hash_context, udi_nonce, - sizeof((*udi_nonce))), + sizeof(struct DONAU_UniqueDonorIdentifierNonce)), GNUNET_CRYPTO_hash_context_read (hash_context, h_tax_id, - sizeof((*h_tax_id))); + sizeof(struct DONAU_HashDonorTaxId)); GNUNET_CRYPTO_hash_context_finish (hash_context, &udi_hash->hash); |