diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2017-03-29 14:26:33 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2017-03-29 14:26:33 +0200 |
commit | ab281595eeb270120f89ec954a572f4fcf78fc53 (patch) | |
tree | 335a2caf503596adc400c5ebb9fb742f097bc5a3 /src/cadet/cadet_protocol.h | |
parent | 59d393a1124cfd1aaffdf994bf6f8a9baaac8361 (diff) | |
parent | 2b87f173e360aaf4a3bac3fbc6e5b4dc44cf58cd (diff) | |
download | gnunet-ab281595eeb270120f89ec954a572f4fcf78fc53.tar.gz gnunet-ab281595eeb270120f89ec954a572f4fcf78fc53.zip |
- merge with master
Diffstat (limited to 'src/cadet/cadet_protocol.h')
-rw-r--r-- | src/cadet/cadet_protocol.h | 193 |
1 files changed, 64 insertions, 129 deletions
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index 5ec34f7d7..de0cec5d0 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001 - 2011 GNUnet e.V. | 3 | Copyright (C) 2007 - 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -19,8 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Bartlomiej Polot | ||
23 | * @file cadet/cadet_protocol.h | 22 | * @file cadet/cadet_protocol.h |
23 | * @brief P2P messages used by CADET | ||
24 | * @author Bartlomiej Polot | ||
25 | * @author Christian Grothoff | ||
24 | */ | 26 | */ |
25 | 27 | ||
26 | #ifndef CADET_PROTOCOL_H_ | 28 | #ifndef CADET_PROTOCOL_H_ |
@@ -67,9 +69,12 @@ struct GNUNET_CADET_ConnectionCreateMessage | |||
67 | struct GNUNET_MessageHeader header; | 69 | struct GNUNET_MessageHeader header; |
68 | 70 | ||
69 | /** | 71 | /** |
70 | * For alignment. | 72 | * Connection options in network byte order. |
73 | * #GNUNET_CADET_OPTION_DEFAULT for buffered; | ||
74 | * #GNUNET_CADET_OPTION_NOBUFFER for unbuffered. | ||
75 | * Other flags are ignored and should not be set at this level. | ||
71 | */ | 76 | */ |
72 | uint32_t reserved GNUNET_PACKED; | 77 | uint32_t options GNUNET_PACKED; |
73 | 78 | ||
74 | /** | 79 | /** |
75 | * ID of the connection | 80 | * ID of the connection |
@@ -205,7 +210,9 @@ enum GNUNET_CADET_KX_Flags { | |||
205 | struct GNUNET_CADET_TunnelKeyExchangeMessage | 210 | struct GNUNET_CADET_TunnelKeyExchangeMessage |
206 | { | 211 | { |
207 | /** | 212 | /** |
208 | * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX. | 213 | * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX or |
214 | * #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH as part | ||
215 | * of `struct GNUNET_CADET_TunnelKeyExchangeAuthMessage`. | ||
209 | */ | 216 | */ |
210 | struct GNUNET_MessageHeader header; | 217 | struct GNUNET_MessageHeader header; |
211 | 218 | ||
@@ -234,50 +241,36 @@ struct GNUNET_CADET_TunnelKeyExchangeMessage | |||
234 | */ | 241 | */ |
235 | struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key; | 242 | struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key; |
236 | 243 | ||
237 | #ifdef NEW_CADET | ||
238 | /** | ||
239 | * Proof that sender could compute the 3-DH, in lieu of a signature. | ||
240 | */ | ||
241 | struct GNUNET_HashCode triple_dh_proof; | ||
242 | #endif | ||
243 | }; | 244 | }; |
244 | 245 | ||
245 | 246 | ||
246 | /** | 247 | /** |
247 | * Axolotl tunnel message. | 248 | * Message for a Key eXchange for a tunnel, with authentication. |
249 | * Used as a response to the initial KX as well as for rekeying. | ||
248 | */ | 250 | */ |
249 | struct GNUNET_CADET_TunnelEncryptedMessage | 251 | struct GNUNET_CADET_TunnelKeyExchangeAuthMessage |
250 | { | 252 | { |
251 | /** | ||
252 | * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED | ||
253 | */ | ||
254 | struct GNUNET_MessageHeader header; | ||
255 | 253 | ||
256 | #if NEW_CADET | ||
257 | /** | 254 | /** |
258 | * Reserved, for alignment. | 255 | * Message header with key material. |
259 | */ | 256 | */ |
260 | uint32_t reserved GNUNET_PACKED; | 257 | struct GNUNET_CADET_TunnelKeyExchangeMessage kx; |
261 | #else | ||
262 | /** | ||
263 | * Maximum packet ID authorized. | ||
264 | */ | ||
265 | struct CadetEncryptedMessageIdentifier cemi; | ||
266 | #endif | ||
267 | 258 | ||
268 | /** | 259 | /** |
269 | * ID of the connection. | 260 | * KDF-proof that sender could compute the 3-DH, used in lieu of a |
261 | * signature or payload data. | ||
270 | */ | 262 | */ |
271 | struct GNUNET_CADET_ConnectionTunnelIdentifier cid; | 263 | struct GNUNET_HashCode auth; |
264 | |||
265 | }; | ||
272 | 266 | ||
273 | /** | ||
274 | * MAC of the encrypted message, used to verify message integrity. | ||
275 | * Everything after this value will be encrypted with the header key | ||
276 | * and authenticated. | ||
277 | */ | ||
278 | struct GNUNET_ShortHashCode hmac; | ||
279 | 267 | ||
280 | /**************** AX_HEADER start ****************/ | 268 | /** |
269 | * Encrypted axolotl header with numbers that identify which | ||
270 | * keys in which ratchet are to be used to decrypt the body. | ||
271 | */ | ||
272 | struct GNUNET_CADET_AxHeader | ||
273 | { | ||
281 | 274 | ||
282 | /** | 275 | /** |
283 | * Number of messages sent with the current ratchet key. | 276 | * Number of messages sent with the current ratchet key. |
@@ -294,68 +287,47 @@ struct GNUNET_CADET_TunnelEncryptedMessage | |||
294 | */ | 287 | */ |
295 | struct GNUNET_CRYPTO_EcdhePublicKey DHRs; | 288 | struct GNUNET_CRYPTO_EcdhePublicKey DHRs; |
296 | 289 | ||
297 | /**************** AX_HEADER end ****************/ | ||
298 | |||
299 | /** | ||
300 | * Encrypted content follows. | ||
301 | */ | ||
302 | }; | 290 | }; |
303 | 291 | ||
304 | 292 | ||
305 | #ifndef NEW_CADET | ||
306 | |||
307 | /** | 293 | /** |
308 | * Message to query a peer about its Flow Control status regarding a tunnel. | 294 | * Axolotl-encrypted tunnel message with application payload. |
309 | * | ||
310 | * It is NOT yet clear if we need this. | ||
311 | */ | 295 | */ |
312 | struct GNUNET_CADET_ConnectionHopByHopPollMessage | 296 | struct GNUNET_CADET_TunnelEncryptedMessage |
313 | { | 297 | { |
314 | /** | 298 | /** |
315 | * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL | 299 | * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED |
316 | */ | 300 | */ |
317 | struct GNUNET_MessageHeader header; | 301 | struct GNUNET_MessageHeader header; |
318 | 302 | ||
319 | /** | 303 | /** |
320 | * Last packet sent. | 304 | * Reserved, for alignment. |
321 | */ | 305 | */ |
322 | struct CadetEncryptedMessageIdentifier cemi; | 306 | uint32_t reserved GNUNET_PACKED; |
323 | 307 | ||
324 | /** | 308 | /** |
325 | * ID of the connection. | 309 | * ID of the connection. |
326 | */ | 310 | */ |
327 | struct GNUNET_CADET_ConnectionTunnelIdentifier cid; | 311 | struct GNUNET_CADET_ConnectionTunnelIdentifier cid; |
328 | 312 | ||
329 | }; | ||
330 | |||
331 | |||
332 | /** | ||
333 | * Message to acknowledge cadet encrypted traffic, used for | ||
334 | * flow-control on a hop-by-hop basis on the connection-level. Note | ||
335 | * that we do use the @e cemi from the tunnel layer as the connection | ||
336 | * layer's header is included/shared with the tunnel layer messages, | ||
337 | * and we only do flow control for the payload. | ||
338 | */ | ||
339 | struct GNUNET_CADET_ConnectionEncryptedAckMessage | ||
340 | { | ||
341 | /** | 313 | /** |
342 | * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK | 314 | * MAC of the encrypted message, used to verify message integrity. |
315 | * Everything after this value will be encrypted with the header key | ||
316 | * and authenticated. | ||
343 | */ | 317 | */ |
344 | struct GNUNET_MessageHeader header; | 318 | struct GNUNET_ShortHashCode hmac; |
345 | 319 | ||
346 | /** | 320 | /** |
347 | * Maximum packet ID authorized. | 321 | * Axolotl-header that specifies which keys to use in which ratchet |
322 | * to decrypt the body that follows. | ||
348 | */ | 323 | */ |
349 | struct CadetEncryptedMessageIdentifier cemi_max; | 324 | struct GNUNET_CADET_AxHeader ax_header; |
350 | 325 | ||
351 | /** | 326 | /** |
352 | * ID of the connection. | 327 | * Encrypted content follows. |
353 | */ | 328 | */ |
354 | struct GNUNET_CADET_ConnectionTunnelIdentifier cid; | ||
355 | }; | 329 | }; |
356 | 330 | ||
357 | #endif | ||
358 | |||
359 | 331 | ||
360 | /******************************************************************************/ | 332 | /******************************************************************************/ |
361 | /******************************* CHANNEL ***********************************/ | 333 | /******************************* CHANNEL ***********************************/ |
@@ -378,9 +350,9 @@ struct GNUNET_CADET_ChannelOpenMessage | |||
378 | uint32_t opt GNUNET_PACKED; | 350 | uint32_t opt GNUNET_PACKED; |
379 | 351 | ||
380 | /** | 352 | /** |
381 | * Destination port. | 353 | * Hash of destination port and listener. |
382 | */ | 354 | */ |
383 | struct GNUNET_HashCode port; | 355 | struct GNUNET_HashCode h_port; |
384 | 356 | ||
385 | /** | 357 | /** |
386 | * ID of the channel within the tunnel. | 358 | * ID of the channel within the tunnel. |
@@ -390,93 +362,56 @@ struct GNUNET_CADET_ChannelOpenMessage | |||
390 | 362 | ||
391 | 363 | ||
392 | /** | 364 | /** |
393 | * Message to manage a Channel | 365 | * Message to acknowledge opening a channel of type |
394 | * (#GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK, | 366 | * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK. |
395 | * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY). | ||
396 | */ | 367 | */ |
397 | struct GNUNET_CADET_ChannelManageMessage | 368 | struct GNUNET_CADET_ChannelOpenAckMessage |
398 | { | 369 | { |
399 | /** | 370 | /** |
400 | * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK or | 371 | * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK |
401 | * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY | ||
402 | */ | 372 | */ |
403 | struct GNUNET_MessageHeader header; | 373 | struct GNUNET_MessageHeader header; |
404 | 374 | ||
405 | #ifdef NEW_CADET | ||
406 | /** | 375 | /** |
407 | * For alignment. | 376 | * For alignment. |
408 | */ | 377 | */ |
409 | uint32_t reserved GNUNET_PACKED; | 378 | uint32_t reserved GNUNET_PACKED; |
410 | #endif | ||
411 | 379 | ||
412 | /** | 380 | /** |
413 | * ID of the channel | 381 | * ID of the channel |
414 | */ | 382 | */ |
415 | struct GNUNET_CADET_ChannelTunnelNumber ctn; | 383 | struct GNUNET_CADET_ChannelTunnelNumber ctn; |
416 | }; | ||
417 | |||
418 | |||
419 | #ifndef NEW_CADET | ||
420 | |||
421 | /** | ||
422 | * Message for cadet data traffic. | ||
423 | */ | ||
424 | struct GNUNET_CADET_ChannelAppDataMessage | ||
425 | { | ||
426 | /** | ||
427 | * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST, | ||
428 | * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN | ||
429 | */ | ||
430 | struct GNUNET_MessageHeader header; | ||
431 | |||
432 | /** | ||
433 | * Unique ID of the payload message | ||
434 | */ | ||
435 | /* NEW: struct ChannelMessageIdentifier */ | ||
436 | uint32_t mid GNUNET_PACKED; | ||
437 | 384 | ||
438 | /** | 385 | /** |
439 | * ID of the channel | 386 | * Port number of the channel, used to prove to the |
440 | */ | 387 | * initiator that the receiver knows the port. |
441 | struct GNUNET_CADET_ChannelTunnelNumber ctn; | ||
442 | |||
443 | /** | ||
444 | * Payload follows | ||
445 | */ | 388 | */ |
389 | struct GNUNET_HashCode port; | ||
446 | }; | 390 | }; |
447 | 391 | ||
448 | 392 | ||
449 | /** | 393 | /** |
450 | * Message to acknowledge end-to-end data. | 394 | * Message to destroy a channel of type |
395 | * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY. | ||
451 | */ | 396 | */ |
452 | struct GNUNET_CADET_ChannelDataAckMessage | 397 | struct GNUNET_CADET_ChannelDestroyMessage |
453 | { | 398 | { |
454 | /** | 399 | /** |
455 | * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK | 400 | * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY |
456 | */ | 401 | */ |
457 | struct GNUNET_MessageHeader header; | 402 | struct GNUNET_MessageHeader header; |
458 | 403 | ||
459 | /** | 404 | /** |
460 | * ID of the channel | 405 | * For alignment. |
461 | */ | ||
462 | struct GNUNET_CADET_ChannelTunnelNumber ctn; | ||
463 | |||
464 | /** | ||
465 | * Bitfield of already-received newer messages | ||
466 | * pid + 1 @ LSB | ||
467 | * pid + 64 @ MSB | ||
468 | */ | 406 | */ |
469 | uint64_t futures GNUNET_PACKED; | 407 | uint32_t reserved GNUNET_PACKED; |
470 | 408 | ||
471 | /** | 409 | /** |
472 | * Last message ID received. | 410 | * ID of the channel |
473 | */ | 411 | */ |
474 | /* NEW: struct ChannelMessageIdentifier */ | 412 | struct GNUNET_CADET_ChannelTunnelNumber ctn; |
475 | uint32_t mid GNUNET_PACKED; | ||
476 | }; | 413 | }; |
477 | 414 | ||
478 | #else | ||
479 | |||
480 | 415 | ||
481 | /** | 416 | /** |
482 | * Number used to uniquely identify messages in a CADET Channel. | 417 | * Number used to uniquely identify messages in a CADET Channel. |
@@ -532,21 +467,21 @@ struct GNUNET_CADET_ChannelDataAckMessage | |||
532 | struct GNUNET_CADET_ChannelTunnelNumber ctn; | 467 | struct GNUNET_CADET_ChannelTunnelNumber ctn; |
533 | 468 | ||
534 | /** | 469 | /** |
535 | * Bitfield of already-received messages past @e mid. | 470 | * Bitfield of already-received newer messages. Note that bit 0 |
536 | * pid + 1 @ LSB | 471 | * corresponds to @e mid + 1. |
537 | * pid + 64 @ MSB | 472 | * |
473 | * pid + 0 @ LSB | ||
474 | * pid + 63 @ MSB | ||
538 | */ | 475 | */ |
539 | uint64_t futures GNUNET_PACKED; | 476 | uint64_t futures GNUNET_PACKED; |
540 | 477 | ||
541 | /** | 478 | /** |
542 | * Last message ID received. | 479 | * Next message ID expected. |
543 | */ | 480 | */ |
544 | struct ChannelMessageIdentifier mid; | 481 | struct ChannelMessageIdentifier mid; |
545 | }; | 482 | }; |
546 | 483 | ||
547 | 484 | ||
548 | #endif | ||
549 | |||
550 | GNUNET_NETWORK_STRUCT_END | 485 | GNUNET_NETWORK_STRUCT_END |
551 | 486 | ||
552 | #if 0 /* keep Emacsens' auto-indent happy */ | 487 | #if 0 /* keep Emacsens' auto-indent happy */ |