[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 01/09: Changed creation of key for kx to be for every notificat
From: |
gnunet |
Subject: |
[gnunet] 01/09: Changed creation of key for kx to be for every notification of transport about a new connected peer. |
Date: |
Wed, 10 Jan 2024 11:59:58 +0100 |
This is an automated email from the git hooks/post-receive script.
t3sserakt pushed a commit to branch master
in repository gnunet.
commit a54d28cd8a4550a5e8345038d451cfd2b936fbba
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Wed Jan 10 11:04:55 2024 +0100
Changed creation of key for kx to be for every notification of transport
about a new connected peer.
---
src/service/core/gnunet-service-core_kx.c | 106 ++++++++++++++++++++----------
1 file changed, 71 insertions(+), 35 deletions(-)
diff --git a/src/service/core/gnunet-service-core_kx.c
b/src/service/core/gnunet-service-core_kx.c
index ca7bccbd9..440c88ca3 100644
--- a/src/service/core/gnunet-service-core_kx.c
+++ b/src/service/core/gnunet-service-core_kx.c
@@ -693,6 +693,14 @@ 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).
@@ -718,33 +726,66 @@ handle_transport_notify_connect (void *cls,
gettext_noop ("# key exchanges initiated"),
1,
GNUNET_NO);
- 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))
+ for (kx = kx_head; NULL != kx; kx = kx->next)
{
- /* 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);
+ if (0 == memcmp (pid, kx->peer, sizeof(struct GNUNET_PeerIdentity)))
+ break;
+ }
+ if (NULL == kx)
+ {
+ GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
+ sign_ephemeral_key ();
+ {
+ struct GNUNET_HashCode eh;
+
+ GNUNET_CRYPTO_hash (¤t_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);
+ }
}
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);
+ 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);
}
return kx;
}
@@ -1754,6 +1795,12 @@ 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 ();
@@ -1816,18 +1863,7 @@ 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 (¤t_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.
- [gnunet] branch master updated (577ad2f7d -> 29213833f), gnunet, 2024/01/10
- [gnunet] 04/09: Resuming communicators in case of core restarting., gnunet, 2024/01/10
- [gnunet] 01/09: Changed creation of key for kx to be for every notification of transport about a new connected peer.,
gnunet <=
- [gnunet] 02/09: Added missing GNUNET_TRANSPORT_core_receive_continue., gnunet, 2024/01/10
- [gnunet] 03/09: Fixed bug in logic getting root parent of fragment which is a DV box., gnunet, 2024/01/10
- [gnunet] 06/09: Fixed bug calculating next resend of fragments., gnunet, 2024/01/10
- [gnunet] 07/09: first_challenge_use has to be reset in case of revalidation., gnunet, 2024/01/10
- [gnunet] 08/09: When to resend a validation challenge and when to start revalidation needs to be seperate logic., gnunet, 2024/01/10
- [gnunet] 09/09: Merge branch 'master' of ssh://git.gnunet.org/gnunet, gnunet, 2024/01/10
- [gnunet] 05/09: Fixed bug in logic freeing timedout QueueEntry., gnunet, 2024/01/10