- fix coverity
[oweals/gnunet.git] / src / cadet / cadet_protocol.h
index 19cdfe4a0167e0e2acf0651d602d92f6a32e223e..dbb4f604fc64e16fca44e4525fc081af8ab0018d 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (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)
@@ -72,13 +72,14 @@ struct GNUNET_CADET_ConnectionCreate
   /* struct GNUNET_PeerIdentity peers[path_length]; */
 };
 
+
 /**
  * Message for ack'ing a connection
  */
 struct GNUNET_CADET_ConnectionACK
 {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK
+     * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK
      */
   struct GNUNET_MessageHeader header;
 
@@ -96,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;
 
@@ -109,6 +110,55 @@ 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.
+ */
+struct GNUNET_CADET_AX_KX
+{
+  /**
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_AX_KX.
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * 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 encoded in a
+   * format suitable for network transmission, as created
+   * using 'gcry_sexp_sprint'.
+   */
+  struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
+};
+
+
 /**
  * Message transmitted with the signed ephemeral key of a peer.  The
  * session key is then derived from the two ephemeral keys (ECDHE).
@@ -150,43 +200,24 @@ struct GNUNET_CADET_KX_Ephemeral
   struct GNUNET_TIME_AbsoluteNBO expiration_time;
 
   /**
-   * Ephemeral public ECC key (always for NIST P-521) encoded in a format suitable
-   * for network transmission as created using 'gcry_sexp_sprint'.
+   * Ephemeral public ECC key (always for NIST P-521) encoded in a format
+   * suitable for network transmission as created using 'gcry_sexp_sprint'.
    */
   struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
 
   /**
-   * Public key of the signing peer (persistent version, not the ephemeral public key).
+   * Public key of the signing peer
+   * (persistent version, not the ephemeral public key).
    */
   struct GNUNET_PeerIdentity origin_identity;
-};
 
-
-/**
- * We're sending an (encrypted) PING to the other peer to check if he
- * can decrypt.  The other peer should respond with a PONG with the
- * same content, except this time encrypted with the receiver's key.
- */
-struct GNUNET_CADET_KX_Ping
-{
   /**
-   * Message type is GNUNET_MESSAGE_TYPE_CADET_KX_PING.
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * Seed for the IV
+   * Seed for the IV of nonce.
    */
   uint32_t iv GNUNET_PACKED;
 
   /**
-   * Intended target of the PING, used primarily to check
-   * that decryption actually worked.
-   */
-  struct GNUNET_PeerIdentity target;
-
-  /**
-   * Random number chosen to make reply harder.
+   * Nonce to check liveness of peer.
    */
   uint32_t nonce GNUNET_PACKED;
 };
@@ -256,6 +287,63 @@ struct GNUNET_CADET_Encrypted
 };
 
 
+/**
+ * Axolotl tunnel message.
+ */
+struct GNUNET_CADET_AX
+{
+  /**
+   * Type: GNUNET_MESSAGE_TYPE_CADET_AXOLOTL_DATA
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * ID of the connection.
+   */
+  struct GNUNET_CADET_Hash cid;
+
+  /**
+   * ID of the packet (hop by hop).
+   */
+  uint32_t pid GNUNET_PACKED;
+
+  /**
+   * Reserved field for 64b alignment.
+   */
+  uint32_t reserved GNUNET_PACKED;
+
+  /**
+   * MAC of the encrypted message, used to verify message integrity.
+   * Everything after this value  will be encrypted with the header key
+   * and authenticated.
+   */
+  struct GNUNET_CADET_Hash hmac;
+
+  /**************** AX_HEADER start ****************/
+
+  /**
+   * Number of messages sent with the current ratchet key.
+   */
+  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.
+   */
+};
+
+
 /**
  * Message to create a Channel.
  */