donau

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

commit 590d377aa124203c827d2fbe05718d04a519e604
parent db5ca33efd90ac28d84d74d8fec53e208a710967
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Tue, 18 Jun 2024 10:36:45 +0200

finish qr-string generation

Diffstat:
Msrc/include/donau_crypto_lib.h | 6+++---
Msrc/include/donau_testing_lib.h | 2++
Msrc/include/donau_util.h | 4++--
Msrc/testing/testing_api_cmd_donation_statement_get.c | 50+++++++++++++++-----------------------------------
Msrc/testing/testing_api_cmd_issue_receipts.c | 14++++++++++++++
Msrc/util/donau_signatures.c | 16----------------
Msrc/util/qr.c | 16++++++----------
7 files changed, 42 insertions(+), 66 deletions(-)

diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -378,17 +378,17 @@ struct DONAU_DonationStatement /** * The salted and hashed donor id. */ - struct DONAU_HashDonorTaxId *h_donor_tax_id; + const struct DONAU_HashDonorTaxId *h_donor_tax_id; /** * The salt used for @h_donor_tax_id. */ - char *donor_tax_id; + const char *donor_tax_id; /** * The cleartext tax id of the user used for @h_donor_tax_id. */ - char *salt; + const char *salt; /** * The total donated amount. diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h @@ -207,6 +207,8 @@ TALER_TESTING_get_donau_url ( op (charity_id, const unsigned long long) \ op (donau_url, const char) \ op (donau_keys, struct DONAU_Keys) \ + op (donor_salt, const char) \ + op (donor_tax_id, const char) \ op (salted_tax_id_hash, const struct DONAU_HashDonorTaxId) \ op (donation_receipts, const struct DONAU_DonationReceipt*) \ op (number_receipts, const size_t) diff --git a/src/include/donau_util.h b/src/include/donau_util.h @@ -50,7 +50,7 @@ DONAU_OS_init (void); * with #GNUNET_free(). */ char * -generate_QR_string (struct DONAU_DonauPublicKeyP *pub_key, - struct DONAU_DonationStatement *donation_statement); +generate_QR_string (const struct DONAU_DonauPublicKeyP *pub_key, + const struct DONAU_DonationStatement *donation_statement); #endif diff --git a/src/testing/testing_api_cmd_donation_statement_get.c b/src/testing/testing_api_cmd_donation_statement_get.c @@ -122,36 +122,11 @@ donation_statement_status_cb (void *cls, &ss->donation_statement. donation_statement_sig)) { - char *end_pub; - char pub_str[sizeof (struct DONAU_DonauPublicKeyP) * 2]; - end_pub = GNUNET_STRINGS_data_to_string ( - &dsr->details.ok.donau_pub, - sizeof (struct DONAU_DonauPublicKeyP), - pub_str, - sizeof (pub_str)); - *end_pub = '\0'; - - char *end_sig; - char sig_str[sizeof (struct DONAU_DonauSignatureP) * 2]; - end_sig = GNUNET_STRINGS_data_to_string ( - &ss->donation_statement.donation_statement_sig, - sizeof (struct DONAU_DonauSignatureP), - sig_str, - sizeof (sig_str)); - *end_sig = '\0'; -// char *b64_pub; -// GNUNET_STRINGS_base64_encode (&dsr->details.ok.donau_pub, -// sizeof (struct DONAU_DonauPublicKeyP), -// &b64_pub); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "eddsa_pub_key: %s\n", pub_str); -// char *b64_sig; -// GNUNET_STRINGS_base64_encode (&ss->donation_statement. -// donation_statement_sig, -// sizeof (struct DONAU_DonauSignatureP), -// &b64_sig); + char *qr_string = generate_QR_string(&dsr->details.ok.donau_pub, + &ss->donation_statement); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "sig: %s\n", sig_str); + "qr-string: %s\n", qr_string); + TALER_TESTING_interpreter_next (ss->is); return; } @@ -182,21 +157,26 @@ status_run (void *cls, { const struct TALER_TESTING_Command *issue_receipts_cmd; const struct DONAU_HashDonorTaxId *h_donor_tax_id; + const char *donor_salt; + const char *donor_tax_id; issue_receipts_cmd = TALER_TESTING_interpreter_lookup_command (is, "issue-receipts"); - if (GNUNET_OK != - TALER_TESTING_get_trait_salted_tax_id_hash (issue_receipts_cmd, - &h_donor_tax_id)) + if (GNUNET_OK != TALER_TESTING_get_trait_salted_tax_id_hash + (issue_receipts_cmd, &h_donor_tax_id) || + GNUNET_OK != TALER_TESTING_get_trait_donor_salt + (issue_receipts_cmd, &donor_salt) || + GNUNET_OK != TALER_TESTING_get_trait_donor_tax_id + (issue_receipts_cmd, &donor_tax_id)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); return; } - ss->donation_statement.h_donor_tax_id = (struct - DONAU_HashDonorTaxId*) - h_donor_tax_id; + ss->donation_statement.donor_tax_id = donor_tax_id; + ss->donation_statement.salt = donor_salt; + ss->donation_statement.h_donor_tax_id = h_donor_tax_id; } ss->dsgh = DONAU_donation_statement_get ( diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c @@ -88,6 +88,16 @@ struct StatusState struct DONAU_Keys *keys; /** + * The salt used for @h_donor_tax_id. + */ + const char *donor_tax_id; + + /** + * The cleartext tax id of the user used for @h_donor_tax_id. + */ + const char *donor_salt; + + /** * Hashed and salted tax id of the donor. */ struct DONAU_HashDonorTaxId h_donor_tax_id; @@ -484,6 +494,8 @@ issue_receipts_traits (void *cls, { struct StatusState *ss = cls; struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_donor_salt (ss->donor_salt), + TALER_TESTING_make_trait_donor_tax_id (ss->donor_tax_id), TALER_TESTING_make_trait_salted_tax_id_hash ( (const struct DONAU_HashDonorTaxId *) &ss->h_donor_tax_id), TALER_TESTING_make_trait_donation_receipts ( @@ -517,6 +529,8 @@ TALER_TESTING_cmd_issue_receipts (const char *label, ss->expected_response_code = expected_response_code; ss->num_bkp = 3; ss->uses_cs = uses_cs; + ss->donor_salt = (const char*) salt; + ss->donor_tax_id = (const char*) donor_tax_id; struct DONAU_HashDonorTaxId h_donor_tax_id; struct GNUNET_HashContext *hash_context; hash_context = GNUNET_CRYPTO_hash_context_start (); diff --git a/src/util/donau_signatures.c b/src/util/donau_signatures.c @@ -102,22 +102,6 @@ DONAU_donation_statement_verify ( TALER_amount_hton (&confirm.amount_tot, amount_tot); - // char *b64; - // GNUNET_STRINGS_base64_encode (&confirm, - // sizeof (struct DONAU_DonationStatementConfirmationPS), - // &b64); - char *end_message; - char message_str[sizeof (struct DONAU_DonationStatementConfirmationPS) * 2]; - end_message = GNUNET_STRINGS_data_to_string ( - &confirm, - sizeof (struct DONAU_DonationStatementConfirmationPS), - message_str, - sizeof (message_str)); - *end_message = '\0'; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "message: %s\n message_size: %lu\n", message_str, - sizeof(confirm)); - return GNUNET_CRYPTO_eddsa_verify (DONAU_SIGNATURE_DONAU_DONATION_STATEMENT, &confirm, diff --git a/src/util/qr.c b/src/util/qr.c @@ -26,10 +26,10 @@ // FIXME: remove public key, only needed for testing. // The verification app should get the public key directly from the Donau. char * -generate_QR_string (struct DONAU_DonauPublicKeyP *pub_key, - struct DONAU_DonationStatement *donation_statement) +generate_QR_string (const struct DONAU_DonauPublicKeyP *pub_key, + const struct DONAU_DonationStatement *donation_statement) { - /* The string will be structured as follows: YEAR:TOTALAMOUNT:TAXID:TAXIDSALT:ED25519SIGNATURE:PUBKEY */ + /* The string will be structured as follows: YEAR/TOTALAMOUNT/TAXID/TAXIDSALT/ED25519SIGNATURE/PUBKEY */ uint64_t total_size = 0; char *total_amount_string = TALER_amount_to_string ( @@ -59,20 +59,16 @@ generate_QR_string (struct DONAU_DonauPublicKeyP *pub_key, *end_pub = '\0'; char *qr_string = GNUNET_malloc (total_size + 1); - if (0 > GNUNET_snprintf (qr_string, + GNUNET_assert (0 <= GNUNET_snprintf (qr_string, total_size, - "%llu:%s:%s:%s:%s:%s", + "%llu/%s/%s/%s/%s/%s", (unsigned long long) donation_statement->year, total_amount_string, donation_statement->donor_tax_id, donation_statement->salt, sig_str, - pub_str)) - { - return NULL; - } - ; + pub_str)); return qr_string; } \ No newline at end of file