more on backchannel logic
authorChristian Grothoff <christian@grothoff.org>
Fri, 25 Jan 2019 21:25:48 +0000 (22:25 +0100)
committerChristian Grothoff <christian@grothoff.org>
Fri, 25 Jan 2019 21:25:48 +0000 (22:25 +0100)
src/include/gnunet_protocols.h
src/transport/gnunet-service-tng.c
src/transport/transport.h
src/transport/transport_api2_communication.c

index a8d716b3f40004ee2a3108a542ee1de12d95fac6..7ef8dca8e57df1cac7e0eba408a754f0342520fe 100644 (file)
@@ -3125,9 +3125,10 @@ extern "C"
 #define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX 1219
 
 /**
- * Transport affirming receipt of an ephemeral key.
+ * Transport signalling incoming backchannel message to a communicator.
  */ 
-#define GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION 1220
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING 1220
+
 
 /**
  * Message sent to indicate to the transport that a monitor
index b55cd2485554462eac525c26720c5a6f56fd2107..cb6fcebdc043e8dd889bfbb228aacbb888ba5d25 100644 (file)
@@ -34,6 +34,7 @@
  *
  * Implement:
  * - manage defragmentation, retransmission, track RTT, loss, etc.
+ * - DV data structures, learning, forgetting, using them!
  *
  * Easy:
  * - use ATS bandwidth allocation callback and schedule transmissions!
@@ -153,6 +154,9 @@ struct TransportBackchannelEncapsulationMessage
    */
   struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
 
+  // FIXME: probably should add random IV here as well,
+  // especially if we re-use ephemeral keys!
+  
   /**
    * HMAC over the ciphertext of the encrypted, variable-size
    * body that follows.  Verified via DH of @e target and
@@ -177,8 +181,7 @@ struct EphemeralConfirmation
   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
 
   /**
-   * How long is this signature over the ephemeral key
-   * valid?
+   * How long is this signature over the ephemeral key valid?
    */
   struct GNUNET_TIME_AbsoluteNBO ephemeral_validity;
 
@@ -191,37 +194,6 @@ struct EphemeralConfirmation
 };
 
 
-/**
- * Message by which a peqer confirms that it is using an ephemeral
- * key.
- */
-struct EphemeralConfirmationMessage
-{
-
-  /**
-   * Message header, type is #GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * Must be zero.
-   */  
-  uint32_t reserved;
-  
-  /**
-   * How long is this signature over the ephemeral key
-   * valid?
-   */
-  struct GNUNET_TIME_AbsoluteNBO ephemeral_validity;
-
-  /**
-   * Ephemeral key setup by the sender for @e target, used
-   * to encrypt the payload.
-   */
-  struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
-};
-
-
 /**
  * Plaintext of the variable-size payload that is encrypted
  * within a `struct TransportBackchannelEncapsulationMessage`
@@ -546,6 +518,10 @@ enum ClientType
 
 /**
  * Entry in our cache of ephemeral keys we currently use.
+ * This way, we only sign an ephemeral once per @e target,
+ * and then can re-use it over multiple 
+ * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION
+ * messages (as signing is expensive).
  */
 struct EphemeralCacheEntry
 {
@@ -2525,31 +2501,7 @@ handle_backchannel_encapsulation (void *cls,
   // FIXME: check HMAC
   // FIXME: decrypt payload
   // FIXME: forward to specified communicator!
-  
-  finish_cmc_handling (cmc);
-}
-
-
-/**
- * Communicator gave us an ephemeral confirmation.  Process the request.
- *
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
- * @param ec the message that was received
- */
-static void
-handle_ephemeral_confirmation (void *cls,
-                              const struct EphemeralConfirmationMessage *ec)
-{
-  struct CommunicatorMessageContext *cmc = cls;
-
-  // FIXME: notify communicator (?) about ephemeral confirmation!?
-  // FIXME: or does this have something to do with the ephemeral_map?
-  //        where did I plan to use this message again!?
-  // FIXME: communicator API has a very general notification API,
-  //        nothing specific for ephemeral keys;
-  //        why do we have a ephemeral key-specific message here?
-  // => first revise where we get such messages from communicator
-  //    before processing further here!
+  // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING)  
   finish_cmc_handling (cmc);
 }
 
@@ -2726,10 +2678,6 @@ handle_incoming_msg (void *cls,
                           GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION,
                           struct TransportBackchannelEncapsulationMessage,
                           &cmc),
-    GNUNET_MQ_hd_fixed_size (ephemeral_confirmation,
-                            GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION,
-                            struct EphemeralConfirmationMessage,
-                            &cmc),
     GNUNET_MQ_hd_var_size (dv_learn,
                           GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN,
                           struct TransportDVLearn,
index 24479e4c627e21ad5ad8e8b9e203062d0c78ea38..931ba4810d502f2d49e54d47eafd3965e3a414ed 100644 (file)
@@ -977,6 +977,33 @@ struct GNUNET_TRANSPORT_CommunicatorBackchannel
 };
 
 
+/**
+ * Message from transport to communicator passing along a backchannel
+ * message from the given peer @e pid.
+ */
+struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
+{
+  /**
+   * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Always zero, for alignment.
+   */
+  uint32_t reserved;
+
+  /**
+   * Origin peer.
+   */
+  struct GNUNET_PeerIdentity pid;
+
+  /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
+     message to the communicator */
+
+};
+
+
 
 /**
  * Request to start monitoring.
index a816ecb6795d0a379c879e6e7f46de16be191c24..ee1c788e54afb0775adb972cb09a7a62730d3ef4 100644 (file)
@@ -22,6 +22,8 @@
  * @file transport/transport_api2_communication.c
  * @brief implementation of the gnunet_transport_communication_service.h API
  * @author Christian Grothoff
+ *
+ * FIXME: handling of messages for "notify_cb" not implemented!
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
@@ -618,15 +620,8 @@ static int
 check_send_msg (void *cls,
                const struct GNUNET_TRANSPORT_SendMessageTo *smt)
 {
-  uint16_t len = ntohs (smt->header.size) - sizeof (*smt);
-  const struct GNUNET_MessageHeader *mh = (const struct GNUNET_MessageHeader *) &smt[1];
-
   (void) cls;
-  if (ntohs (mh->size) != len)
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_boxed_message (smt);
   return GNUNET_OK;
 }
 
@@ -732,6 +727,40 @@ handle_send_msg (void *cls,
 }
 
 
+/**
+ * Transport service gives us backchannel message. Check if @a bi
+ * is well-formed.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *`
+ * @param bi the backchannel message
+ * @return #GNUNET_OK if @a smt is well-formed
+ */
+static int
+check_backchannel_incoming (void *cls,
+                           const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
+{
+  (void) cls;
+  GNUNET_MQ_check_boxed_message (bi);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Transport service gives us backchannel message. Handle it.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *`
+ * @param bi the backchannel message
+ */
+static void
+handle_backchannel_incoming (void *cls,
+                            const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
+{
+  struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
+
+  // FIXME: handle bi!
+}
+
+
 /**
  * (re)connect our communicator to the transport service
  *
@@ -753,7 +782,10 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
                           GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG,
                           struct GNUNET_TRANSPORT_SendMessageTo,
                           ch),
-    // FIXME: handle backchannel notifications!
+    GNUNET_MQ_hd_var_size (backchannel_incoming,
+                          GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING,
+                          struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming,
+                          ch),
     GNUNET_MQ_handler_end()
   };
   struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam;