donau

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

commit eda9bd4254d5a653acb30bdaac16ac441a7bef62
parent f46e805fa3652f88e92bb5584c7f00837f2c1673
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Sun, 28 Apr 2024 16:55:54 +0200

[lib] submit client

Diffstat:
Msrc/donau/donau-httpd_batch-submit.c | 2+-
Msrc/donaudb/pg_insert_submitted_receipts.c | 2+-
Msrc/include/donau_crypto_lib.h | 2+-
Msrc/include/donau_json_lib.h | 15+++++++++++++++
Msrc/json/donau_json.c | 40++++++++++++++++++++++++++++++++++++++++
Msrc/lib/donau_api_batch_submit_receipts.c | 18++++++++++--------
6 files changed, 68 insertions(+), 11 deletions(-)

diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c @@ -61,7 +61,7 @@ parse_json_dr (struct DONAU_DonationReceipt *dr, GNUNET_JSON_spec_fixed_auto ("nonce", &dr->nonce), GNUNET_JSON_spec_fixed_auto ("donau_sig", - &dr->donau_sig), + &dr->du_sig), GNUNET_JSON_spec_end () }; diff --git a/src/donaudb/pg_insert_submitted_receipts.c b/src/donaudb/pg_insert_submitted_receipts.c @@ -61,7 +61,7 @@ DH_PG_insert_submitted_receipts ( h_donation_unit_pubs[i] = &dr->h_donation_unit_pub; nonces[i] = &dr->nonce; - donau_sigs[i] = &dr->donau_sig; + donau_sigs[i] = &dr->du_sig; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Do insert submitted receipt\n"); diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -303,7 +303,7 @@ struct DONAU_DonationReceipt /** * Unblinded donation unit signature from the donau. */ - struct DONAU_DonauSignatureP donau_sig; + struct DONAU_DonationUnitSignature du_sig; }; diff --git a/src/include/donau_json_lib.h b/src/include/donau_json_lib.h @@ -108,6 +108,21 @@ DONAU_JSON_pack_donation_unit_pub ( const char *name, const struct DONAU_DonationUnitPublicKey *pk); + +/** + * Generate packer instruction for a JSON field of type + * donation unit signature. + * + * @param name name of the field to add to the object + * @param sig signature + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +DONAU_JSON_pack_donation_unit_sig ( + const char *name, + const struct DONAU_DonationUnitSignature *sig); + + /** * Generate packer instruction for a JSON field of type * blinded donation unit signature (that needs to be diff --git a/src/json/donau_json.c b/src/json/donau_json.c @@ -492,6 +492,46 @@ DONAU_JSON_spec_blinded_donation_unit_sig (const char *field, return ret; } + +struct GNUNET_JSON_PackSpec +DONAU_JSON_pack_donation_unit_sig ( + const char *name, + const struct DONAU_DonationUnitSignature *sig) +{ + const struct GNUNET_CRYPTO_UnblindedSignature *bs; + struct GNUNET_JSON_PackSpec ps = { + .field_name = name, + }; + + if (NULL == sig) + return ps; + bs = sig->unblinded_sig; + switch (bs->cipher) + { + case GNUNET_CRYPTO_BSA_INVALID: + break; + case GNUNET_CRYPTO_BSA_RSA: + ps.object = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("cipher", + "RSA"), + GNUNET_JSON_pack_rsa_signature ("rsa_signature", + bs->details.rsa_signature)); + return ps; + case GNUNET_CRYPTO_BSA_CS: + ps.object = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("cipher", + "CS"), + GNUNET_JSON_pack_data_auto ("cs_signature_r", + &bs->details.cs_signature.r_point), + GNUNET_JSON_pack_data_auto ("cs_signature_s", + &bs->details.cs_signature.s_scalar)); + return ps; + } + GNUNET_assert (0); + return ps; +} + + struct GNUNET_JSON_PackSpec DONAU_JSON_pack_blinded_donation_unit_sig ( const char *name, diff --git a/src/lib/donau_api_batch_submit_receipts.c b/src/lib/donau_api_batch_submit_receipts.c @@ -57,11 +57,6 @@ struct DONAU_DonorReceiptsToStatementHandle DONAU_DonorReceiptsToStatementResultCallback cb; /** - * BUDI-key-pair signature. - */ - struct DONAU_CharitySignatureP charity_sig; - - /** * Closure to pass to @e cb. */ void *cb_cls; @@ -98,8 +93,8 @@ submit_request_body_to_json (const size_t num_drs, &drs[i].h_donation_unit_pub), GNUNET_JSON_pack_data_auto ("nonce", &drs[i].nonce), - GNUNET_JSON_pack_data_auto ("donau_sig", - &drs[i].donau_sig)); + DONAU_JSON_pack_donation_unit_sig ("donau_sig", + &drs[i].du_sig)); GNUNET_assert (0 == json_array_append_new (donation_receipts, receipt)); @@ -138,20 +133,27 @@ handle_batch_submit_finished (void *cls, birh->job = NULL; switch (response_code) { - case MHD_HTTP_CREATED: + case MHD_HTTP_OK: break; case MHD_HTTP_NO_CONTENT: biresp.hr.ec = TALER_JSON_get_error_code (j); biresp.hr.hint = TALER_JSON_get_error_hint (j); break; + //One of the signatures is invalid. case MHD_HTTP_FORBIDDEN: biresp.hr.ec = TALER_JSON_get_error_code (j); biresp.hr.hint = TALER_JSON_get_error_hint (j); break; + //At least one of the donation unit keys is not known to the Donau. case MHD_HTTP_NOT_FOUND: biresp.hr.ec = TALER_JSON_get_error_code (j); biresp.hr.hint = TALER_JSON_get_error_hint (j); break; + //At least one of the corresponding private keys is deprecated/leaked. + case MHD_HTTP_GONE: + biresp.hr.ec = TALER_JSON_get_error_code (j); + biresp.hr.hint = TALER_JSON_get_error_hint (j); + break; case MHD_HTTP_CONTENT_TOO_LARGE: biresp.hr.ec = TALER_JSON_get_error_code (j); biresp.hr.hint = TALER_JSON_get_error_hint (j);