add assertion to make static analysis happy
[oweals/gnunet.git] / src / cadet / cadet_protocol.h
index 24145a0081036b00786a32f221b5ebc9300e0882..d2426addbd67cad26531acdea192034093c3f244 100644 (file)
@@ -67,9 +67,12 @@ struct GNUNET_CADET_ConnectionCreateMessage
   struct GNUNET_MessageHeader header;
 
   /**
-   * For alignment.
+   * Connection options in network byte order.
+   * #GNUNET_CADET_OPTION_DEFAULT for buffered;
+   * #GNUNET_CADET_OPTION_NOBUFFER for unbuffered.
+   * Other flags are ignored and should not be set at this level.
    */
-  uint32_t reserved GNUNET_PACKED;
+  uint32_t options GNUNET_PACKED;
 
   /**
    * ID of the connection
@@ -205,7 +208,9 @@ enum GNUNET_CADET_KX_Flags {
 struct GNUNET_CADET_TunnelKeyExchangeMessage
 {
   /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX.
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX or
+   * #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH as part
+   * of `struct GNUNET_CADET_TunnelKeyExchangeAuthMessage`.
    */
   struct GNUNET_MessageHeader header;
 
@@ -234,17 +239,57 @@ struct GNUNET_CADET_TunnelKeyExchangeMessage
    */
   struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
 
-#ifdef NEW_CADET
+};
+
+
+/**
+ * Message for a Key eXchange for a tunnel, with authentication.
+ * Used as a response to the initial KX as well as for rekeying.
+ */
+struct GNUNET_CADET_TunnelKeyExchangeAuthMessage
+{
+
   /**
-   * Proof that sender could compute the 3-DH, in lieu of a signature.
+   * Message header with key material.
    */
-  struct GNUNET_HashCode triple_dh_proof;
-#endif
+  struct GNUNET_CADET_TunnelKeyExchangeMessage kx;
+
+  /**
+   * KDF-proof that sender could compute the 3-DH, used in lieu of a
+   * signature or payload data.
+   */
+  struct GNUNET_HashCode auth;
+
+};
+
+
+/**
+ * Encrypted axolotl header with numbers that identify which
+ * keys in which ratchet are to be used to decrypt the body.
+ */
+struct GNUNET_CADET_AxHeader
+{
+
+  /**
+   * Number of messages sent with the current ratchet key.
+   */
+  uint32_t Ns GNUNET_PACKED;
+
+  /**
+   * Number of messages sent with the previous ratchet key.
+   */
+  uint32_t PNs GNUNET_PACKED;
+
+  /**
+   * Current ratchet key.
+   */
+  struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
+
 };
 
 
 /**
- * Axolotl tunnel message.
+ * Axolotl-encrypted tunnel message with application payload.
  */
 struct GNUNET_CADET_TunnelEncryptedMessage
 {
@@ -277,8 +322,13 @@ struct GNUNET_CADET_TunnelEncryptedMessage
    */
   struct GNUNET_ShortHashCode hmac;
 
-  /**************** AX_HEADER start ****************/
-
+  #if NEW_CADET
+  /**
+   * Axolotl-header that specifies which keys to use in which ratchet
+   * to decrypt the body that follows.
+   */
+  struct GNUNET_CADET_AxHeader ax_header;
+#else
   /**
    * Number of messages sent with the current ratchet key.
    */
@@ -293,9 +343,7 @@ struct GNUNET_CADET_TunnelEncryptedMessage
    * Current ratchet key.
    */
   struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
-
-  /**************** AX_HEADER  end  ****************/
-
+#endif
   /**
    * Encrypted content follows.
    */
@@ -390,12 +438,14 @@ struct GNUNET_CADET_ChannelOpenMessage
 
 
 /**
- * Message to manage a Channel (CHANNEL_CREATE_ACK, CHANNEL_DESTROY).
+ * Message to manage a Channel
+ * (#GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK,
+ * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY).
  */
 struct GNUNET_CADET_ChannelManageMessage
 {
   /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE_ACK or
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK or
    * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY
    */
   struct GNUNET_MessageHeader header;
@@ -460,7 +510,7 @@ struct GNUNET_CADET_ChannelDataAckMessage
   struct GNUNET_CADET_ChannelTunnelNumber ctn;
 
   /**
-   * Bitfield of already-received newer messages
+   * Bitfield of already-received messages past @e mid.
    * pid +  1 @ LSB
    * pid + 64 @ MSB
    */
@@ -530,14 +580,16 @@ struct GNUNET_CADET_ChannelDataAckMessage
   struct GNUNET_CADET_ChannelTunnelNumber ctn;
 
   /**
-   * Bitfield of already-received messages past @e mid.
-   * pid +  1 @ LSB
-   * pid + 64 @ MSB
+   * Bitfield of already-received newer messages.  Note that bit 0
+   * corresponds to @e mid + 1.
+   *
+   * pid +  0 @ LSB
+   * pid + 63 @ MSB
    */
   uint64_t futures GNUNET_PACKED;
 
   /**
-   * Last message ID received.
+   * Next message ID expected.
    */
   struct ChannelMessageIdentifier mid;
 };