gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: transport: Reviewed communicator rekey t


From: gnunet
Subject: [gnunet] branch master updated: transport: Reviewed communicator rekey test. Fixes #6828
Date: Mon, 11 Mar 2024 15:08:54 +0100

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 09df2660e transport: Reviewed communicator rekey test. Fixes #6828
09df2660e is described below

commit 09df2660e393349d5cec05ebc18b3096b8085e66
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Mon Mar 11 15:06:55 2024 +0100

    transport: Reviewed communicator rekey test. Fixes #6828
    
    The TCP communicator already expires keys according to config, but it
    was not possible to configure the maximum rekey bytes.
    Note that we also still do not have test that tests this specifically.
    Conversely, the UDP communicator test tests the expiration after the
    number of bytes, but the option for the expiration is not used still.
---
 src/service/transport/gnunet-communicator-tcp.c | 36 ++++++++++++++++++++++---
 src/service/transport/gnunet-communicator-udp.c |  2 +-
 src/service/transport/test_communicator_basic.c | 35 +++++++++++++++++++++---
 3 files changed, 64 insertions(+), 9 deletions(-)

diff --git a/src/service/transport/gnunet-communicator-tcp.c 
b/src/service/transport/gnunet-communicator-tcp.c
index ccc32d65c..0ab8c0c82 100644
--- a/src/service/transport/gnunet-communicator-tcp.c
+++ b/src/service/transport/gnunet-communicator-tcp.c
@@ -832,6 +832,11 @@ static struct GNUNET_CONTAINER_MultiHashMap *lt_map;
  */
 static struct GNUNET_PeerIdentity my_identity;
 
+/**
+ * The rekey byte maximum
+ */
+static unsigned long long rekey_max_bytes;
+
 /**
  * The rekey interval
  */
@@ -1560,7 +1565,7 @@ setup_out_cipher (struct Queue *queue, struct 
GNUNET_HashCode *dh)
   setup_cipher (dh, &queue->target, &queue->out_cipher, &queue->out_hmac);
   queue->rekey_time = GNUNET_TIME_relative_to_absolute (rekey_interval);
   queue->rekey_left_bytes =
-    GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, REKEY_MAX_BYTES);
+    GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, rekey_max_bytes);
 }
 
 
@@ -2036,6 +2041,14 @@ try_handle_plaintext (struct Queue *queue)
     size = ntohs (hdr->size) + sizeof(*box);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Handling plaintext, box processed!\n");
+    GNUNET_STATISTICS_update (stats,
+                              "# bytes decrypted with BOX",
+                              size,
+                              GNUNET_NO);
+    GNUNET_STATISTICS_update (stats,
+                              "# messages decrypted with BOX",
+                              1,
+                              GNUNET_NO);
     break;
 
   case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY:
@@ -2061,6 +2074,10 @@ try_handle_plaintext (struct Queue *queue)
     size = ntohs (hdr->size);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Handling plaintext, rekey processed!\n");
+    GNUNET_STATISTICS_update (stats,
+                              "# rekeying successful",
+                              1,
+                              GNUNET_NO);
     break;
 
   case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH:
@@ -3556,7 +3573,7 @@ do_shutdown (void *cls)
   }
   if (NULL != stats)
   {
-    GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
+    GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
     stats = NULL;
   }
   if (NULL != my_private_key)
