gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-donau] branch master updated: fix keys warnings


From: gnunet
Subject: [taler-donau] branch master updated: fix keys warnings
Date: Wed, 13 Mar 2024 14:24:55 +0100

This is an automated email from the git hooks/post-receive script.

johannes-casaburi pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new a6f2a29  fix keys warnings
a6f2a29 is described below

commit a6f2a29acd0e90bdb368a0773eb63b4c41d4e789
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Wed Mar 13 14:24:19 2024 +0100

    fix keys warnings
---
 src/donau/donau-httpd_keys.c   | 95 ++++++++++++++++++++++++++----------------
 src/include/donau_crypto_lib.h | 12 ++++++
 2 files changed, 70 insertions(+), 37 deletions(-)

diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c
index 39f7c9c..002f713 100644
--- a/src/donau/donau-httpd_keys.c
+++ b/src/donau/donau-httpd_keys.c
@@ -427,12 +427,12 @@ struct HelperState
   /**
    * Handle for the donation_unit/RSA helper.
    */
-  struct DONAU_CRYPTO_RsaDenominationUnitHelper *rsadh;
+  struct TALER_CRYPTO_RsaDenominationHelper *rsadh;
 
   /**
    * Handle for the donation_unit/CS helper.
    */
-  struct TALER_CRYPTO_CsDenominationUnitHelper *csdh;
+  struct TALER_CRYPTO_CsDenominationHelper *csdh;
 
   /**
    * Map from H(donation_unit_pub) to `struct HelperDonationUnit` entries.
@@ -509,14 +509,14 @@ add_sign_key_cb (void *cls,
   struct SigningKey *sk = value;
 
   (void) pid;
-  // if (GNUNET_TIME_absolute_is_future (sk->meta.expire_sign.abs_time))
-  // {
-  //  ctx->min_sk_frequency =
-  //    GNUNET_TIME_relative_min (ctx->min_sk_frequency,
-  //                              GNUNET_TIME_absolute_get_difference (
-  //                                sk->meta.start.abs_time,
-  //                                sk->meta.expire_sign.abs_time));
-  // }
+  if (GNUNET_TIME_absolute_is_future (sk->meta.expire_sign.abs_time))
+  {
+    ctx->min_sk_frequency =
+      GNUNET_TIME_relative_min (ctx->min_sk_frequency,
+                                GNUNET_TIME_absolute_get_difference (
+                                  sk->meta.valid_from.abs_time,
+                                  sk->meta.expire_sign.abs_time));
+  }
   GNUNET_assert (0 == json_array_append_new (ctx->signkeys, GNUNET_JSON_PACK (
                                                GNUNET_JSON_pack_timestamp (
                                                  "stamp_start",
@@ -600,13 +600,13 @@ struct KeysBuilderContext
  * data) to the JSON array.
  *
  * @param cls the `struct FutureBuilderContext *`
- * @param h_donation_unit_pub hash of the donation unit public key
+ * @param h_du_pub hash of the donation unit public key
  * @param value a `struct HelperDonationUnit`
  * @return #GNUNET_OK (continue to iterate)
  */
 static enum GNUNET_GenericReturnValue
 insert_donation_unit_cb (void *cls,
-                         const struct GNUNET_HashCode *h_donation_unit_pub,
+                         const struct GNUNET_HashCode *h_du_pub,
                          void *value)
 {
   struct KeysBuilderContext *kbc = cls;
@@ -615,7 +615,7 @@ insert_donation_unit_cb (void *cls,
 
   du = GNUNET_CONTAINER_multihashmap_get (
     kbc->ksh->donation_unit_map,
-    h_donation_unit_pub);
+    h_du_pub);
   if (NULL != du)
     return GNUNET_OK; /* skip: this key is already active! */
   // if (GNUNET_TIME_relative_is_zero (hd->validity_duration))
@@ -627,8 +627,8 @@ insert_donation_unit_cb (void *cls,
       GNUNET_JSON_PACK (
         GNUNET_JSON_pack_data_auto ("donation_unit_pub",
                                     &hd->donation_unit_pub),
-        // GNUNET_JSON_pack_uint64 ("validity_year",
-        //                          du->validity_year),
+        GNUNET_JSON_pack_uint64 ("validity_year",
+                                 du->validity_year),
         // TALER_JSON_pack_amount ("value",
         //                         &du->value),
         GNUNET_JSON_pack_data_auto ("donation_unit_secmod_sig",
@@ -645,7 +645,7 @@ insert_donation_unit_cb (void *cls,
  * and @a denoms.
  *
  * @param[in,out] ksh key state handle we build @a krd for
- * @param[in] denom_keys_hash hash over all the denomination keys in @a denoms
+ * @param[in] h_donation_unit_pub hash over all the denomination keys in @a 
denoms
  * @param last_cherry_pick_date timestamp to use
  * @param[in,out] signkeys list of sign keys to return
  * @param[in,out] grouped_donation_units list of grouped denominations to 
return
@@ -653,19 +653,19 @@ insert_donation_unit_cb (void *cls,
  */
 static enum GNUNET_GenericReturnValue
 create_krd (struct DH_KeyStateHandle *ksh,
-            const struct GNUNET_HashCode *denom_keys_hash,
+            const struct GNUNET_HashCode *h_du_pub,
             struct GNUNET_TIME_Timestamp last_cherry_pick_date,
             json_t *signkeys,
             json_t *grouped_donation_units)
 {
   struct KeysResponseData krd;
   struct DONAU_DonauPublicKeyP donau_pub;
-  struct DONAU_DonauSignatureP donau_sig;
+  // struct DONAU_DonauSignatureP donau_sig;
   json_t *keys;
 
 
-  // GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
-  //                  last_cherry_pick_date.abs_time));
+  GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
+                   last_cherry_pick_date.abs_time));
   GNUNET_assert (NULL != signkeys);
   GNUNET_assert (NULL != grouped_donation_units);
   GNUNET_assert (NULL != DH_currency);
@@ -684,7 +684,7 @@ create_krd (struct DH_KeyStateHandle *ksh,
   //           &TEH_keys_donau_sign2_,
   //           ksh,
   //           last_cherry_pick_date,
-  //           denom_keys_hash,
+  //           h_donation_unit_pub,
   //           &donau_pub,
   //           &donau_sig)))
   //  {
@@ -698,9 +698,10 @@ create_krd (struct DH_KeyStateHandle *ksh,
   {
     const struct SigningKey *sk;
 
-    sk = GNUNET_CONTAINER_multipeermap_get (
-      ksh->signkey_map,
-      (const struct GNUNET_PeerIdentity *) &donau_pub);
+    sk = GNUNET_CONTAINER_multipeermap_get (ksh->signkey_map,
+                                            (const struct GNUNET_PeerIdentity 
*)
+                                            &donau_pub);
+
     ksh->signature_expires = GNUNET_TIME_timestamp_min (sk->meta.expire_sign,
                                                         
ksh->signature_expires);
   }
@@ -969,6 +970,18 @@ finish_keys_response (struct DH_KeyStateHandle *ksh)
           /* There is no group for this meta-data yet, so we create a new 
group */
           const char *cipher;
 
+          switch (meta.cipher)
+          {
+          case GNUNET_CRYPTO_BSA_RSA:
+            cipher = "RSA";
+            break;
+          case GNUNET_CRYPTO_BSA_CS:
+            cipher = "CS";
+            break;
+          default:
+            GNUNET_assert (false);
+          }
+
           group = GNUNET_new (struct GroupData);
 
           /* Create a new array for the donation_units in this group */
@@ -994,7 +1007,8 @@ finish_keys_response (struct DH_KeyStateHandle *ksh)
             GNUNET_CONTAINER_multihashmap_put (donation_units_by_group,
                                                &key,
                                                group,
-                                               
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+                                               
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
+            );
         }
 
         /* Now that we have found/created the right group, add the
@@ -1114,14 +1128,14 @@ CLEANUP:
  */
 static enum GNUNET_GenericReturnValue
 clear_donation_unit_cb (void *cls,
-                        const struct GNUNET_HashCode *h_donation_unit_pub,
+                        const struct GNUNET_HashCode *h_du_pub,
                         void *value)
 {
   struct DH_DonationUnitKey *dk = value;
 
   (void) cls;
-  (void) h_donation_unit_pub;
-  // TALER_donation_unit_pub_free (&dk->donation_unit_pub);
+  (void) h_du_pub;
+  DONAU_donation_unit_pub_free (&dk->donation_unit_pub);
   GNUNET_free (dk);
   return GNUNET_OK;
 }
@@ -1220,7 +1234,8 @@ check_donation_unit_rsa_sm_pub (const struct
     if (! GNUNET_is_zero (&donation_unit_rsa_sm_pub))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Our RSA security module changed its key. This must not 
happen.\n");
+                  "Our RSA security module changed its key. This must not 
happen.\n")
+      ;
       GNUNET_assert (0);
     }
     donation_unit_rsa_sm_pub = *sm_pub; /* TOFU ;-) */
@@ -1245,7 +1260,8 @@ check_donation_unit_cs_sm_pub (const struct
     if (! GNUNET_is_zero (&donation_unit_cs_sm_pub))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Our CS security module changed its key. This must not 
happen.\n");
+                  "Our CS security module changed its key. This must not 
happen.\n")
+      ;
       GNUNET_assert (0);
     }
     donation_unit_cs_sm_pub = *sm_pub; /* TOFU ;-) */
@@ -1269,7 +1285,8 @@ check_esign_sm_pub (const struct 
TALER_SecurityModulePublicKeyP *sm_pub)
     if (! GNUNET_is_zero (&esign_sm_pub))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Our EdDSA security module changed its key. This must not 
happen.\n");
+                  "Our EdDSA security module changed its key. This must not 
happen.\n")
+      ;
       GNUNET_assert (0);
     }
     esign_sm_pub = *sm_pub; /* TOFU ;-) */
@@ -1288,7 +1305,8 @@ check_esign_sm_pub (const struct 
TALER_SecurityModulePublicKeyP *sm_pub)
  */
 static enum GNUNET_GenericReturnValue
 free_donation_unit_cb (void *cls,
-                       const struct GNUNET_HashCode *h_donation_unit_pub,
+                       const struct DONAU_DonationUnitHashP 
*h_donation_unit_pub
+                       ,
                        void *value)
 {
   struct HelperDonationUnit *hd = value;
@@ -1476,7 +1494,7 @@ helper_rsa_cb (
     GNUNET_OK ==
     GNUNET_CONTAINER_multihashmap_put (
       hs->donation_unit,
-      &hd->h_donation_unit_pub,
+      &hd->h_donation_unit_pub.hash,
       hd,
       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   GNUNET_assert (
@@ -1739,7 +1757,8 @@ donation_unit_info_cb (
     GNUNET_CONTAINER_multihashmap_put (ksh->donation_unit_map,
                                        &dk->h_donation_unit_pub.hash,
                                        dk,
-                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
+    );
 }
 
 
@@ -1754,7 +1773,7 @@ static void
 iterate_active_signing_keys_cb (
   void *cls,
   const struct DONAU_DonauPublicKeyP *donau_pub,
-  const struct DONAUDB_SignkeyMetaData *meta)
+  struct DONAUDB_SignkeyMetaData *meta)
 {
   struct DH_KeyStateHandle *ksh = cls;
   struct SigningKey *sk;
@@ -1769,7 +1788,8 @@ iterate_active_signing_keys_cb (
     GNUNET_CONTAINER_multipeermap_put (ksh->signkey_map,
                                        &pid,
                                        sk,
-                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)
+    );
 }
 
 
@@ -1841,7 +1861,8 @@ build_key_state (struct HelperState *hs)
   {
     GNUNET_log (
       GNUNET_ERROR_TYPE_WARNING,
-      "Could not finish /keys response (likely no signing keys available 
yet)\n");
+      "Could not finish /keys response (likely no signing keys available 
yet)\n")
+    ;
     destroy_key_state (ksh,
                        true);
     return NULL;
diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h
index 3d89af4..a3e6960 100644
--- a/src/include/donau_crypto_lib.h
+++ b/src/include/donau_crypto_lib.h
@@ -156,6 +156,18 @@ void
 DONAU_donation_unit_pub_free (struct
                               DONAU_DonationUnitPublicKey *donation_unit_pub);
 
+/**
+ * Compute the hash of the given @a donation_unit_pub.
+ *
+ * @param donation_unit_pub public key to hash
+ * @param[out] donation_unit_hash resulting hash value
+ */
+void
+DONAU_donation_unit_pub_hash (const struct
+                              DONAU_DonationUnitPublicKey *donation_unit_pub,
+                              struct DONAU_DonationUnitHashP 
*donation_unit_hash
+                              );
+
 /**
  * Hash used to represent a Donation Receipt
  */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]