gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35865 - in gnunet/src: cadet include


From: gnunet
Subject: [GNUnet-SVN] r35865 - in gnunet/src: cadet include
Date: Thu, 4 Jun 2015 15:50:02 +0200

Author: grothoff
Date: 2015-06-04 15:50:02 +0200 (Thu, 04 Jun 2015)
New Revision: 35865

Modified:
   gnunet/src/cadet/cadet_protocol.h
   gnunet/src/cadet/gnunet-service-cadet_peer.c
   gnunet/src/cadet/gnunet-service-cadet_peer.h
   gnunet/src/cadet/gnunet-service-cadet_tunnel.c
   gnunet/src/include/gnunet_signatures.h
Log:
-simplifying Cadet KX to directly use EdDSA keys for ECDHE

Modified: gnunet/src/cadet/cadet_protocol.h
===================================================================
--- gnunet/src/cadet/cadet_protocol.h   2015-06-04 11:37:05 UTC (rev 35864)
+++ gnunet/src/cadet/cadet_protocol.h   2015-06-04 13:50:02 UTC (rev 35865)
@@ -127,23 +127,6 @@
   uint32_t force_reply;
 
   /**
-   * An EdDSA signature of the permanent ECDH key with the Peer's ID key.
-   */
-  struct GNUNET_CRYPTO_EddsaSignature signature;
-
-  /**
-   * Information about what is being signed (@a permanent_key).
-   */
-  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
-  /**
-   * Sender's permanent_key public ECC key encoded in a
-   * format suitable for network transmission, as created
-   * using 'gcry_sexp_sprint'.
-   */
-  struct GNUNET_CRYPTO_EcdhePublicKey permanent_key;
-
-  /**
    * Sender's ephemeral public ECC key encoded in a
    * format suitable for network transmission, as created
    * using 'gcry_sexp_sprint'.

Modified: gnunet/src/cadet/gnunet-service-cadet_peer.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.c        2015-06-04 11:37:05 UTC 
(rev 35864)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.c        2015-06-04 13:50:02 UTC 
(rev 35865)
@@ -120,34 +120,29 @@
  */
 struct CadetPeer
 {
-    /**
-     * ID of the peer
-     */
+  /**
+   * ID of the peer
+   */
   GNUNET_PEER_Id id;
 
-    /**
-     * Axolotl permanent public key.
-     */
-  struct GNUNET_CRYPTO_EcdhePublicKey ax_key;
-
-    /**
-     * Last time we heard from this peer
-     */
+  /**
+   * Last time we heard from this peer
+   */
   struct GNUNET_TIME_Absolute last_contact;
 
-    /**
-     * Paths to reach the peer, ordered by ascending hop count
-     */
+  /**
+   * Paths to reach the peer, ordered by ascending hop count
+   */
   struct CadetPeerPath *path_head;
 
-    /**
-     * Paths to reach the peer, ordered by ascending hop count
-     */
+  /**
+   * Paths to reach the peer, ordered by ascending hop count
+   */
   struct CadetPeerPath *path_tail;
 
-    /**
-     * Handle to stop the DHT search for paths to this peer
-     */
+  /**
+   * Handle to stop the DHT search for paths to this peer
+   */
   struct GCD_search_handle *search_h;
 
   /**
@@ -2383,61 +2378,6 @@
 
 
 /**
- * Check if the given ECDH key is correct for the peer.
- *
- * This function caches the results if the key has been previoulsy checked,
- * otherwise checks that the key is signed with the peer's ID (EdDSA key).
- *
- * TODO: save the cached public key to permanent storage / peerinfo.
- *
- * @param peer Peer whose key to check.
- * @param key ECDH key to check.
- * @param purpose Purpose of the signature (followed by the key).
- * @param sig Signature with the peer's EdDSA key (PeerID).
- */
-int
-GCP_check_key (struct CadetPeer *peer,
-               const struct GNUNET_CRYPTO_EcdhePublicKey *key,
-               const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
-               const struct GNUNET_CRYPTO_EddsaSignature *sig)
-{
-  struct GNUNET_CRYPTO_EddsaPublicKey *pub;
-  int verified;
-
-  /* Is it the same as the cached key? */
-  if (0 == memcmp (&peer->ax_key, key, sizeof (*key)))
-    return GNUNET_OK;
-
-  /* New key, verify. */
-  pub = (struct GNUNET_CRYPTO_EddsaPublicKey *) GCP_get_id (peer);
-  verified = GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_CADET_AXKX,
-                                         purpose, sig, pub);
-
-  if (GNUNET_OK != verified)
-    return GNUNET_SYSERR;
-
-  /* Cache key for later. */
-  peer->ax_key = *key;
-  return GNUNET_OK;
-}
-
-
-/**
- * Get the Identity ECDH key of the peer.
- *
- * @param peer Peer whose key to get.
- *
- * @return Peer's permanent ECDH key (might be all 0: unknown).
- *
- */
-struct GNUNET_CRYPTO_EcdhePublicKey *
-GCP_get_ecdh_key (struct CadetPeer *peer)
-{
-  return &peer->ax_key;
-}
-
-
-/**
  * Notify a peer that a link between two other peers is broken. If any path
  * used that link, eliminate it.
  *

Modified: gnunet/src/cadet/gnunet-service-cadet_peer.h
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.h        2015-06-04 11:37:05 UTC 
(rev 35864)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.h        2015-06-04 13:50:02 UTC 
(rev 35865)
@@ -390,35 +390,6 @@
 GCP_try_connect (struct CadetPeer *peer);
 
 /**
- * Check if the given ECDH key is correct for the peer.
- *
- * This function caches the results if the key has been previoulsy checked,
- * otherwise checks that the key is signed with the peer's ID (EdDSA key).
- *
- * TODO: save the cached public key to permanent storage / peerinfo.
- *
- * @param peer Peer whose key to check.
- * @param key ECDH key to check.
- * @param purpose Purpose of the signature (followed by the key).
- * @param sig Signature with the peer's EdDSA key (PeerID).
- */
-int
-GCP_check_key (struct CadetPeer *peer,
-               const struct GNUNET_CRYPTO_EcdhePublicKey *key,
-               const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
-               const struct GNUNET_CRYPTO_EddsaSignature *sig);
-
-/**
- * Get the Identity ECDH key of the peer.
- *
- * @param peer Peer whose key to get.
- *
- * @return Peer's permanent ECDH key (might be all 0: unknown).
- */
-struct GNUNET_CRYPTO_EddsaPublicKey *
-GCP_get_key (struct CadetPeer *peer);
-
-/**
  * Notify a peer that a link between two other peers is broken. If any path
  * used that link, eliminate it.
  *

Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2015-06-04 11:37:05 UTC 
(rev 35864)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2015-06-04 13:50:02 UTC 
(rev 35865)
@@ -252,11 +252,6 @@
   struct GNUNET_CRYPTO_EcdhePrivateKey *kx_0;
 
   /**
-   * ECDH Identity key (recv).
-   */
-  struct GNUNET_CRYPTO_EcdhePublicKey DHIr;
-
-  /**
    * ECDH Ratchet key (send).
    */
   struct GNUNET_CRYPTO_EcdhePrivateKey *DHRs;
