gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34313 - in gnunet/src: core util


From: gnunet
Subject: [GNUnet-SVN] r34313 - in gnunet/src: core util
Date: Tue, 30 Sep 2014 15:21:29 +0200

Author: grothoff
Date: 2014-09-30 15:21:29 +0200 (Tue, 30 Sep 2014)
New Revision: 34313

Modified:
   gnunet/src/core/gnunet-service-core_kx.c
   gnunet/src/util/crypto_crc.c
Log:
-doxygen, code cleanup


Modified: gnunet/src/core/gnunet-service-core_kx.c
===================================================================
--- gnunet/src/core/gnunet-service-core_kx.c    2014-09-30 08:38:28 UTC (rev 
34312)
+++ gnunet/src/core/gnunet-service-core_kx.c    2014-09-30 13:21:29 UTC (rev 
34313)
@@ -82,12 +82,12 @@
   struct GNUNET_MessageHeader header;
 
   /**
-   * Status of the sender (should be in "enum PeerStateMachine"), nbo.
+   * Status of the sender (should be in `enum PeerStateMachine`), nbo.
    */
   int32_t sender_status GNUNET_PACKED;
 
   /**
-   * An ECC signature of the 'origin' asserting the validity of
+   * An ECC signature of the @e origin_identity asserting the validity of
    * the given ephemeral key.
    */
   struct GNUNET_CRYPTO_EddsaSignature signature;
@@ -230,7 +230,7 @@
 
 
 /**
- * Number of bytes (at the beginning) of "struct EncryptedMessage"
+ * Number of bytes (at the beginning) of `struct EncryptedMessage`
  * that are NOT encrypted.
  */
 #define ENCRYPTED_HEADER_SIZE (offsetof(struct EncryptedMessage, 
sequence_number))
@@ -385,7 +385,7 @@
  * Inform the given monitor about the KX state of
  * the given peer.
  *
- * @param mc monitor to inform
+ * @param client client to inform
  * @param kx key exchange state to inform about
  */
 static void
@@ -407,6 +407,22 @@
 
 
 /**
+ * Calculate seed value we should use for a message.
+ *
+ * @param kx key exchange context
+ */
+static uint32_t
+calculate_seed (struct GSC_KeyExchangeInfo *kx)
+{
+  /* Note: may want to make this non-random and instead
+     derive from key material to avoid having an undetectable
+     side-channel */
+  return htonl (GNUNET_CRYPTO_random_u32
+               (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX));
+}
+
+
+/**
  * Inform all monitors about the KX state of the given peer.
  *
  * @param kx key exchange state to inform about
@@ -657,8 +673,7 @@
   pm = &kx->ping;
   pm->header.size = htons (sizeof (struct PingMessage));
   pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING);
-  pm->iv_seed =
-      GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
+  pm->iv_seed = calculate_seed (kx);
   derive_iv (&iv, &kx->encrypt_key, pm->iv_seed, &kx->peer);
   pp.challenge = kx->ping_challenge;
   pp.target = kx->peer;
@@ -1026,8 +1041,7 @@
   tx.target = t.target;
   tp.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PONG);
   tp.header.size = htons (sizeof (struct PongMessage));
-  tp.iv_seed =
-      GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
+  tp.iv_seed = calculate_seed (kx);
   derive_pong_iv (&iv, &kx->encrypt_key, tp.iv_seed, t.challenge, &kx->peer);
   do_encrypt (kx, &iv, &tx.challenge, &tp.challenge,
               sizeof (struct PongMessage) - ((void *) &tp.challenge -
@@ -1276,7 +1290,7 @@
  *
  * @param kx key exchange context
  * @param payload payload of the message
- * @param payload_size number of bytes in 'payload'
+ * @param payload_size number of bytes in @a payload
  */
 void
 GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
@@ -1291,10 +1305,8 @@
   struct GNUNET_CRYPTO_AuthKey auth_key;
 
   ph = (struct EncryptedMessage *) pbuf;
-  ph->iv_seed =
-      htonl (GNUNET_CRYPTO_random_u32
-             (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX));
   ph->sequence_number = htonl (++kx->last_sequence_number_sent);
+  ph->iv_seed = calculate_seed (kx);
   ph->reserved = 0;
   ph->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
   memcpy (&ph[1], payload, payload_size);

Modified: gnunet/src/util/crypto_crc.c
===================================================================
--- gnunet/src/util/crypto_crc.c        2014-09-30 08:38:28 UTC (rev 34312)
+++ gnunet/src/util/crypto_crc.c        2014-09-30 13:21:29 UTC (rev 34313)
@@ -118,7 +118,7 @@
  * @param sum current sum, initially 0
  * @param buf buffer to calculate CRC over (must be 16-bit aligned)
  * @param len number of bytes in hdr, must be multiple of 2
- * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to 
get actual crc16)
+ * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish() 
to get actual crc16)
  */
 uint32_t
 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len)
@@ -133,7 +133,7 @@
 
 
 /**
- * Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
+ * Convert results from #GNUNET_CRYPTO_crc16_step() to final crc16.
  *
  * @param sum cummulative sum
  * @return crc16 value




reply via email to

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