gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 01/04: Core: Reverted code for complex ephemeral handling.


From: gnunet
Subject: [gnunet] 01/04: Core: Reverted code for complex ephemeral handling.
Date: Mon, 05 Feb 2024 14:47:42 +0100

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

t3sserakt pushed a commit to branch master
in repository gnunet.

commit 3ff5ca2600bb75814bd00c616fcc8e6b5a5e04b1
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Mon Feb 5 11:44:44 2024 +0100

    Core: Reverted code for complex ephemeral handling.
---
 src/service/core/gnunet-service-core_kx.c | 110 +++++++++++-------------------
 1 file changed, 40 insertions(+), 70 deletions(-)

diff --git a/src/service/core/gnunet-service-core_kx.c 
b/src/service/core/gnunet-service-core_kx.c
index fc9bfd7b9..68efe98f0 100644
--- a/src/service/core/gnunet-service-core_kx.c
+++ b/src/service/core/gnunet-service-core_kx.c
@@ -693,14 +693,6 @@ deliver_message (void *cls, const struct 
GNUNET_MessageHeader *m)
 }
 
 
-static void
-do_rekey (void *cls);
-
-
-static void
-sign_ephemeral_key ();
-
-
 /**
  * Function called by transport to notify us that
  * a peer connected to us (on the network level).
@@ -726,66 +718,34 @@ handle_transport_notify_connect (void *cls,
                             gettext_noop ("# key exchanges initiated"),
                             1,
                             GNUNET_NO);
-  for (kx = kx_head; NULL != kx; kx = kx->next)
-  {
-    if (0 == memcmp (pid, kx->peer, sizeof(struct GNUNET_PeerIdentity)))
-      break;
-  }
-  if (NULL == kx)
+  
+  kx = GNUNET_new (struct GSC_KeyExchangeInfo);
+  kx->mst = GNUNET_MST_create (&deliver_message, kx);
+  kx->mq = mq;
+  kx->peer = pid;
+  kx->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY;
+  GNUNET_CONTAINER_DLL_insert (kx_head, kx_tail, kx);
+  kx->status = GNUNET_CORE_KX_STATE_KEY_SENT;
+  monitor_notify_all (kx);
+  GNUNET_CRYPTO_hash (pid, sizeof(struct GNUNET_PeerIdentity), &h1);
+  GNUNET_CRYPTO_hash (&GSC_my_identity,
+                      sizeof(struct GNUNET_PeerIdentity),
+                      &h2);
+  if (0 < GNUNET_CRYPTO_hash_cmp (&h1, &h2))
   {
-    GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
-    sign_ephemeral_key ();
-    {
-      struct GNUNET_HashCode eh;
-
-      GNUNET_CRYPTO_hash (&current_ekm.ephemeral_key,
-                          sizeof(current_ekm.ephemeral_key),
-                          &eh);
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  "Starting with ephemeral key %s\n",
-                  GNUNET_h2s (&eh));
-    }
-    kx = GNUNET_new (struct GSC_KeyExchangeInfo);
-    kx->mst = GNUNET_MST_create (&deliver_message, kx);
-    kx->mq = mq;
-    kx->peer = pid;
-    kx->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY;
-    GNUNET_CONTAINER_DLL_insert (kx_head, kx_tail, kx);
-    kx->status = GNUNET_CORE_KX_STATE_KEY_SENT;
-    monitor_notify_all (kx);
-    GNUNET_CRYPTO_hash (pid, sizeof(struct GNUNET_PeerIdentity), &h1);
-    GNUNET_CRYPTO_hash (&GSC_my_identity,
-                        sizeof(struct GNUNET_PeerIdentity),
-                        &h2);
-    if (0 < GNUNET_CRYPTO_hash_cmp (&h1, &h2))
-      {
-        /* peer with "lower" identity starts KX, otherwise we typically end up
-           with both peers starting the exchange and transmit the 'set key'
-           message twice */
-        send_key (kx);
-      }
-    else
-      {
-        /* peer with "higher" identity starts a delayed KX, if the "lower" peer
-         * does not start a KX since it sees no reasons to do so  */
-        kx->retry_set_key_task =
-          GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                        &set_key_retry_task,
-                                        kx);
-      }
+    /* peer with "lower" identity starts KX, otherwise we typically end up
+       with both peers starting the exchange and transmit the 'set key'
+       message twice */
+    send_key (kx);
   }
   else
   {
-    struct GNUNET_TIME_Relative left;
-
-    left = GNUNET_TIME_absolute_get_remaining (kx->timeout);
-    if (0 == left.rel_value_us)
-    {
-      kx->status = GNUNET_CORE_KX_STATE_DOWN;
-    }
-    else
-      kx->status = GNUNET_CORE_KX_STATE_REKEY_SENT;
-    do_rekey (NULL);
+    /* peer with "higher" identity starts a delayed KX, if the "lower" peer
+     * does not start a KX since it sees no reasons to do so  */
+    kx->retry_set_key_task =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                    &set_key_retry_task,
+                                    kx);
   }
   return kx;
 }
@@ -1092,6 +1052,10 @@ handle_ephemeral_key (void *cls, const struct 
EphemeralKeyMessage *m)
 }
 
 
+static void
+send_keep_alive (void *cls);
+
+
 /**
  * We received a PING message.  Validate and transmit
  * a PONG message.
@@ -1798,11 +1762,6 @@ do_rekey (void *cls)
   struct GSC_KeyExchangeInfo *pos;
 
   (void) cls;
-  if (NULL != rekey_task)
-  {
-    GNUNET_SCHEDULER_cancel (rekey_task);
-    rekey_task = NULL;
-  }
   rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_FREQUENCY, &do_rekey, NULL);
   GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
   sign_ephemeral_key ();
@@ -1865,7 +1824,18 @@ GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
   my_private_key = *pk;
   GNUNET_CRYPTO_eddsa_key_get_public (&my_private_key,
                                       &GSC_my_identity.public_key);
-  
+  GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
+  sign_ephemeral_key ();
+  {
+    struct GNUNET_HashCode eh;
+
+    GNUNET_CRYPTO_hash (&current_ekm.ephemeral_key,
+                        sizeof(current_ekm.ephemeral_key),
+                        &eh);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Starting with ephemeral key %s\n",
+                GNUNET_h2s (&eh));
+  }
 
   nc = GNUNET_notification_context_create (1);
   rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_FREQUENCY, &do_rekey, NULL);

-- 
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]