@@ -3765,7 +3782,7 @@ init_socket (struct sockaddr *addr,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Bound to `%s'\n",
               GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len));
-  stats = GNUNET_STATISTICS_create ("C-TCP", cfg);
+  stats = GNUNET_STATISTICS_create ("communicator-tcp", cfg);
 
   if (NULL == is)
     is = GNUNET_NT_scanner_init ();
@@ -4008,14 +4025,25 @@ run (void *cls,
                                              COMMUNICATOR_CONFIG_SECTION,
                                              "MAX_QUEUE_LENGTH",
                                              &max_queue_length))
+  {
     max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
+  }
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_time (cfg,
                                            COMMUNICATOR_CONFIG_SECTION,
                                            "REKEY_INTERVAL",
                                            &rekey_interval))
+  {
     rekey_interval = DEFAULT_REKEY_INTERVAL;
-
+  }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (cfg,
+                                             COMMUNICATOR_CONFIG_SECTION,
+                                             "REKEY_MAX_BYTES",
+                                             &rekey_max_bytes))
+  {
+    rekey_max_bytes = REKEY_MAX_BYTES;
+  }
   peerstore = GNUNET_PEERSTORE_connect (cfg);
   if (NULL == peerstore)
   {
diff --git a/src/service/transport/gnunet-communicator-udp.c 
b/src/service/transport/gnunet-communicator-udp.c
index 406c52bff..76e5d7906 100644
--- a/src/service/transport/gnunet-communicator-udp.c
+++ b/src/service/transport/gnunet-communicator-udp.c
@@ -3491,7 +3491,7 @@ run (void *cls,
     GNUNET_break (0);
     my_port = 0;
   }
-  stats = GNUNET_STATISTICS_create ("C-UDP", cfg);
+  stats = GNUNET_STATISTICS_create ("communicator-udp", cfg);
   senders = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES);
   receivers = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES);
   senders_heap = GNUNET_CONTAINER_heap_create 
(GNUNET_CONTAINER_HEAP_ORDER_MIN);
diff --git a/src/service/transport/test_communicator_basic.c 
b/src/service/transport/test_communicator_basic.c
index 510791a47..78ac26b25 100644
--- a/src/service/transport/test_communicator_basic.c
+++ b/src/service/transport/test_communicator_basic.c
@@ -597,11 +597,32 @@ choose_phase (struct 
GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
                                                            "backchannel",
                                                            test_name))) )
     {
-      LOG (GNUNET_ERROR_TYPE_ERROR, "Getting statistics...\n");
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "Getting statistics UDP...\n");
       if (NULL != box_stats[peer_nr])
         GNUNET_STATISTICS_get_cancel (box_stats[peer_nr]);
       box_stats[peer_nr] = GNUNET_STATISTICS_get (stats[1],
-                                                  "C-UDP",
+                                                  "communicator-udp",
+                                                  "# messages decrypted with 
BOX",
+                                                  process_statistics_box_done,
+                                                  &process_statistics,
+                                                  tc_h);
+      if (NULL != rekey_stats[peer_nr])
+        GNUNET_STATISTICS_get_cancel (rekey_stats[peer_nr]);
+      rekey_stats[peer_nr] = GNUNET_STATISTICS_get (stats[1],
+                                                    "communicator-udp",
+                                                    "# rekeying successful",
+                                                    
process_statistics_rekey_done,
+                                                    &process_statistics,
+                                                    tc_h);
+    }
+    else if ((0 == strcmp ("tcp", communicator_name)) && (0 == strcmp ("rekey",
+                                                                        
test_name)))
+    {
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "Getting statistics... TCP\n");
+      if (NULL != box_stats[peer_nr])
+        GNUNET_STATISTICS_get_cancel (box_stats[peer_nr]);
+      box_stats[peer_nr] = GNUNET_STATISTICS_get (stats[1],
+                                                  "communicator-tcp",
                                                   //"# messages decrypted with 
BOX",
                                                   NULL,
                                                   process_statistics_box_done,
@@ -610,7 +631,7 @@ choose_phase (struct 
GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
       if (NULL != rekey_stats[peer_nr])
         GNUNET_STATISTICS_get_cancel (rekey_stats[peer_nr]);
       rekey_stats[peer_nr] = GNUNET_STATISTICS_get (stats[1],
-                                                    "C-UDP",
+                                                    "communicator-tcp",
                                                     "# rekeying successful",
                                                     
process_statistics_rekey_done,
                                                     &process_statistics,
@@ -1084,7 +1105,13 @@ run (void *cls)
                                                         "backchannel",
                                                         test_name))) )
     {
-      stats[i] = GNUNET_STATISTICS_create ("C-UDP",
+      stats[i] = GNUNET_STATISTICS_create ("communicator-udp",
+                                           cfg_peers[i]);
+    }
+    else if ((0 == strcmp ("tcp", communicator_name)) && (0 == strcmp ("rekey",
+                                                                        
test_name)))
+    {
+      stats[i] = GNUNET_STATISTICS_create ("communicator-tcp",
                                            cfg_peers[i]);
     }
     else if ((0 == strcmp ("bidirect", test_name)))

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