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 /******************************************************************************/
52 /***************************** CONNECTION **********************************/
53 /******************************************************************************/
57 * Message for cadet connection creation.
59 struct GNUNET_CADET_ConnectionCreateMessage
62 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
64 * Size: sizeof (struct GNUNET_CADET_ConnectionCreateMessage) +
65 * path_length * sizeof (struct GNUNET_PeerIdentity)
67 struct GNUNET_MessageHeader header;
72 uint32_t reserved GNUNET_PACKED;
75 * ID of the connection
77 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
80 * path_length structs defining the *whole* path from the origin [0] to the
81 * final destination [path_length-1].
83 /* struct GNUNET_PeerIdentity peers[path_length]; */
88 * Message for ack'ing a connection
90 struct GNUNET_CADET_ConnectionCreateAckMessage
93 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK
95 struct GNUNET_MessageHeader header;
100 uint32_t reserved GNUNET_PACKED;
103 * ID of the connection.
105 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
111 * Message for notifying a disconnection in a path
113 struct GNUNET_CADET_ConnectionBrokenMessage
116 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.
118 struct GNUNET_MessageHeader header;
123 uint32_t reserved GNUNET_PACKED;
126 * ID of the connection.
128 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
133 struct GNUNET_PeerIdentity peer1;
138 struct GNUNET_PeerIdentity peer2;
143 * Message to destroy a connection.
145 struct GNUNET_CADET_ConnectionDestroyMessage
148 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
150 struct GNUNET_MessageHeader header;
155 uint32_t reserved GNUNET_PACKED;
158 * ID of the connection.
160 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
164 /******************************************************************************/
165 /******************************* TUNNEL ***********************************/
166 /******************************************************************************/
169 * Unique identifier (counter) for an encrypted message in a channel.
170 * Used to match #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
171 * and #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL messages
172 * against the respective #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
175 struct CadetEncryptedMessageIdentifier
178 * This number is incremented by one per message. It may wrap around.
179 * In network byte order.
181 uint32_t pid GNUNET_PACKED;
186 * Flags to be used in GNUNET_CADET_KX.
188 enum GNUNET_CADET_KX_Flags {
191 * Should the peer reply with its KX details?
193 GNUNET_CADET_KX_FLAG_NONE = 0,
196 * The peer should reply with its KX details?
198 GNUNET_CADET_KX_FLAG_FORCE_REPLY = 1
203 * Message for a Key eXchange for a tunnel.
205 struct GNUNET_CADET_TunnelKeyExchangeMessage
208 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX or
209 * #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH as part
210 * of `struct GNUNET_CADET_TunnelKeyExchangeAuthMessage`.
212 struct GNUNET_MessageHeader header;
215 * Flags for the key exchange in NBO, based on
216 * `enum GNUNET_CADET_KX_Flags`.
218 uint32_t flags GNUNET_PACKED;
221 * ID of the connection.
223 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
226 * Sender's ephemeral public ECC key encoded in a
227 * format suitable for network transmission, as created
228 * using 'gcry_sexp_sprint'.
230 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
233 * Sender's next ephemeral public ECC key encoded in a
234 * format suitable for network transmission, as created
235 * using 'gcry_sexp_sprint'.
237 struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
243 * Message for a Key eXchange for a tunnel, with authentication.
244 * Used as a response to the initial KX as well as for rekeying.
246 struct GNUNET_CADET_TunnelKeyExchangeAuthMessage
250 * Message header with key material.
252 struct GNUNET_CADET_TunnelKeyExchangeMessage kx;
255 * KDF-proof that sender could compute the 3-DH, used in lieu of a
256 * signature or payload data.
258 struct GNUNET_HashCode auth;
264 * Encrypted axolotl header with numbers that identify which
265 * keys in which ratchet are to be used to decrypt the body.
267 struct GNUNET_CADET_AxHeader
271 * Number of messages sent with the current ratchet key.
273 uint32_t Ns GNUNET_PACKED;
276 * Number of messages sent with the previous ratchet key.
278 uint32_t PNs GNUNET_PACKED;
281 * Current ratchet key.
283 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
289 * Axolotl-encrypted tunnel message with application payload.
291 struct GNUNET_CADET_TunnelEncryptedMessage
294 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
296 struct GNUNET_MessageHeader header;
300 * Reserved, for alignment.
302 uint32_t reserved GNUNET_PACKED;
305 * Maximum packet ID authorized.
307 struct CadetEncryptedMessageIdentifier cemi;
311 * ID of the connection.
313 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
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_ShortHashCode hmac;
324 * Axolotl-header that specifies which keys to use in which ratchet
325 * to decrypt the body that follows.
327 struct GNUNET_CADET_AxHeader ax_header;
330 * Number of messages sent with the current ratchet key.
332 uint32_t Ns GNUNET_PACKED;
335 * Number of messages sent with the previous ratchet key.
337 uint32_t PNs GNUNET_PACKED;
340 * Current ratchet key.
342 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
345 * Encrypted content follows.
353 * Message to query a peer about its Flow Control status regarding a tunnel.
355 * It is NOT yet clear if we need this.
357 struct GNUNET_CADET_ConnectionHopByHopPollMessage
360 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL
362 struct GNUNET_MessageHeader header;
367 struct CadetEncryptedMessageIdentifier cemi;
370 * ID of the connection.
372 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
378 * Message to acknowledge cadet encrypted traffic, used for
379 * flow-control on a hop-by-hop basis on the connection-level. Note
380 * that we do use the @e cemi from the tunnel layer as the connection
381 * layer's header is included/shared with the tunnel layer messages,
382 * and we only do flow control for the payload.
384 struct GNUNET_CADET_ConnectionEncryptedAckMessage
387 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
389 struct GNUNET_MessageHeader header;
392 * Maximum packet ID authorized.
394 struct CadetEncryptedMessageIdentifier cemi_max;
397 * ID of the connection.
399 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
405 /******************************************************************************/
406 /******************************* CHANNEL ***********************************/
407 /******************************************************************************/
411 * Message to create a Channel.
413 struct GNUNET_CADET_ChannelOpenMessage
416 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN
418 struct GNUNET_MessageHeader header;
423 uint32_t opt GNUNET_PACKED;
428 struct GNUNET_HashCode port;
431 * ID of the channel within the tunnel.
433 struct GNUNET_CADET_ChannelTunnelNumber ctn;
438 * Message to manage a Channel
439 * (#GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK,
440 * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY).
442 struct GNUNET_CADET_ChannelManageMessage
445 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK or
446 * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY
448 struct GNUNET_MessageHeader header;
454 uint32_t reserved GNUNET_PACKED;
460 struct GNUNET_CADET_ChannelTunnelNumber ctn;
467 * Message for cadet data traffic.
469 struct GNUNET_CADET_ChannelAppDataMessage
472 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
473 * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
475 struct GNUNET_MessageHeader header;
478 * Unique ID of the payload message
480 /* NEW: struct ChannelMessageIdentifier */
481 uint32_t mid GNUNET_PACKED;
486 struct GNUNET_CADET_ChannelTunnelNumber ctn;
495 * Message to acknowledge end-to-end data.
497 struct GNUNET_CADET_ChannelDataAckMessage
500 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
502 struct GNUNET_MessageHeader header;
507 struct GNUNET_CADET_ChannelTunnelNumber ctn;
510 * Bitfield of already-received messages past @e mid.
514 uint64_t futures GNUNET_PACKED;
517 * Last message ID received.
519 /* NEW: struct ChannelMessageIdentifier */
520 uint32_t mid GNUNET_PACKED;
527 * Number used to uniquely identify messages in a CADET Channel.
529 struct ChannelMessageIdentifier
532 * Unique ID of the message, cycles around, in NBO.
534 uint32_t mid GNUNET_PACKED;
539 * Message for cadet data traffic.
541 struct GNUNET_CADET_ChannelAppDataMessage
544 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA.
546 struct GNUNET_MessageHeader header;
549 * Unique ID of the payload message.
551 struct ChannelMessageIdentifier mid;
556 struct GNUNET_CADET_ChannelTunnelNumber ctn;
565 * Message to acknowledge end-to-end data.
567 struct GNUNET_CADET_ChannelDataAckMessage
570 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
572 struct GNUNET_MessageHeader header;
577 struct GNUNET_CADET_ChannelTunnelNumber ctn;
580 * Bitfield of already-received newer messages. Note that bit 0
581 * corresponds to @e mid + 1.
586 uint64_t futures GNUNET_PACKED;
589 * Next message ID expected.
591 struct ChannelMessageIdentifier mid;
597 GNUNET_NETWORK_STRUCT_END
599 #if 0 /* keep Emacsens' auto-indent happy */
606 /* ifndef CADET_PROTOCOL_H */
608 /* end of cadet_protocol.h */