donau

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

commit d37efa8ebc04a63811514c47e79ad92852efa9da
parent 7fd7414a5849f792a9bd8edf3ef80f2a7272bcd4
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Mon, 14 Apr 2025 19:00:48 +0200

fixing the strlen

Diffstat:
Msrc/testing/testing_api_cmd_issue_receipts.c | 33++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c @@ -536,23 +536,22 @@ TALER_TESTING_cmd_issue_receipts (const char *label, ss->donor_tax_id = (const char*) donor_tax_id; // use libsodium SHA-512 Hash for compatibility reasons with the Donau Verify app. - unsigned char hash[512 / 8]; - crypto_hash_sha512_state state; - crypto_hash_sha512_init (&state); - - unsigned int tax_length; - for (tax_length = 0; donor_tax_id[tax_length]!= '\0'; ++tax_length) - ; - unsigned int salt_length; - for (salt_length = 0; salt[salt_length]!= '\0'; ++salt_length) - ; - - crypto_hash_sha512_update (&state, (const unsigned char*) donor_tax_id, - tax_length); - crypto_hash_sha512_update (&state, (const unsigned char*) salt, salt_length); - - crypto_hash_sha512_final (&state, hash); - GNUNET_memcpy (ss->h_donor_tax_id.hash, hash, sizeof(hash)); + { + crypto_hash_sha512_state state; + size_t tax_length = strlen (donor_tax_id); + size_t salt_length = strlen (salt); + + crypto_hash_sha512_init (&state); + crypto_hash_sha512_update (&state, + (const unsigned char*) donor_tax_id, + tax_length); + crypto_hash_sha512_update (&state, + (const unsigned char*) salt, + salt_length); + GNUNET_static_assert (sizeof (ss->h_donor_tax_id.hash) == 512 / 8); + crypto_hash_sha512_final (&state, + ss->h_donor_tax_id.hash); + } { struct TALER_TESTING_Command cmd = { .cls = ss,