@@ -467,28 +462,6 @@
 };
 
 
-/**
- * Cached Axolotl key with signature.
- */
-struct CadetAxolotlSignedKey
-{
-  /**
-   * Information about what is being signed (@a permanent_key).
-   */
-  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
-  /**
-   * Permanent public ECDH key.
-   */
-  struct GNUNET_CRYPTO_EcdhePublicKey permanent_key;
-
-  /**
-   * An EdDSA signature of the permanent ECDH key with the Peer's ID key.
-   */
-  struct GNUNET_CRYPTO_EddsaSignature signature;
-} GNUNET_PACKED;
-
-
 
/******************************************************************************/
 /*******************************   GLOBALS  
***********************************/
 
/******************************************************************************/
@@ -534,14 +507,7 @@
 
 /********************************  AXOLOTL 
************************************/
 
-static struct GNUNET_CRYPTO_EcdhePrivateKey *ax_key;
-
 /**
- * Own Axolotl permanent public key (cache).
- */
-static struct CadetAxolotlSignedKey ax_identity;
-
-/**
  * How many messages are needed to trigger a ratchet advance.
  */
 static unsigned long long ratchet_messages;
@@ -704,19 +670,6 @@
 
 
 /**
- * Ephemeral key message purpose size.
- *
- * @return Size of the part of the ephemeral key message that must be signed.
- */
-static size_t
-ax_purpose_size (void)
-{
-  return sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
-         sizeof (struct GNUNET_CRYPTO_EcdhePublicKey);
-}
-
-
-/**
  * Size of the encrypted part of a ping message.
  *
  * @return Size of the encrypted part of a ping message.
@@ -2887,8 +2840,6 @@
   struct CadetTunnelAxolotl *ax;
   struct GNUNET_HashCode key_material[3];
   struct GNUNET_CRYPTO_SymmetricSessionKey keys[5];
-  const struct GNUNET_CRYPTO_EcdhePublicKey *pub;
-  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv;
   const char salt[] = "CADET Axolotl salt";
   const struct GNUNET_PeerIdentity *pid;
   int am_I_alice;
@@ -2903,13 +2854,6 @@
     return;
   }
 
-  if (GNUNET_OK != GCP_check_key (t->peer, &msg->permanent_key,
-                                  &msg->purpose, &msg->signature))
-  {
-    GNUNET_break_op (0);
-    return;
-  }
-
   pid = GCT_get_destination (t);
   if (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
     am_I_alice = GNUNET_YES;
@@ -2931,38 +2875,43 @@
 
   ax = t->ax;
   ax->DHRr = msg->ratchet_key;
-  ax->DHIr = msg->permanent_key;
 
   /* ECDH A B0 */
   if (GNUNET_YES == am_I_alice)
   {
-    priv = ax_key;                                              /* A */
-    pub = &msg->ephemeral_key;                                  /* B0 */
+    GNUNET_CRYPTO_eddsa_ecdh (id_key,              /* A */
+                              &msg->ephemeral_key,  /* B0 */
+                              &key_material[0]);
   }
   else
   {
-    priv = ax->kx_0;                                            /* B0 */
-    pub = &ax->DHIr;                                            /* A */
+    GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0,            /* B0 */
+                              &pid->public_key,    /* A */
+                              &key_material[0]);
   }
