2 This file is part of GNUnet.
3 Copyright (C) 2001 - 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @author Bartlomiej Polot
23 * @file cadet/cadet_protocol.h
26 #ifndef CADET_PROTOCOL_H_
27 #define CADET_PROTOCOL_H_
30 #include "gnunet_util_lib.h"
35 struct GNUNET_CADET_TunnelMessage;
39 /* keep Emacsens' auto-indent happy */
44 /******************************************************************************/
45 /******************** CADET NETWORK MESSAGES **************************/
46 /******************************************************************************/
48 GNUNET_NETWORK_STRUCT_BEGIN
51 * Message for cadet connection creation.
53 struct GNUNET_CADET_ConnectionCreate
56 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
58 * Size: sizeof (struct GNUNET_CADET_ConnectionCreate) +
59 * path_length * sizeof (struct GNUNET_PeerIdentity)
61 struct GNUNET_MessageHeader header;
64 * ID of the connection
66 struct GNUNET_CADET_Hash cid;
69 * path_length structs defining the *whole* path from the origin [0] to the
70 * final destination [path_length-1].
72 /* struct GNUNET_PeerIdentity peers[path_length]; */
77 * Message for ack'ing a connection
79 struct GNUNET_CADET_ConnectionACK
82 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK
84 struct GNUNET_MessageHeader header;
87 * ID of the connection.
89 struct GNUNET_CADET_Hash cid;
95 * Message for encapsulation of a Key eXchange message in a connection.
97 struct GNUNET_CADET_KX
100 * Type: #GNUNET_MESSAGE_TYPE_CADET_KX.
102 struct GNUNET_MessageHeader header;
105 * ID of the connection.
107 struct GNUNET_CADET_Hash cid;
109 /* Specific KX message follows. */
114 * Flags to be used in GNUNET_CADET_AX_KX.
116 enum GNUNET_CADET_AX_KX_Flags {
119 * Should the peer reply with its KX details?
121 GNUNET_CADET_AX_KX_FLAG_NONE = 0,
124 * The peer should reply with its KX details?
126 GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY = 1
131 * Message for encapsulation of a Key eXchange message in a connection.
133 struct GNUNET_CADET_AX_KX
136 * Type: #GNUNET_MESSAGE_TYPE_CADET_AX_KX.
138 struct GNUNET_MessageHeader header;
141 * Flags for the key exchange in NBO, based on
142 * `enum GNUNET_CADET_AX_KX_Flags`.
144 uint32_t flags GNUNET_PACKED;
147 * Sender's ephemeral public ECC key encoded in a
148 * format suitable for network transmission, as created
149 * using 'gcry_sexp_sprint'.
151 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
154 * Sender's next ephemeral public ECC key encoded in a
155 * format suitable for network transmission, as created
156 * using 'gcry_sexp_sprint'.
158 struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
163 * Message transmitted with the signed ephemeral key of a peer. The
164 * session key is then derived from the two ephemeral keys (ECDHE).
166 * As far as possible, same as CORE's EphemeralKeyMessage.
168 struct GNUNET_CADET_KX_Ephemeral
172 * Message type is GNUNET_MESSAGE_TYPE_CADET_KX_EPHEMERAL.
174 struct GNUNET_MessageHeader header;
177 * Status of the sender (should be in "enum PeerStateMachine"), nbo.
179 int32_t sender_status GNUNET_PACKED;
182 * An ECC signature of the 'origin' asserting the validity of
183 * the given ephemeral key.
185 struct GNUNET_CRYPTO_EddsaSignature signature;
188 * Information about what is being signed.
190 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
193 * At what time was this key created (beginning of validity).
195 struct GNUNET_TIME_AbsoluteNBO creation_time;
198 * When does the given ephemeral key expire (end of validity).
200 struct GNUNET_TIME_AbsoluteNBO expiration_time;
203 * Ephemeral public ECC key (always for NIST P-521) encoded in a format
204 * suitable for network transmission as created using 'gcry_sexp_sprint'.
206 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
209 * Public key of the signing peer
210 * (persistent version, not the ephemeral public key).
212 struct GNUNET_PeerIdentity origin_identity;
215 * Seed for the IV of nonce.
217 uint32_t iv GNUNET_PACKED;
220 * Nonce to check liveness of peer.
222 uint32_t nonce GNUNET_PACKED;
227 * Response to a PING. Includes data from the original PING.
229 struct GNUNET_CADET_KX_Pong
232 * Message type is GNUNET_MESSAGE_TYPE_CADET_KX_PONG.
234 struct GNUNET_MessageHeader header;
239 uint32_t iv GNUNET_PACKED;
242 * Same nonce as in the reve.
244 uint32_t nonce GNUNET_PACKED;
249 * Tunnel(ed) message.
251 struct GNUNET_CADET_Encrypted
254 * Type: GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED
256 struct GNUNET_MessageHeader header;
259 * ID of the connection.
261 struct GNUNET_CADET_Hash cid;
264 * ID of the packet (hop by hop).
266 uint32_t pid GNUNET_PACKED;
269 * Number of hops to live.
271 uint32_t ttl GNUNET_PACKED;
274 * Initialization Vector for payload encryption.
276 uint32_t iv GNUNET_PACKED;
279 * MAC of the encrypted message, used to verify message integrity.
280 * Everything after this value will be encrypted and authenticated.
282 struct GNUNET_CADET_Hash hmac;
285 * Encrypted content follows.
291 * Axolotl tunnel message.
293 struct GNUNET_CADET_AX
296 * Type: GNUNET_MESSAGE_TYPE_CADET_AXOLOTL_DATA
298 struct GNUNET_MessageHeader header;
301 * ID of the connection.
303 struct GNUNET_CADET_Hash cid;
306 * ID of the packet (hop by hop).
308 uint32_t pid GNUNET_PACKED;
311 * Reserved field for 64b alignment.
313 uint32_t reserved GNUNET_PACKED;
316 * MAC of the encrypted message, used to verify message integrity.
317 * Everything after this value will be encrypted with the header key
320 struct GNUNET_CADET_Hash hmac;
323 * Number of messages sent with the current ratchet key.
328 * Number of messages sent with the previous ratchet key.
333 * Current ratchet key.
335 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
338 * Encrypted content follows.
344 * Message to create a Channel.
346 struct GNUNET_CADET_ChannelCreate
349 * Type: GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE
351 struct GNUNET_MessageHeader header;
356 CADET_ChannelNumber chid GNUNET_PACKED;
361 uint32_t port GNUNET_PACKED;
366 uint32_t opt GNUNET_PACKED;
371 * Message to manage a Channel (ACK, NACK, Destroy).
373 struct GNUNET_CADET_ChannelManage
376 * Type: GNUNET_MESSAGE_TYPE_CADET_CHANNEL_{ACK|NACK|DESTROY}
378 struct GNUNET_MessageHeader header;
383 CADET_ChannelNumber chid GNUNET_PACKED;
388 * Message for cadet data traffic.
390 struct GNUNET_CADET_Data
393 * Type: GNUNET_MESSAGE_TYPE_CADET_UNICAST,
394 * GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
396 struct GNUNET_MessageHeader header;
399 * Unique ID of the payload message
401 uint32_t mid GNUNET_PACKED;
406 CADET_ChannelNumber chid GNUNET_PACKED;
415 * Message to acknowledge end-to-end data.
417 struct GNUNET_CADET_DataACK
420 * Type: GNUNET_MESSAGE_TYPE_CADET_DATA_ACK
422 struct GNUNET_MessageHeader header;
427 CADET_ChannelNumber chid GNUNET_PACKED;
430 * Bitfield of already-received newer messages
434 uint64_t futures GNUNET_PACKED;
437 * Last message ID received.
439 uint32_t mid GNUNET_PACKED;
444 * Message to acknowledge cadet encrypted traffic.
446 struct GNUNET_CADET_ACK
449 * Type: GNUNET_MESSAGE_TYPE_CADET_ACK
451 struct GNUNET_MessageHeader header;
454 * Maximum packet ID authorized.
456 uint32_t ack GNUNET_PACKED;
459 * ID of the connection.
461 struct GNUNET_CADET_Hash cid;
466 * Message to query a peer about its Flow Control status regarding a tunnel.
468 struct GNUNET_CADET_Poll
471 * Type: GNUNET_MESSAGE_TYPE_CADET_POLL
473 struct GNUNET_MessageHeader header;
478 uint32_t pid GNUNET_PACKED;
481 * ID of the connection.
483 struct GNUNET_CADET_Hash cid;
489 * Message for notifying a disconnection in a path
491 struct GNUNET_CADET_ConnectionBroken
494 * Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
496 struct GNUNET_MessageHeader header;
499 * ID of the connection.
501 struct GNUNET_CADET_Hash cid;
506 struct GNUNET_PeerIdentity peer1;
511 struct GNUNET_PeerIdentity peer2;
516 * Message to destroy a connection.
518 struct GNUNET_CADET_ConnectionDestroy
521 * Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
523 struct GNUNET_MessageHeader header;
526 * ID of the connection.
528 struct GNUNET_CADET_Hash cid;
532 GNUNET_NETWORK_STRUCT_END
534 #if 0 /* keep Emacsens' auto-indent happy */
541 /* ifndef CADET_PROTOCOL_H */
543 /* end of cadet_protocol.h */