2 This file is part of GNUnet.
3 Copyright (C) 2001 - 2011 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, 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;
322 /**************** AX_HEADER start ****************/
325 * Number of messages sent with the current ratchet key.
330 * Number of messages sent with the previous ratchet key.
335 * Current ratchet key.
337 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
339 /**************** AX_HEADER end ****************/
342 * Encrypted content follows.
348 * Message to create a Channel.
350 struct GNUNET_CADET_ChannelCreate
353 * Type: GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE
355 struct GNUNET_MessageHeader header;
360 CADET_ChannelNumber chid GNUNET_PACKED;
365 uint32_t port GNUNET_PACKED;
370 uint32_t opt GNUNET_PACKED;
375 * Message to manage a Channel (ACK, NACK, Destroy).
377 struct GNUNET_CADET_ChannelManage
380 * Type: GNUNET_MESSAGE_TYPE_CADET_CHANNEL_{ACK|NACK|DESTROY}
382 struct GNUNET_MessageHeader header;
387 CADET_ChannelNumber chid GNUNET_PACKED;
392 * Message for cadet data traffic.
394 struct GNUNET_CADET_Data
397 * Type: GNUNET_MESSAGE_TYPE_CADET_UNICAST,
398 * GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
400 struct GNUNET_MessageHeader header;
403 * Unique ID of the payload message
405 uint32_t mid GNUNET_PACKED;
410 CADET_ChannelNumber chid GNUNET_PACKED;
419 * Message to acknowledge end-to-end data.
421 struct GNUNET_CADET_DataACK
424 * Type: GNUNET_MESSAGE_TYPE_CADET_DATA_ACK
426 struct GNUNET_MessageHeader header;
431 CADET_ChannelNumber chid GNUNET_PACKED;
434 * Bitfield of already-received newer messages
438 uint64_t futures GNUNET_PACKED;
441 * Last message ID received.
443 uint32_t mid GNUNET_PACKED;
448 * Message to acknowledge cadet encrypted traffic.
450 struct GNUNET_CADET_ACK
453 * Type: GNUNET_MESSAGE_TYPE_CADET_ACK
455 struct GNUNET_MessageHeader header;
458 * Maximum packet ID authorized.
460 uint32_t ack GNUNET_PACKED;
463 * ID of the connection.
465 struct GNUNET_CADET_Hash cid;
470 * Message to query a peer about its Flow Control status regarding a tunnel.
472 struct GNUNET_CADET_Poll
475 * Type: GNUNET_MESSAGE_TYPE_CADET_POLL
477 struct GNUNET_MessageHeader header;
482 uint32_t pid GNUNET_PACKED;
485 * ID of the connection.
487 struct GNUNET_CADET_Hash cid;
493 * Message for notifying a disconnection in a path
495 struct GNUNET_CADET_ConnectionBroken
498 * Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
500 struct GNUNET_MessageHeader header;
503 * ID of the connection.
505 struct GNUNET_CADET_Hash cid;
510 struct GNUNET_PeerIdentity peer1;
515 struct GNUNET_PeerIdentity peer2;
520 * Message to destroy a connection.
522 struct GNUNET_CADET_ConnectionDestroy
525 * Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
527 struct GNUNET_MessageHeader header;
530 * ID of the connection.
532 struct GNUNET_CADET_Hash cid;
536 GNUNET_NETWORK_STRUCT_END
538 #if 0 /* keep Emacsens' auto-indent happy */
545 /* ifndef CADET_PROTOCOL_H */
547 /* end of cadet_protocol.h */