donau

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

commit 22a490d729b470c7f30236f80617b9103c656028
parent f6147b01989563435ea723da76aabca9a3a69959
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date:   Fri, 29 Mar 2024 16:36:14 +0100

fix keys hashmap

Diffstat:
Msrc/donau/donau-httpd_keys.c | 60+++++++++++++++++++++++++++++-------------------------------
Msrc/donau/donau-httpd_keys.h | 86++++---------------------------------------------------------------------------
2 files changed, 33 insertions(+), 113 deletions(-)

diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c @@ -252,11 +252,6 @@ struct HelperState struct TALER_CRYPTO_CsDenominationHelper *csdh; /** - * Map from H(donation_unit_pub) to `struct DH_DonationUnitKey` entries. - */ - struct GNUNET_CONTAINER_MultiHashMap *donation_unit; - - /** * Map from H(rsa_pub) to `struct DH_DonationUnitKey` entries. */ struct GNUNET_CONTAINER_MultiHashMap *rsa_keys; @@ -1045,7 +1040,8 @@ helper_rsa_cb ( const struct TALER_SecurityModulePublicKeyP *sm_pub, const struct TALER_SecurityModuleSignatureP *sm_sig) { - struct HelperState *hs = cls; + struct DH_KeyStateHandle *ksh = cls; + struct HelperState *hs = ksh->helpers; struct DH_DonationUnitKey *hd; struct TALER_Amount value; enum GNUNET_DB_QueryStatus qs; @@ -1071,12 +1067,13 @@ helper_rsa_cb ( false)); hd = GNUNET_CONTAINER_multihashmap_get (hs->rsa_keys, &h_rsa->hash); - // if (NULL != hd) - // { - // /* should be just an update (revocation!), so update existing entry */ - // hd->validity_duration = validity_duration; hd->lost = false; - // return; - // } + if (NULL != hd) + { + /* should be just an update (revocation!), so update existing entry */ + // hd->validity_duration = validity_duration; + hd->lost = false; + return; + } GNUNET_assert (NULL != sm_pub); check_donation_unit_rsa_sm_pub (sm_pub); hd = GNUNET_new (struct DH_DonationUnitKey); @@ -1107,7 +1104,7 @@ helper_rsa_cb ( GNUNET_assert ( GNUNET_OK == GNUNET_CONTAINER_multihashmap_put ( - hs->donation_unit, + ksh->donation_unit_map, &hd->h_donation_unit_pub.hash, hd, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); @@ -1149,7 +1146,8 @@ helper_cs_cb ( const struct TALER_SecurityModulePublicKeyP *sm_pub, const struct TALER_SecurityModuleSignatureP *sm_sig) { - struct HelperState *hs = cls; + struct DH_KeyStateHandle *ksh = cls; + struct HelperState *hs = ksh->helpers; struct DH_DonationUnitKey *hd; struct TALER_Amount value; enum GNUNET_DB_QueryStatus qs; @@ -1212,7 +1210,7 @@ helper_cs_cb ( GNUNET_assert ( GNUNET_OK == GNUNET_CONTAINER_multihashmap_put ( - hs->donation_unit, + ksh->donation_unit_map, &hd->h_donation_unit_pub.hash, hd, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); @@ -1252,7 +1250,8 @@ helper_esign_cb ( const struct TALER_SecurityModulePublicKeyP *sm_pub, const struct TALER_SecurityModuleSignatureP *sm_sig) { - struct HelperState *hs = cls; + struct DH_KeyStateHandle *ksh = cls; + struct HelperState *hs = ksh->helpers; struct SigningKey *hsk; struct GNUNET_PeerIdentity pid; /* need to "cast" because secmod works with TALER_ExchangePublicKeyP */ @@ -1306,7 +1305,7 @@ helper_esign_cb ( } if (qs < 0) { - // ... + // FIXME } GNUNET_assert ( GNUNET_OK == @@ -1327,11 +1326,10 @@ helper_esign_cb ( * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -setup_key_helpers (struct HelperState *hs) +setup_key_helpers (struct DH_KeyStateHandle *ksh) { - hs->donation_unit - = GNUNET_CONTAINER_multihashmap_create (1024, - GNUNET_YES); + struct HelperState *hs = ksh->helpers; + hs->rsa_keys = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES); @@ -1344,7 +1342,7 @@ setup_key_helpers (struct HelperState *hs) hs->rsadh = TALER_CRYPTO_helper_rsa_connect (DH_cfg, "donau", &helper_rsa_cb, - hs); + ksh); if (NULL == hs->rsadh) { destroy_key_helpers (hs); @@ -1353,7 +1351,7 @@ setup_key_helpers (struct HelperState *hs) hs->csdh = TALER_CRYPTO_helper_cs_connect (DH_cfg, "donau", &helper_cs_cb, - hs); + ksh); if (NULL == hs->csdh) { destroy_key_helpers (hs); @@ -1362,7 +1360,7 @@ setup_key_helpers (struct HelperState *hs) hs->esh = TALER_CRYPTO_helper_esign_connect (DH_cfg, "donau", &helper_esign_cb, - hs); + ksh); if (NULL == hs->esh) { destroy_key_helpers (hs); @@ -1486,10 +1484,15 @@ build_key_state (struct HelperState *hs) ksh->reload_time = GNUNET_TIME_timestamp_get (); /* We must use the key_generation from when we STARTED the process! */ ksh->key_generation = key_generation; + ksh->donation_unit_map = GNUNET_CONTAINER_multihashmap_create (1024, + true); + ksh->signkey_map = GNUNET_CONTAINER_multipeermap_create (32, + false /* MUST be false! */ + ); if (NULL == hs) { ksh->helpers = GNUNET_new (struct HelperState); - if (GNUNET_OK != setup_key_helpers (ksh->helpers)) + if (GNUNET_OK != setup_key_helpers (ksh)) { GNUNET_free (ksh->helpers); GNUNET_assert (NULL == ksh->keys_reply); @@ -1501,11 +1504,6 @@ build_key_state (struct HelperState *hs) { ksh->helpers = hs; } - ksh->donation_unit_map = GNUNET_CONTAINER_multihashmap_create (1024, - true); - ksh->signkey_map = GNUNET_CONTAINER_multipeermap_create (32, - false /* MUST be false! */ - ); /* NOTE: fetches master-signed signkeys, but ALSO those that were revoked! */ GNUNET_break (GNUNET_OK == @@ -1708,7 +1706,7 @@ DH_handler_keys (struct DH_RequestContext *rc, GNUNET_assert (NULL != kbc.donation_units); GNUNET_assert (NULL != kbc.signkeys); GNUNET_assert (NULL != DH_currency); - GNUNET_CONTAINER_multihashmap_iterate (ksh->helpers->donation_unit, + GNUNET_CONTAINER_multihashmap_iterate (ksh->donation_unit_map, &insert_donation_unit_cb, &kbc); GNUNET_CONTAINER_multipeermap_iterate (ksh->helpers->esign_keys, diff --git a/src/donau/donau-httpd_keys.h b/src/donau/donau-httpd_keys.h @@ -59,90 +59,12 @@ struct DH_DonationUnitKey */ struct TALER_Amount value; -}; - -/** - * Information needed to create a blind signature. - */ -// struct DH_CoinSignData -// { -/** - * Hash of key to sign with. - */ -// const struct TALER_DenominationHashP *h_denom_pub; - -/** - * Blinded planchet to sign over. + /** + * Did we lose the private keys? */ -// const struct TALER_BlindedPlanchet *bp; -// }; - - -// /** -// * Request to sign @a csds. -// * -// * @param csds array with data to blindly sign (and keys to sign with) -// * @param csds_length length of @a csds array -// * @param for_melt true if this is for a melt operation -// * @param[out] bss array set to the blind signature on success; must be of length @a csds_length -// * @return #TALER_EC_NONE on success -// */ -// enum TALER_ErrorCode -// TEH_keys_denomination_batch_sign ( -// unsigned int csds_length, -// const struct TEH_CoinSignData csds[static csds_length], -// bool for_melt, -// struct TALER_BlindedDenominationSignature bss[static csds_length]); - - -// /** -// * Information needed to derive the CS r_pub. -// */ -// struct TEH_CsDeriveData -// { -// /** -// * Hash of key to sign with. -// */ -// const struct TALER_DenominationHashP *h_denom_pub; - -// /** -// * Nonce to use. -// */ -// const struct GNUNET_CRYPTO_CsSessionNonce *nonce; -// }; - - -// /** -// * Request to derive CS @a r_pub using the denomination and nonce from @a cdd. -// * -// * @param cdd data to compute @a r_pub from -// * @param for_melt true if this is for a melt operation -// * @param[out] r_pub where to write the result -// * @return #TALER_EC_NONE on success -// */ -// enum TALER_ErrorCode -// TEH_keys_denomination_cs_r_pub ( -// const struct TEH_CsDeriveData *cdd, -// bool for_melt, -// struct GNUNET_CRYPTO_CSPublicRPairP *r_pub); - -// /** -// * Request to derive a bunch of CS @a r_pubs using the -// * denominations and nonces from @a cdds. -// * -// * @param cdds array to compute @a r_pubs from -// * @param cdds_length length of the @a cdds array -// * @param for_melt true if this is for a melt operation -// * @param[out] r_pubs array where to write the result; must be of length @a cdds_length -// * @return #TALER_EC_NONE on success -// */ -// enum TALER_ErrorCode -// TEH_keys_denomination_cs_batch_r_pub ( -// unsigned int cdds_length, -// const struct TEH_CsDeriveData cdds[static cdds_length], -// bool for_melt, -// struct GNUNET_CRYPTO_CSPublicRPairP r_pubs[static cdds_length]); + bool lost; +}; /** * Fully clean up keys subsystem.