-  GNUNET_CRYPTO_ecc_ecdh (priv, pub, &key_material[0]);
 
   /* ECDH A0 B */
   if (GNUNET_YES == am_I_alice)
   {
-    priv = ax->kx_0;                                            /* A0 */
-    pub = &ax->DHIr;                                            /* B */
+    GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0,            /* A0 */
+                              &pid->public_key,    /* B */
+                              &key_material[1]);
   }
   else
   {
-    priv = ax_key;                                              /* B */
-    pub = &msg->ephemeral_key;                                  /* A0 */
+    GNUNET_CRYPTO_eddsa_ecdh (id_key,              /* A */
+                              &msg->ephemeral_key,  /* B0 */
+                              &key_material[1]);
+
+
   }
-  GNUNET_CRYPTO_ecc_ecdh (priv, pub, &key_material[1]);
 
-  /* ECDH A0 B0*/
-  priv = ax->kx_0;                                              /* A0 or B0 */
-  pub = &msg->ephemeral_key;                                    /* B0 or A0 */
-  GNUNET_CRYPTO_ecc_ecdh (priv, pub, &key_material[2]);
+  /* ECDH A0 B0 */
+  /* (This is the triple-DH, we could probably safely skip this,
+     as A0/B0 are already in the key material.) */
+  GNUNET_CRYPTO_ecc_ecdh (ax->kx_0,             /* A0 or B0 */
+                          &msg->ephemeral_key,  /* B0 or A0 */
+                          &key_material[2]);
 
   #if DUMP_KEYS_TO_STDERR
   {
@@ -3084,7 +3033,7 @@
   size_t payload_size;
   int decrypted_size;
   uint16_t type;
-  struct GNUNET_MessageHeader *msgh;
+  const struct GNUNET_MessageHeader *msgh;
   unsigned int off;
 
   type = ntohs (msg->type);
@@ -3233,16 +3182,6 @@
   otr_kx_msg.purpose.size = htonl (ephemeral_purpose_size ());
   otr_kx_msg.origin_identity = my_full_id;
   rekey_task = GNUNET_SCHEDULER_add_now (&global_otr_rekey, NULL);
-
-  ax_key = GNUNET_CRYPTO_ecdhe_key_create ();
-  GNUNET_CRYPTO_ecdhe_key_get_public (ax_key, &ax_identity.permanent_key);
-  ax_identity.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CADET_AXKX);
-  ax_identity.purpose.size = htonl (ax_purpose_size ());
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CRYPTO_eddsa_sign (id_key,
-                                           &ax_identity.purpose,
-                                           &ax_identity.signature));
-
   tunnels = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES);
 }
 
@@ -3260,7 +3199,6 @@
   }
   GNUNET_CONTAINER_multipeermap_iterate (tunnels, &destroy_iterator, NULL);
   GNUNET_CONTAINER_multipeermap_destroy (tunnels);
-  GNUNET_free (ax_key);
 }
 
 
@@ -4237,9 +4175,6 @@
   msg.header.size = htons (sizeof (msg));
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_AX_KX);
   msg.force_reply = htonl (force_reply);
-  msg.permanent_key = ax_identity.permanent_key;
-  msg.purpose = ax_identity.purpose;
-  msg.signature = ax_identity.signature;
   GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->kx_0, &msg.ephemeral_key);
   GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->DHRs, &msg.ratchet_key);
 
@@ -4402,11 +4337,6 @@
   LOG2 (level, "TTT  CKr\t %s\n",
         GNUNET_h2s ((struct GNUNET_HashCode *) &ax->CKr));
 
-  GNUNET_CRYPTO_ecdhe_key_get_public (ax_key, &pub);
-  LOG2 (level, "TTT  DHIs\t %s\n",
-        GNUNET_h2s ((struct GNUNET_HashCode *) &pub));
-  LOG2 (level, "TTT  DHIr\t %s\n",
-        GNUNET_h2s ((struct GNUNET_HashCode *) &ax->DHIr));
   GNUNET_CRYPTO_ecdhe_key_get_public (ax->DHRs, &pub);
   LOG2 (level, "TTT  DHRs\t %s\n",
         GNUNET_h2s ((struct GNUNET_HashCode *) &pub));

Modified: gnunet/src/include/gnunet_signatures.h
===================================================================
--- gnunet/src/include/gnunet_signatures.h      2015-06-04 11:37:05 UTC (rev 
35864)
+++ gnunet/src/include/gnunet_signatures.h      2015-06-04 13:50:02 UTC (rev 
35865)
@@ -176,12 +176,7 @@
  */
 #define GNUNET_SIGNATURE_PURPOSE_SENSOR_ANOMALY_REPORT 25
 
-/**
- * Axolotl key exchange in CADET
- */
-#define GNUNET_SIGNATURE_PURPOSE_CADET_AXKX 26
 
-
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif




reply via email to

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