- fix coverity
[oweals/gnunet.git] / src / cadet / cadet_protocol.h
index d866e20d32f7fa91fb9a9565b7fe0de6cc4d0f60..dbb4f604fc64e16fca44e4525fc081af8ab0018d 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2001 - 2011 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2001 - 2011 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 /**
@@ -53,7 +53,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
 struct GNUNET_CADET_ConnectionCreate
 {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
+     * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
      *
      * Size: sizeof (struct GNUNET_CADET_ConnectionCreate) +
      *       path_length * sizeof (struct GNUNET_PeerIdentity)
@@ -79,7 +79,7 @@ struct GNUNET_CADET_ConnectionCreate
 struct GNUNET_CADET_ConnectionACK
 {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK
+     * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK
      */
   struct GNUNET_MessageHeader header;
 
@@ -97,7 +97,7 @@ struct GNUNET_CADET_ConnectionACK
 struct GNUNET_CADET_KX
 {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_CADET_KX.
+     * Type: #GNUNET_MESSAGE_TYPE_CADET_KX.
      */
   struct GNUNET_MessageHeader header;
 
@@ -110,6 +110,22 @@ struct GNUNET_CADET_KX
 };
 
 
+/**
+ * Flags to be used in GNUNET_CADET_AX_KX.
+ */
+enum GNUNET_CADET_AX_KX_Flags {
+
+  /**
+   * Should the peer reply with its KX details?
+   */
+  GNUNET_CADET_AX_KX_FLAG_NONE = 0,
+
+  /**
+   * The peer should reply with its KX details?
+   */
+  GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY = 1
+};
+
 
 /**
  * Message for encapsulation of a Key eXchange message in a connection.
@@ -117,19 +133,25 @@ struct GNUNET_CADET_KX
 struct GNUNET_CADET_AX_KX
 {
   /**
-   * Type: GNUNET_MESSAGE_TYPE_CADET_AX_KX.
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_AX_KX.
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * Sender's ephemeral public ECC key (always for NIST P-521) encoded in a
+   * Flags for the key exchange in NBO, based on
+   * `enum GNUNET_CADET_AX_KX_Flags`.
+   */
+  uint32_t flags GNUNET_PACKED;
+
+  /**
+   * Sender's ephemeral public ECC key encoded in a
    * format suitable for network transmission, as created
    * using 'gcry_sexp_sprint'.
    */
   struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
 
   /**
-   * Sender's next ephemeral public ECC key (always for NIST P-521) encoded in a
+   * Sender's next ephemeral public ECC key encoded in a
    * format suitable for network transmission, as created
    * using 'gcry_sexp_sprint'.
    */
@@ -286,20 +308,35 @@ struct GNUNET_CADET_AX
   uint32_t pid GNUNET_PACKED;
 
   /**
-   * Number of hops to live.
+   * Reserved field for 64b alignment.
    */
-  uint32_t ttl GNUNET_PACKED;
+  uint32_t reserved GNUNET_PACKED;
 
   /**
-   * Initialization Vector for payload encryption.
+   * MAC of the encrypted message, used to verify message integrity.
+   * Everything after this value  will be encrypted with the header key
+   * and authenticated.
    */
-  uint32_t iv GNUNET_PACKED;
+  struct GNUNET_CADET_Hash hmac;
+
+  /**************** AX_HEADER start ****************/
 
   /**
-   * MAC of the encrypted message, used to verify message integrity.
-   * Everything after this value  will be encrypted and authenticated.
+   * Number of messages sent with the current ratchet key.
    */
-  struct GNUNET_CADET_Hash hmac;
+  uint32_t Ns;
+
+  /**
+   * Number of messages sent with the previous ratchet key.
+   */
+  uint32_t PNs;
+
+  /**
+   * Current ratchet key.
+   */
+  struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
+
+  /**************** AX_HEADER  end  ****************/
 
   /**
    * Encrypted content follows.