aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2016-10-29 23:46:44 +0000
committerBart Polot <bart@net.in.tum.de>2016-10-29 23:46:44 +0000
commitf7f26f6ca1b76d2734463d4989b9541df48a6773 (patch)
treeefcbc1e51bbe162577b981dd3e601aec81a348a8
parenta3735db333033ccefc95c56148ec3118bf7a0ccd (diff)
downloadgnunet-f7f26f6ca1b76d2734463d4989b9541df48a6773.tar.gz
gnunet-f7f26f6ca1b76d2734463d4989b9541df48a6773.zip
Refactor encrypted traffic handling
- eliminate encapsulation for KX/DATA - simplify cases - remove dead code - Organize message types
-rw-r--r--src/cadet/cadet_common.c15
-rw-r--r--src/cadet/cadet_protocol.h224
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c16
-rw-r--r--src/cadet/gnunet-service-cadet_connection.h2
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c86
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c554
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.h17
-rw-r--r--src/include/gnunet_constants.h2
-rw-r--r--src/include/gnunet_protocols.h114
9 files changed, 433 insertions, 597 deletions
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c
index c24bc5c4b..a9d9a35be 100644
--- a/src/cadet/cadet_common.c
+++ b/src/cadet/cadet_common.c
@@ -192,17 +192,17 @@ GC_m2s (uint16_t m)
192 break; 192 break;
193 193
194 /** 194 /**
195 * Key exchange encapsulation. 195 * Key exchange message.
196 */ 196 */
197 case GNUNET_MESSAGE_TYPE_CADET_KX: 197 case GNUNET_MESSAGE_TYPE_CADET_KX:
198 s = "KX"; 198 s = "KX";
199 break; 199 break;
200 200
201 /** 201 /**
202 * Axolotl key exchange message. 202 * Encrypted.
203 */ 203 */
204 case GNUNET_MESSAGE_TYPE_CADET_AX_KX: 204 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
205 s = "AX_KX"; 205 s = "ENCRYPTED";
206 break; 206 break;
207 207
208 /** 208 /**
@@ -276,13 +276,6 @@ GC_m2s (uint16_t m)
276 break; 276 break;
277 277
278 /** 278 /**
279 * Axolotl encrypted payload.
280 */
281 case GNUNET_MESSAGE_TYPE_CADET_AX:
282 s = "AX";
283 break;
284
285 /**
286 * Local payload traffic 279 * Local payload traffic
287 */ 280 */
288 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA: 281 case GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA:
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h
index 2df652e34..d034c63b0 100644
--- a/src/cadet/cadet_protocol.h
+++ b/src/cadet/cadet_protocol.h
@@ -47,6 +47,12 @@ extern "C"
47 47
48GNUNET_NETWORK_STRUCT_BEGIN 48GNUNET_NETWORK_STRUCT_BEGIN
49 49
50
51/******************************************************************************/
52/***************************** CONNECTION **********************************/
53/******************************************************************************/
54
55
50/** 56/**
51 * Message for cadet connection creation. 57 * Message for cadet connection creation.
52 */ 58 */
@@ -102,15 +108,15 @@ struct GNUNET_CADET_ConnectionACK
102 108
103 109
104/** 110/**
105 * Message for encapsulation of a Key eXchange message in a connection. 111 * Message for notifying a disconnection in a path
106 */ 112 */
107struct GNUNET_CADET_KX 113struct GNUNET_CADET_ConnectionBroken
108{ 114{
109 /** 115 /**
110 * Type: #GNUNET_MESSAGE_TYPE_CADET_KX. 116 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
111 */ 117 */
112 struct GNUNET_MessageHeader header; 118 struct GNUNET_MessageHeader header;
113 119
114 /** 120 /**
115 * For alignment. 121 * For alignment.
116 */ 122 */
@@ -121,44 +127,129 @@ struct GNUNET_CADET_KX
121 */ 127 */
122 struct GNUNET_CADET_Hash cid; 128 struct GNUNET_CADET_Hash cid;
123 129
124 /* Specific KX message follows. */ 130 /**
131 * ID of the endpoint
132 */
133 struct GNUNET_PeerIdentity peer1;
134
135 /**
136 * ID of the endpoint
137 */
138 struct GNUNET_PeerIdentity peer2;
125}; 139};
126 140
127 141
128/** 142/**
129 * Flags to be used in GNUNET_CADET_AX_KX. 143 * Message to destroy a connection.
130 */ 144 */
131enum GNUNET_CADET_AX_KX_Flags { 145struct GNUNET_CADET_ConnectionDestroy
146{
147 /**
148 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
149 */
150 struct GNUNET_MessageHeader header;
151
152 /**
153 * For alignment.
154 */
155 uint32_t reserved GNUNET_PACKED;
156
157 /**
158 * ID of the connection.
159 */
160 struct GNUNET_CADET_Hash cid;
161};
162
163
164/**
165 * Message to acknowledge cadet encrypted traffic.
166 */
167struct GNUNET_CADET_ACK
168{
169 /**
170 * Type: #GNUNET_MESSAGE_TYPE_CADET_ACK
171 */
172 struct GNUNET_MessageHeader header;
173
174 /**
175 * Maximum packet ID authorized.
176 */
177 uint32_t ack GNUNET_PACKED;
178
179 /**
180 * ID of the connection.
181 */
182 struct GNUNET_CADET_Hash cid;
183};
184
185
186/**
187 * Message to query a peer about its Flow Control status regarding a tunnel.
188 */
189struct GNUNET_CADET_Poll
190{
191 /**
192 * Type: #GNUNET_MESSAGE_TYPE_CADET_POLL
193 */
194 struct GNUNET_MessageHeader header;
195
196 /**
197 * Last packet sent.
198 */
199 uint32_t pid GNUNET_PACKED;
200
201 /**
202 * ID of the connection.
203 */
204 struct GNUNET_CADET_Hash cid;
205
206};
207
208
209
210/******************************************************************************/
211/******************************* TUNNEL ***********************************/
212/******************************************************************************/
213
214/**
215 * Flags to be used in GNUNET_CADET_KX.
216 */
217enum GNUNET_CADET_KX_Flags {
132 218
133 /** 219 /**
134 * Should the peer reply with its KX details? 220 * Should the peer reply with its KX details?
135 */ 221 */
136 GNUNET_CADET_AX_KX_FLAG_NONE = 0, 222 GNUNET_CADET_KX_FLAG_NONE = 0,
137 223
138 /** 224 /**
139 * The peer should reply with its KX details? 225 * The peer should reply with its KX details?
140 */ 226 */
141 GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY = 1 227 GNUNET_CADET_KX_FLAG_FORCE_REPLY = 1
142}; 228};
143 229
144 230
145/** 231/**
146 * Message for encapsulation of a Key eXchange message in a connection. 232 * Message for a Key eXchange for a tunnel.
147 */ 233 */
148struct GNUNET_CADET_AX_KX 234struct GNUNET_CADET_KX
149{ 235{
150 /** 236 /**
151 * Type: #GNUNET_MESSAGE_TYPE_CADET_AX_KX. 237 * Type: #GNUNET_MESSAGE_TYPE_CADET_KX.
152 */ 238 */
153 struct GNUNET_MessageHeader header; 239 struct GNUNET_MessageHeader header;
154 240
155 /** 241 /**
156 * Flags for the key exchange in NBO, based on 242 * Flags for the key exchange in NBO, based on
157 * `enum GNUNET_CADET_AX_KX_Flags`. 243 * `enum GNUNET_CADET_KX_Flags`.
158 */ 244 */
159 uint32_t flags GNUNET_PACKED; 245 uint32_t flags GNUNET_PACKED;
160 246
161 /** 247 /**
248 * ID of the connection.
249 */
250 struct GNUNET_CADET_Hash cid;
251
252 /**
162 * Sender's ephemeral public ECC key encoded in a 253 * Sender's ephemeral public ECC key encoded in a
163 * format suitable for network transmission, as created 254 * format suitable for network transmission, as created
164 * using 'gcry_sexp_sprint'. 255 * using 'gcry_sexp_sprint'.
@@ -177,10 +268,10 @@ struct GNUNET_CADET_AX_KX
177/** 268/**
178 * Axolotl tunnel message. 269 * Axolotl tunnel message.
179 */ 270 */
180struct GNUNET_CADET_AX 271struct GNUNET_CADET_Encrypted
181{ 272{
182 /** 273 /**
183 * Type: #GNUNET_MESSAGE_TYPE_CADET_AXOLOTL_DATA 274 * Type: #GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED
184 */ 275 */
185 struct GNUNET_MessageHeader header; 276 struct GNUNET_MessageHeader header;
186 277
@@ -226,6 +317,11 @@ struct GNUNET_CADET_AX
226}; 317};
227 318
228 319
320
321/******************************************************************************/
322/******************************* CHANNEL ***********************************/
323/******************************************************************************/
324
229/** 325/**
230 * Message to create a Channel. 326 * Message to create a Channel.
231 */ 327 */
@@ -326,104 +422,6 @@ struct GNUNET_CADET_DataACK
326}; 422};
327 423
328 424
329/**
330 * Message to acknowledge cadet encrypted traffic.
331 */
332struct GNUNET_CADET_ACK
333{
334 /**
335 * Type: #GNUNET_MESSAGE_TYPE_CADET_ACK
336 */
337 struct GNUNET_MessageHeader header;
338
339 /**
340 * Maximum packet ID authorized.
341 */
342 uint32_t ack GNUNET_PACKED;
343
344 /**
345 * ID of the connection.
346 */
347 struct GNUNET_CADET_Hash cid;
348};
349
350
351/**
352 * Message to query a peer about its Flow Control status regarding a tunnel.
353 */
354struct GNUNET_CADET_Poll
355{
356 /**
357 * Type: #GNUNET_MESSAGE_TYPE_CADET_POLL
358 */
359 struct GNUNET_MessageHeader header;
360
361 /**
362 * Last packet sent.
363 */
364 uint32_t pid GNUNET_PACKED;
365
366 /**
367 * ID of the connection.
368 */
369 struct GNUNET_CADET_Hash cid;
370
371};
372
373
374/**
375 * Message for notifying a disconnection in a path
376 */
377struct GNUNET_CADET_ConnectionBroken
378{
379 /**
380 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
381 */
382 struct GNUNET_MessageHeader header;
383
384 /**
385 * For alignment.
386 */
387 uint32_t reserved GNUNET_PACKED;
388
389 /**
390 * ID of the connection.
391 */
392 struct GNUNET_CADET_Hash cid;
393
394 /**
395 * ID of the endpoint
396 */
397 struct GNUNET_PeerIdentity peer1;
398
399 /**
400 * ID of the endpoint
401 */
402 struct GNUNET_PeerIdentity peer2;
403};
404
405
406/**
407 * Message to destroy a connection.
408 */
409struct GNUNET_CADET_ConnectionDestroy
410{
411 /**
412 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
413 */
414 struct GNUNET_MessageHeader header;
415
416 /**
417 * For alignment.
418 */
419 uint32_t reserved GNUNET_PACKED;
420
421 /**
422 * ID of the connection.
423 */
424 struct GNUNET_CADET_Hash cid;
425};
426
427 425
428GNUNET_NETWORK_STRUCT_END 426GNUNET_NETWORK_STRUCT_END
429 427
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 205f0b3b3..c88df79fd 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -736,7 +736,7 @@ conn_message_sent (void *cls,
736 } 736 }
737 GNUNET_free (q); 737 GNUNET_free (q);
738 } 738 }
739 else if (type == GNUNET_MESSAGE_TYPE_CADET_AX) 739 else if (type == GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED)
740 { 740 {
741 /* SHOULD NO LONGER HAPPEN FIXME: REMOVE CASE */ 741 /* SHOULD NO LONGER HAPPEN FIXME: REMOVE CASE */
742 // If NULL == q and ENCRYPTED == type, message must have been ch_mngmnt 742 // If NULL == q and ENCRYPTED == type, message must have been ch_mngmnt
@@ -771,7 +771,7 @@ conn_message_sent (void *cls,
771 schedule_next_keepalive (c, fwd); 771 schedule_next_keepalive (c, fwd);
772 break; 772 break;
773 773
774 case GNUNET_MESSAGE_TYPE_CADET_AX: 774 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
775 if (GNUNET_YES == sent) 775 if (GNUNET_YES == sent)
776 { 776 {
777 GNUNET_assert (NULL != q); 777 GNUNET_assert (NULL != q);
@@ -2517,7 +2517,7 @@ check_message (const struct GNUNET_MessageHeader *message,
2517 2517
2518 /* Check PID for payload messages */ 2518 /* Check PID for payload messages */
2519 type = ntohs (message->type); 2519 type = ntohs (message->type);
2520 if (GNUNET_MESSAGE_TYPE_CADET_AX == type) 2520 if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type)
2521 { 2521 {
2522 fc = fwd ? &c->bck_fc : &c->fwd_fc; 2522 fc = fwd ? &c->bck_fc : &c->fwd_fc;
2523 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n", 2523 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n",
@@ -2611,7 +2611,7 @@ GCC_handle_kx (struct CadetPeer *peer,
2611 GNUNET_break (0); 2611 GNUNET_break (0);
2612 return; 2612 return;
2613 } 2613 }
2614 GCT_handle_kx (c->t, &msg[1].header); 2614 GCT_handle_kx (c->t, msg);
2615 GCC_check_connections (); 2615 GCC_check_connections ();
2616 return; 2616 return;
2617 } 2617 }
@@ -2633,7 +2633,7 @@ GCC_handle_kx (struct CadetPeer *peer,
2633 */ 2633 */
2634void 2634void
2635GCC_handle_encrypted (struct CadetPeer *peer, 2635GCC_handle_encrypted (struct CadetPeer *peer,
2636 const struct GNUNET_CADET_AX *msg) 2636 const struct GNUNET_CADET_Encrypted *msg)
2637{ 2637{
2638 const struct GNUNET_CADET_Hash* cid; 2638 const struct GNUNET_CADET_Hash* cid;
2639 struct CadetConnection *c; 2639 struct CadetConnection *c;
@@ -2670,7 +2670,7 @@ GCC_handle_encrypted (struct CadetPeer *peer,
2670 GNUNET_break (GNUNET_NO != c->destroy); 2670 GNUNET_break (GNUNET_NO != c->destroy);
2671 return; 2671 return;
2672 } 2672 }
2673 GCT_handle_encrypted (c->t, &msg->header); 2673 GCT_handle_encrypted (c->t, msg);
2674 GCC_send_ack (c, fwd, GNUNET_NO); 2674 GCC_send_ack (c, fwd, GNUNET_NO);
2675 GCC_check_connections (); 2675 GCC_check_connections ();
2676 return; 2676 return;
@@ -3275,7 +3275,7 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3275 GC_f2s(fwd), size); 3275 GC_f2s(fwd), size);
3276 switch (type) 3276 switch (type)
3277 { 3277 {
3278 case GNUNET_MESSAGE_TYPE_CADET_AX: 3278 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
3279 LOG (GNUNET_ERROR_TYPE_DEBUG, " Q_N+ %p %u\n", fc, fc->queue_n); 3279 LOG (GNUNET_ERROR_TYPE_DEBUG, " Q_N+ %p %u\n", fc, fc->queue_n);
3280 LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent); 3280 LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent);
3281 LOG (GNUNET_ERROR_TYPE_DEBUG, " ack recv %u\n", fc->last_ack_recv); 3281 LOG (GNUNET_ERROR_TYPE_DEBUG, " ack recv %u\n", fc->last_ack_recv);
@@ -3312,7 +3312,7 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3312 GNUNET_break (0); 3312 GNUNET_break (0);
3313 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue full: %u/%u\n", 3313 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue full: %u/%u\n",
3314 fc->queue_n, fc->queue_max); 3314 fc->queue_n, fc->queue_max);
3315 if (GNUNET_MESSAGE_TYPE_CADET_AX == type) 3315 if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type)
3316 { 3316 {
3317 fc->queue_n--; 3317 fc->queue_n--;
3318 } 3318 }
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h
index 4e994f2be..27f105f81 100644
--- a/src/cadet/gnunet-service-cadet_connection.h
+++ b/src/cadet/gnunet-service-cadet_connection.h
@@ -197,7 +197,7 @@ GCC_handle_kx (struct CadetPeer *peer,
197 */ 197 */
198void 198void
199GCC_handle_encrypted (struct CadetPeer *peer, 199GCC_handle_encrypted (struct CadetPeer *peer,
200 const struct GNUNET_CADET_AX *msg); 200 const struct GNUNET_CADET_Encrypted *msg);
201 201
202/** 202/**
203 * Core handler for axolotl key exchange traffic. 203 * Core handler for axolotl key exchange traffic.
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index da9b1bbe1..c312d56bf 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -548,32 +548,6 @@ handle_poll (void *cls, const struct GNUNET_CADET_Poll *msg)
548 548
549 549
550/** 550/**
551 * Check if the Key eXchange message has the appropriate size.
552 *
553 * @param cls Closure (unused).
554 * @param msg Message to check.
555 *
556 * @return #GNUNET_YES if size is correct, #GNUNET_NO otherwise.
557 */
558static int
559check_kx (void *cls, const struct GNUNET_CADET_KX *msg)
560{
561 uint16_t size;
562 uint16_t expected_size;
563
564 size = ntohs (msg->header.size);
565 expected_size = sizeof (struct GNUNET_CADET_KX)
566 + sizeof (struct GNUNET_MessageHeader);
567
568 if (size < expected_size)
569 {
570 GNUNET_break_op (0);
571 return GNUNET_NO;
572 }
573 return GNUNET_YES;
574}
575
576/**
577 * Handle for #GNUNET_MESSAGE_TYPE_CADET_KX 551 * Handle for #GNUNET_MESSAGE_TYPE_CADET_KX
578 * 552 *
579 * @param cls Closure (CadetPeer for neighbor that sent the message). 553 * @param cls Closure (CadetPeer for neighbor that sent the message).
@@ -596,13 +570,13 @@ handle_kx (void *cls, const struct GNUNET_CADET_KX *msg)
596 * @return #GNUNET_YES if size is correct, #GNUNET_NO otherwise. 570 * @return #GNUNET_YES if size is correct, #GNUNET_NO otherwise.
597 */ 571 */
598static int 572static int
599check_encrypted (void *cls, const struct GNUNET_CADET_AX *msg) 573check_encrypted (void *cls, const struct GNUNET_CADET_Encrypted *msg)
600{ 574{
601 uint16_t size; 575 uint16_t size;
602 uint16_t minimum_size; 576 uint16_t minimum_size;
603 577
604 size = ntohs (msg->header.size); 578 size = ntohs (msg->header.size);
605 minimum_size = sizeof (struct GNUNET_CADET_AX) 579 minimum_size = sizeof (struct GNUNET_CADET_Encrypted)
606 + sizeof (struct GNUNET_MessageHeader); 580 + sizeof (struct GNUNET_MessageHeader);
607 581
608 if (size < minimum_size) 582 if (size < minimum_size)
@@ -614,13 +588,13 @@ check_encrypted (void *cls, const struct GNUNET_CADET_AX *msg)
614} 588}
615 589
616/** 590/**
617 * Handle for #GNUNET_MESSAGE_TYPE_CADET_AX (AXolotl encrypted traffic). 591 * Handle for #GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED.
618 * 592 *
619 * @param cls Closure (CadetPeer for neighbor that sent the message). 593 * @param cls Closure (CadetPeer for neighbor that sent the message).
620 * @param msg Message itself. 594 * @param msg Message itself.
621 */ 595 */
622static void 596static void
623handle_encrypted (void *cls, const struct GNUNET_CADET_AX *msg) 597handle_encrypted (void *cls, const struct GNUNET_CADET_Encrypted *msg)
624{ 598{
625 struct CadetPeer *peer = cls; 599 struct CadetPeer *peer = cls;
626 GCC_handle_encrypted (peer, msg); 600 GCC_handle_encrypted (peer, msg);
@@ -643,37 +617,37 @@ connect_to_core (const struct GNUNET_CONFIGURATION_Handle *c)
643{ 617{
644 struct GNUNET_MQ_MessageHandler core_handlers[] = { 618 struct GNUNET_MQ_MessageHandler core_handlers[] = {
645 GNUNET_MQ_hd_var_size (create, 619 GNUNET_MQ_hd_var_size (create,
646 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 620 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE,
647 struct GNUNET_CADET_ConnectionCreate, 621 struct GNUNET_CADET_ConnectionCreate,
648 NULL), 622 NULL),
649 GNUNET_MQ_hd_fixed_size (confirm, 623 GNUNET_MQ_hd_fixed_size (confirm,
650 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 624 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK,
651 struct GNUNET_CADET_ConnectionACK, 625 struct GNUNET_CADET_ConnectionACK,
652 NULL), 626 NULL),
653 GNUNET_MQ_hd_fixed_size (broken, 627 GNUNET_MQ_hd_fixed_size (broken,
654 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 628 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN,
655 struct GNUNET_CADET_ConnectionBroken, 629 struct GNUNET_CADET_ConnectionBroken,
656 NULL), 630 NULL),
657 GNUNET_MQ_hd_fixed_size (destroy, 631 GNUNET_MQ_hd_fixed_size (destroy,
658 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY, 632 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY,
659 struct GNUNET_CADET_ConnectionDestroy, 633 struct GNUNET_CADET_ConnectionDestroy,
660 NULL), 634 NULL),
661 GNUNET_MQ_hd_fixed_size (ack, 635 GNUNET_MQ_hd_fixed_size (ack,
662 GNUNET_MESSAGE_TYPE_CADET_ACK, 636 GNUNET_MESSAGE_TYPE_CADET_ACK,
663 struct GNUNET_CADET_ACK, 637 struct GNUNET_CADET_ACK,
664 NULL), 638 NULL),
665 GNUNET_MQ_hd_fixed_size (poll, 639 GNUNET_MQ_hd_fixed_size (poll,
666 GNUNET_MESSAGE_TYPE_CADET_POLL, 640 GNUNET_MESSAGE_TYPE_CADET_POLL,
667 struct GNUNET_CADET_Poll, 641 struct GNUNET_CADET_Poll,
668 NULL), 642 NULL),
669 GNUNET_MQ_hd_var_size (kx, 643 GNUNET_MQ_hd_fixed_size (kx,
670 GNUNET_MESSAGE_TYPE_CADET_KX, 644 GNUNET_MESSAGE_TYPE_CADET_KX,
671 struct GNUNET_CADET_KX, 645 struct GNUNET_CADET_KX,
672 NULL), 646 NULL),
673 GNUNET_MQ_hd_var_size (encrypted, 647 GNUNET_MQ_hd_var_size (encrypted,
674 GNUNET_MESSAGE_TYPE_CADET_AX, 648 GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED,
675 struct GNUNET_CADET_AX, 649 struct GNUNET_CADET_Encrypted,
676 NULL), 650 NULL),
677 GNUNET_MQ_handler_end () 651 GNUNET_MQ_handler_end ()
678 }; 652 };
679 core_handle = GNUNET_CORE_connecT (c, NULL, 653 core_handle = GNUNET_CORE_connecT (c, NULL,
@@ -755,7 +729,7 @@ get_priority (struct CadetPeerQueue *q)
755 } 729 }
756 730
757 /* Bulky payload has lower priority, control traffic has higher. */ 731 /* Bulky payload has lower priority, control traffic has higher. */
758 if (GNUNET_MESSAGE_TYPE_CADET_AX == q->type) 732 if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == q->type)
759 return low; 733 return low;
760 return high; 734 return high;
761} 735}
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index 26c1ea3d4..249974d81 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -96,18 +96,6 @@ struct CadetTConnection
96 96
97 97
98/** 98/**
99 * Encryption systems possible.
100 */
101enum CadetTunnelEncryption
102{
103 /**
104 * Default Axolotl system.
105 */
106 CADET_Axolotl
107
108};
109
110/**
111 * Struct to old keys for skipped messages while advancing the Axolotl ratchet. 99 * Struct to old keys for skipped messages while advancing the Axolotl ratchet.
112 */ 100 */
113struct CadetTunnelSkippedKey 101struct CadetTunnelSkippedKey
@@ -267,11 +255,6 @@ struct CadetTunnel
267 struct CadetPeer *peer; 255 struct CadetPeer *peer;
268 256
269 /** 257 /**
270 * Type of encryption used in the tunnel.
271 */
272 enum CadetTunnelEncryption enc_type;
273
274 /**
275 * Axolotl info. 258 * Axolotl info.
276 */ 259 */
277 struct CadetTunnelAxolotl *ax; 260 struct CadetTunnelAxolotl *ax;
@@ -550,8 +533,7 @@ is_ready (struct CadetTunnel *t)
550 conn_ok = CADET_TUNNEL_READY == t->cstate; 533 conn_ok = CADET_TUNNEL_READY == t->cstate;
551 enc_ok = CADET_TUNNEL_KEY_OK == t->estate 534 enc_ok = CADET_TUNNEL_KEY_OK == t->estate
552 || CADET_TUNNEL_KEY_REKEY == t->estate 535 || CADET_TUNNEL_KEY_REKEY == t->estate
553 || (CADET_TUNNEL_KEY_PING == t->estate 536 || CADET_TUNNEL_KEY_PING == t->estate;
554 && CADET_Axolotl == t->enc_type);
555 ready = conn_ok && enc_ok; 537 ready = conn_ok && enc_ok;
556 ready = ready || GCT_is_loopback (t); 538 ready = ready || GCT_is_loopback (t);
557 return ready; 539 return ready;
@@ -869,7 +851,7 @@ t_ax_decrypt (struct CadetTunnel *t, void *dst, const void *src, size_t size)
869 * @param msg Message whose header to encrypt. 851 * @param msg Message whose header to encrypt.
870 */ 852 */
871static void 853static void
872t_h_encrypt (struct CadetTunnel *t, struct GNUNET_CADET_AX *msg) 854t_h_encrypt (struct CadetTunnel *t, struct GNUNET_CADET_Encrypted *msg)
873{ 855{
874 struct GNUNET_CRYPTO_SymmetricInitializationVector iv; 856 struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
875 struct CadetTunnelAxolotl *ax; 857 struct CadetTunnelAxolotl *ax;
@@ -902,8 +884,8 @@ t_h_encrypt (struct CadetTunnel *t, struct GNUNET_CADET_AX *msg)
902 * @param dst Where to decrypt header to. 884 * @param dst Where to decrypt header to.
903 */ 885 */
904static void 886static void
905t_h_decrypt (struct CadetTunnel *t, const struct GNUNET_CADET_AX *src, 887t_h_decrypt (struct CadetTunnel *t, const struct GNUNET_CADET_Encrypted *src,
906 struct GNUNET_CADET_AX *dst) 888 struct GNUNET_CADET_Encrypted *dst)
907{ 889{
908 struct GNUNET_CRYPTO_SymmetricInitializationVector iv; 890 struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
909 struct CadetTunnelAxolotl *ax; 891 struct CadetTunnelAxolotl *ax;
@@ -941,12 +923,12 @@ t_h_decrypt (struct CadetTunnel *t, const struct GNUNET_CADET_AX *src,
941 */ 923 */
942static int 924static int
943try_old_ax_keys (struct CadetTunnel *t, void *dst, 925try_old_ax_keys (struct CadetTunnel *t, void *dst,
944 const struct GNUNET_CADET_AX *src, size_t size) 926 const struct GNUNET_CADET_Encrypted *src, size_t size)
945{ 927{
946 struct CadetTunnelSkippedKey *key; 928 struct CadetTunnelSkippedKey *key;
947 struct GNUNET_CADET_Hash *hmac; 929 struct GNUNET_CADET_Hash *hmac;
948 struct GNUNET_CRYPTO_SymmetricInitializationVector iv; 930 struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
949 struct GNUNET_CADET_AX plaintext_header; 931 struct GNUNET_CADET_Encrypted plaintext_header;
950 struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK; 932 struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK;
951 size_t esize; 933 size_t esize;
952 size_t res; 934 size_t res;
@@ -955,7 +937,7 @@ try_old_ax_keys (struct CadetTunnel *t, void *dst,
955 937
956 LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying old keys\n"); 938 LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying old keys\n");
957 hmac = &plaintext_header.hmac; 939 hmac = &plaintext_header.hmac;
958 esize = size - sizeof (struct GNUNET_CADET_AX); 940 esize = size - sizeof (struct GNUNET_CADET_Encrypted);
959 941
960 /* Find a correct Header Key */ 942 /* Find a correct Header Key */
961 for (key = t->ax->skipped_head; NULL != key; key = key->next) 943 for (key = t->ax->skipped_head; NULL != key; key = key->next)
@@ -976,8 +958,8 @@ try_old_ax_keys (struct CadetTunnel *t, void *dst,
976 return -1; 958 return -1;
977 959
978 /* Should've been checked in -cadet_connection.c handle_cadet_encrypted. */ 960 /* Should've been checked in -cadet_connection.c handle_cadet_encrypted. */
979 GNUNET_assert (size > sizeof (struct GNUNET_CADET_AX)); 961 GNUNET_assert (size > sizeof (struct GNUNET_CADET_Encrypted));
980 len = size - sizeof (struct GNUNET_CADET_AX); 962 len = size - sizeof (struct GNUNET_CADET_Encrypted);
981 GNUNET_assert (len >= sizeof (struct GNUNET_MessageHeader)); 963 GNUNET_assert (len >= sizeof (struct GNUNET_MessageHeader));
982 964
983 /* Decrypt header */ 965 /* Decrypt header */
@@ -1120,20 +1102,20 @@ store_ax_keys (struct CadetTunnel *t,
1120 */ 1102 */
1121static int 1103static int
1122t_ax_decrypt_and_validate (struct CadetTunnel *t, void *dst, 1104t_ax_decrypt_and_validate (struct CadetTunnel *t, void *dst,
1123 const struct GNUNET_CADET_AX *src, size_t size) 1105 const struct GNUNET_CADET_Encrypted *src,
1106 size_t size)
1124{ 1107{
1125 struct CadetTunnelAxolotl *ax; 1108 struct CadetTunnelAxolotl *ax;
1126 struct GNUNET_CADET_Hash msg_hmac; 1109 struct GNUNET_CADET_Hash msg_hmac;
1127 struct GNUNET_HashCode hmac; 1110 struct GNUNET_HashCode hmac;
1128 struct GNUNET_CADET_AX plaintext_header; 1111 struct GNUNET_CADET_Encrypted plaintext_header;
1129 uint32_t Np; 1112 uint32_t Np;
1130 uint32_t PNp; 1113 uint32_t PNp;
1131 size_t esize; 1114 size_t esize; /* Size of encryped payload */
1132 size_t osize; 1115 size_t osize; /* Size of output (decrypted payload) */
1133 1116
1117 esize = size - sizeof (struct GNUNET_CADET_Encrypted);
1134 ax = t->ax; 1118 ax = t->ax;
1135 esize = size - sizeof (struct GNUNET_CADET_AX);
1136
1137 if (NULL == ax) 1119 if (NULL == ax)
1138 return -1; 1120 return -1;
1139 1121
@@ -1350,10 +1332,10 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1350 struct CadetTunnelQueue *existing_q) 1332 struct CadetTunnelQueue *existing_q)
1351{ 1333{
1352 struct GNUNET_MessageHeader *msg; 1334 struct GNUNET_MessageHeader *msg;
1353 struct GNUNET_CADET_AX *ax_msg; 1335 struct GNUNET_CADET_Encrypted *ax_msg;
1354 struct CadetTunnelQueue *tq; 1336 struct CadetTunnelQueue *tq;
1355 size_t size = ntohs (message->size); 1337 size_t size = ntohs (message->size);
1356 char cbuf[sizeof (struct GNUNET_CADET_AX) + size] GNUNET_ALIGN; 1338 char cbuf[sizeof (struct GNUNET_CADET_Encrypted) + size] GNUNET_ALIGN;
1357 size_t esize; 1339 size_t esize;
1358 uint32_t mid; 1340 uint32_t mid;
1359 uint16_t type; 1341 uint16_t type;
@@ -1381,11 +1363,10 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1381 1363
1382 GNUNET_assert (GNUNET_NO == GCT_is_loopback (t)); 1364 GNUNET_assert (GNUNET_NO == GCT_is_loopback (t));
1383 1365
1384 GNUNET_assert (CADET_Axolotl == t->enc_type); 1366 ax_msg = (struct GNUNET_CADET_Encrypted *) cbuf;
1385 ax_msg = (struct GNUNET_CADET_AX *) cbuf;
1386 msg = &ax_msg->header; 1367 msg = &ax_msg->header;
1387 msg->size = htons (sizeof (struct GNUNET_CADET_AX) + size); 1368 msg->size = htons (sizeof (struct GNUNET_CADET_Encrypted) + size);
1388 msg->type = htons (GNUNET_MESSAGE_TYPE_CADET_AX); 1369 msg->type = htons (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED);
1389 esize = t_ax_encrypt (t, &ax_msg[1], message, size); 1370 esize = t_ax_encrypt (t, &ax_msg[1], message, size);
1390 ax_msg->Ns = htonl (t->ax->Ns++); 1371 ax_msg->Ns = htonl (t->ax->Ns++);
1391 ax_msg->PNs = htonl (t->ax->PNs); 1372 ax_msg->PNs = htonl (t->ax->PNs);
@@ -1505,12 +1486,12 @@ send_queued_data (struct CadetTunnel *t)
1505 1486
1506 1487
1507/** 1488/**
1508 * @brief Resend the AX KX until we complete the handshake. 1489 * @brief Resend the KX until we complete the handshake.
1509 * 1490 *
1510 * @param cls Closure (tunnel). 1491 * @param cls Closure (tunnel).
1511 */ 1492 */
1512static void 1493static void
1513ax_kx_resend (void *cls) 1494kx_resend (void *cls)
1514{ 1495{
1515 struct CadetTunnel *t = cls; 1496 struct CadetTunnel *t = cls;
1516 1497
@@ -1522,7 +1503,7 @@ ax_kx_resend (void *cls)
1522 return; 1503 return;
1523 } 1504 }
1524 1505
1525 GCT_send_ax_kx (t, CADET_TUNNEL_KEY_SENT >= t->estate); 1506 GCT_send_kx (t, CADET_TUNNEL_KEY_SENT >= t->estate);
1526} 1507}
1527 1508
1528 1509
@@ -1549,98 +1530,15 @@ ephm_sent (void *cls,
1549 if (CADET_TUNNEL_KEY_OK == t->estate) 1530 if (CADET_TUNNEL_KEY_OK == t->estate)
1550 return; 1531 return;
1551 1532
1552 if (CADET_Axolotl == t->enc_type) 1533 if (NULL != t->rekey_task)
1553 {
1554 if (NULL != t->rekey_task)
1555 {
1556 GNUNET_break (0);
1557 GCT_debug (t, GNUNET_ERROR_TYPE_WARNING);
1558 GNUNET_SCHEDULER_cancel (t->rekey_task);
1559 }
1560 t->rekey_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
1561 &ax_kx_resend, t);
1562 }
1563}
1564
1565
1566/**
1567 * Sends key exchange message on a tunnel, choosing the best connection.
1568 * Should not be called on loopback tunnels.
1569 *
1570 * @param t Tunnel on which this message is transmitted.
1571 * @param message Message to send. Function modifies it.
1572 *
1573 * @return Handle to the message in the connection queue.
1574 */
1575static struct CadetConnectionQueue *
1576send_kx (struct CadetTunnel *t,
1577 const struct GNUNET_MessageHeader *message)
1578{
1579 struct CadetConnection *c;
1580 struct GNUNET_CADET_KX *msg;
1581 size_t size = ntohs (message->size);
1582 char cbuf[sizeof (struct GNUNET_CADET_KX) + size];
1583 uint16_t type;
1584 int fwd;
1585
1586 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT KX on Tunnel %s\n", GCT_2s (t));
1587
1588 /* Avoid loopback. */
1589 if (GCT_is_loopback (t))
1590 { 1534 {
1591 GNUNET_break (0); 1535 GNUNET_break (0);
1592 return NULL; 1536 GCT_debug (t, GNUNET_ERROR_TYPE_WARNING);
1593 } 1537 GNUNET_SCHEDULER_cancel (t->rekey_task);
1594 type = ntohs (message->type);
1595
1596 /* Even if tunnel is "being destroyed", send anyway.
1597 * Could be a response to a rekey initiated by remote peer,
1598 * who is trying to create a new channel!
1599 */
1600
1601 /* Must have a connection, or be looking for one. */
1602 if (NULL == t->connection_head)
1603 {
1604 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s with no connection\n", GC_m2s (type));
1605 if (CADET_TUNNEL_SEARCHING != t->cstate)
1606 {
1607 GNUNET_break (0);
1608 GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
1609 }
1610 return NULL;
1611 }
1612
1613 msg = (struct GNUNET_CADET_KX *) cbuf;
1614 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX);
1615 msg->header.size = htons (sizeof (struct GNUNET_CADET_KX) + size);
1616 msg->reserved = htonl (0);
1617 c = tunnel_get_connection (t);
1618 if (NULL == c)
1619 {
1620 if (NULL == t->destroy_task && CADET_TUNNEL_READY == t->cstate)
1621 {
1622 GNUNET_break (0);
1623 GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
1624 }
1625 return NULL;
1626 }
1627 msg->cid = *GCC_get_id (c);
1628 switch (type)
1629 {
1630 case GNUNET_MESSAGE_TYPE_CADET_AX_KX:
1631 GNUNET_assert (NULL == t->ephm_h);
1632 break;
1633 default:
1634 LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", GC_m2s (type));
1635 GNUNET_assert (0);
1636 } 1538 }
1637 GNUNET_memcpy (&msg[1], message, size); 1539 t->rekey_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
1638 1540 &kx_resend, t);
1639 fwd = GCC_is_origin (c, GNUNET_YES);
1640 1541
1641 return GCC_send_prebuilt_message (&msg->header, type, 0, c,
1642 fwd, GNUNET_YES,
1643 &ephm_sent, t);
1644} 1542}
1645 1543
1646 1544
@@ -1965,148 +1863,6 @@ destroy_ax (struct CadetTunnel *t)
1965 1863
1966 1864
1967/** 1865/**
1968 * Handle Axolotl handshake.
1969 *
1970 * @param t Tunnel this message came on.
1971 * @param msg Key eXchange Pong message.
1972 */
1973static void
1974handle_kx_ax (struct CadetTunnel *t, const struct GNUNET_CADET_AX_KX *msg)
1975{
1976 struct CadetTunnelAxolotl *ax;
1977 struct GNUNET_HashCode key_material[3];
1978 struct GNUNET_CRYPTO_SymmetricSessionKey keys[5];
1979 const char salt[] = "CADET Axolotl salt";
1980 const struct GNUNET_PeerIdentity *pid;
1981 int am_I_alice;
1982
1983 LOG (GNUNET_ERROR_TYPE_INFO, "<== { AX_KX} on %s\n", GCT_2s (t));
1984
1985 if (NULL == t->ax)
1986 {
1987 /* Something is wrong if ax is NULL. Whose fault it is? */
1988 GNUNET_break (CADET_Axolotl == t->enc_type);
1989 return;
1990 }
1991 ax = t->ax;
1992
1993 pid = GCT_get_destination (t);
1994 if (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
1995 am_I_alice = GNUNET_YES;
1996 else if (0 < GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
1997 am_I_alice = GNUNET_NO;
1998 else
1999 {
2000 GNUNET_break_op (0);
2001 return;
2002 }
2003
2004 if (0 != (GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY & ntohl (msg->flags)))
2005 {
2006 if (NULL != t->rekey_task)
2007 {
2008 GNUNET_SCHEDULER_cancel (t->rekey_task);
2009 t->rekey_task = NULL;
2010 }
2011 GCT_send_ax_kx (t, GNUNET_NO);
2012 }
2013
2014 if (0 == memcmp (&ax->DHRr, &msg->ratchet_key, sizeof(msg->ratchet_key)))
2015 {
2016 LOG (GNUNET_ERROR_TYPE_INFO, " known ratchet key, exit\n");
2017 return;
2018 }
2019
2020 LOG (GNUNET_ERROR_TYPE_INFO, " is Alice? %s\n", am_I_alice ? "YES" : "NO");
2021
2022 ax->DHRr = msg->ratchet_key;
2023
2024 /* ECDH A B0 */
2025 if (GNUNET_YES == am_I_alice)
2026 {
2027 GNUNET_CRYPTO_eddsa_ecdh (id_key, /* A */
2028 &msg->ephemeral_key, /* B0 */
2029 &key_material[0]);
2030 }
2031 else
2032 {
2033 GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0, /* B0 */
2034 &pid->public_key, /* A */
2035 &key_material[0]);
2036 }
2037
2038 /* ECDH A0 B */
2039 if (GNUNET_YES == am_I_alice)
2040 {
2041 GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0, /* A0 */
2042 &pid->public_key, /* B */
2043 &key_material[1]);
2044 }
2045 else
2046 {
2047 GNUNET_CRYPTO_eddsa_ecdh (id_key, /* A */
2048 &msg->ephemeral_key, /* B0 */
2049 &key_material[1]);
2050
2051
2052 }
2053
2054 /* ECDH A0 B0 */
2055 /* (This is the triple-DH, we could probably safely skip this,
2056 as A0/B0 are already in the key material.) */
2057 GNUNET_CRYPTO_ecc_ecdh (ax->kx_0, /* A0 or B0 */
2058 &msg->ephemeral_key, /* B0 or A0 */
2059 &key_material[2]);
2060
2061 #if DUMP_KEYS_TO_STDERR
2062 {
2063 unsigned int i;
2064 for (i = 0; i < 3; i++)
2065 LOG (GNUNET_ERROR_TYPE_INFO, "km[%u]: %s\n",
2066 i, GNUNET_h2s (&key_material[i]));
2067 }
2068 #endif
2069
2070 /* KDF */
2071 GNUNET_CRYPTO_kdf (keys, sizeof (keys),
2072 salt, sizeof (salt),
2073 &key_material, sizeof (key_material), NULL);
2074
2075 if (0 == memcmp (&ax->RK, &keys[0], sizeof(ax->RK)))
2076 {
2077 LOG (GNUNET_ERROR_TYPE_INFO, " known handshake key, exit\n");
2078 return;
2079 }
2080 ax->RK = keys[0];
2081 if (GNUNET_YES == am_I_alice)
2082 {
2083 ax->HKr = keys[1];
2084 ax->NHKs = keys[2];
2085 ax->NHKr = keys[3];
2086 ax->CKr = keys[4];
2087 ax->ratchet_flag = GNUNET_YES;
2088 }
2089 else
2090 {
2091 ax->HKs = keys[1];
2092 ax->NHKr = keys[2];
2093 ax->NHKs = keys[3];
2094 ax->CKs = keys[4];
2095 ax->ratchet_flag = GNUNET_NO;
2096 ax->ratchet_allowed = GNUNET_NO;
2097 ax->ratchet_counter = 0;
2098 ax->ratchet_expiration =
2099 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), ratchet_time);
2100 }
2101 ax->PNs = 0;
2102 ax->Nr = 0;
2103 ax->Ns = 0;
2104 GCT_change_estate (t, CADET_TUNNEL_KEY_PING);
2105 send_queued_data (t);
2106}
2107
2108
2109/**
2110 * Demultiplex by message type and call appropriate handler for a message 1866 * Demultiplex by message type and call appropriate handler for a message
2111 * towards a channel of a local tunnel. 1867 * towards a channel of a local tunnel.
2112 * 1868 *
@@ -2175,40 +1931,28 @@ handle_decrypted (struct CadetTunnel *t,
2175/******************************************************************************/ 1931/******************************************************************************/
2176/******************************** API ***********************************/ 1932/******************************** API ***********************************/
2177/******************************************************************************/ 1933/******************************************************************************/
1934
2178/** 1935/**
2179 * Decrypt old format and demultiplex by message type. Call appropriate handler 1936 * Decrypt and process an encrypted message.
2180 * for a message towards a channel of a local tunnel. 1937 *
1938 * Calls the appropriate handler for a message in a channel of a local tunnel.
2181 * 1939 *
2182 * @param t Tunnel this message came on. 1940 * @param t Tunnel this message came on.
2183 * @param msg Message header. 1941 * @param msg Message header.
2184 */ 1942 */
2185void 1943void
2186GCT_handle_encrypted (struct CadetTunnel *t, 1944GCT_handle_encrypted (struct CadetTunnel *t,
2187 const struct GNUNET_MessageHeader *msg) 1945 const struct GNUNET_CADET_Encrypted *msg)
2188{ 1946{
2189 uint16_t size = ntohs (msg->size); 1947 uint16_t size = ntohs (msg->header.size);
2190 char cbuf [size]; 1948 char cbuf [size];
2191 int decrypted_size; 1949 int decrypted_size;
2192 uint16_t type;
2193 const struct GNUNET_MessageHeader *msgh; 1950 const struct GNUNET_MessageHeader *msgh;
2194 unsigned int off; 1951 unsigned int off;
2195 1952
2196 type = ntohs (msg->type); 1953 GNUNET_STATISTICS_update (stats, "# received encrypted", 1, GNUNET_NO);
2197 switch (type)
2198 {
2199 case GNUNET_MESSAGE_TYPE_CADET_AX:
2200 {
2201 const struct GNUNET_CADET_AX *emsg;
2202 1954
2203 GNUNET_STATISTICS_update (stats, "# received Axolotl", 1, GNUNET_NO); 1955 decrypted_size = t_ax_decrypt_and_validate (t, cbuf, msg, size);
2204 emsg = (const struct GNUNET_CADET_AX *) msg;
2205 decrypted_size = t_ax_decrypt_and_validate (t, cbuf, emsg, size);
2206 }
2207 break;
2208 default:
2209 GNUNET_break_op (0);
2210 return;
2211 }
2212 1956
2213 if (-1 == decrypted_size) 1957 if (-1 == decrypted_size)
2214 { 1958 {
@@ -2250,35 +1994,144 @@ GCT_handle_encrypted (struct CadetTunnel *t,
2250 1994
2251 1995
2252/** 1996/**
2253 * Demultiplex an encapsulated KX message by message type. 1997 * Handle a Key eXchange message.
2254 * 1998 *
2255 * @param t Tunnel on which the message came. 1999 * @param t Tunnel on which the message came.
2256 * @param message Payload of KX message. 2000 * @param msg KX message itself.
2257 *
2258 * FIXME: not needed anymore
2259 * - substitute with call to kx_ax
2260 * - eliminate encapsulation
2261 */ 2001 */
2262void 2002void
2263GCT_handle_kx (struct CadetTunnel *t, 2003GCT_handle_kx (struct CadetTunnel *t,
2264 const struct GNUNET_MessageHeader *message) 2004 const struct GNUNET_CADET_KX *msg)
2265{ 2005{
2266 uint16_t type; 2006 struct CadetTunnelAxolotl *ax;
2267 char buf[256]; 2007 struct GNUNET_HashCode key_material[3];
2008 struct GNUNET_CRYPTO_SymmetricSessionKey keys[5];
2009 const char salt[] = "CADET Axolotl salt";
2010 const struct GNUNET_PeerIdentity *pid;
2011 int am_I_alice;
2268 2012
2269 type = ntohs (message->type); 2013 LOG (GNUNET_ERROR_TYPE_INFO, "<== { KX} on %s\n", GCT_2s (t));
2270 LOG (GNUNET_ERROR_TYPE_DEBUG, "kx message received: %s\n", GC_m2s (type)); 2014
2271 sprintf (buf, "# received KX of type %hu (%s)", type, GC_m2s (type)); 2015 if (NULL == t->ax)
2272 GNUNET_STATISTICS_update (stats, buf, 1, GNUNET_NO);
2273 switch (type)
2274 { 2016 {
2275 case GNUNET_MESSAGE_TYPE_CADET_AX_KX: 2017 /* Something is wrong if ax is NULL. Whose fault it is? */
2276 handle_kx_ax (t, (const struct GNUNET_CADET_AX_KX *) message); 2018 return;
2277 break; 2019 }
2278 default: 2020 ax = t->ax;
2279 GNUNET_break_op (0); 2021
2280 LOG (GNUNET_ERROR_TYPE_WARNING, "kx message %s unknown\n", GC_m2s (type)); 2022 pid = GCT_get_destination (t);
2023 if (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
2024 am_I_alice = GNUNET_YES;
2025 else if (0 < GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
2026 am_I_alice = GNUNET_NO;
2027 else
2028 {
2029 GNUNET_break_op (0);
2030 return;
2031 }
2032
2033 if (0 != (GNUNET_CADET_KX_FLAG_FORCE_REPLY & ntohl (msg->flags)))
2034 {
2035 if (NULL != t->rekey_task)
2036 {
2037 GNUNET_SCHEDULER_cancel (t->rekey_task);
2038 t->rekey_task = NULL;
2039 }
2040 GCT_send_kx (t, GNUNET_NO);
2041 }
2042
2043 if (0 == memcmp (&ax->DHRr, &msg->ratchet_key, sizeof(msg->ratchet_key)))
2044 {
2045 LOG (GNUNET_ERROR_TYPE_INFO, " known ratchet key, exit\n");
2046 return;
2047 }
2048
2049 LOG (GNUNET_ERROR_TYPE_INFO, " is Alice? %s\n", am_I_alice ? "YES" : "NO");
2050
2051 ax->DHRr = msg->ratchet_key;
2052
2053 /* ECDH A B0 */
2054 if (GNUNET_YES == am_I_alice)
2055 {
2056 GNUNET_CRYPTO_eddsa_ecdh (id_key, /* A */
2057 &msg->ephemeral_key, /* B0 */
2058 &key_material[0]);
2059 }
2060 else
2061 {
2062 GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0, /* B0 */
2063 &pid->public_key, /* A */
2064 &key_material[0]);
2065 }
2066
2067 /* ECDH A0 B */
2068 if (GNUNET_YES == am_I_alice)
2069 {
2070 GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0, /* A0 */
2071 &pid->public_key, /* B */
2072 &key_material[1]);
2073 }
2074 else
2075 {
2076 GNUNET_CRYPTO_eddsa_ecdh (id_key, /* A */
2077 &msg->ephemeral_key, /* B0 */
2078 &key_material[1]);
2079
2080
2081 }
2082
2083 /* ECDH A0 B0 */
2084 /* (This is the triple-DH, we could probably safely skip this,
2085 as A0/B0 are already in the key material.) */
2086 GNUNET_CRYPTO_ecc_ecdh (ax->kx_0, /* A0 or B0 */
2087 &msg->ephemeral_key, /* B0 or A0 */
2088 &key_material[2]);
2089
2090 #if DUMP_KEYS_TO_STDERR
2091 {
2092 unsigned int i;
2093 for (i = 0; i < 3; i++)
2094 LOG (GNUNET_ERROR_TYPE_INFO, "km[%u]: %s\n",
2095 i, GNUNET_h2s (&key_material[i]));
2096 }
2097 #endif
2098
2099 /* KDF */
2100 GNUNET_CRYPTO_kdf (keys, sizeof (keys),
2101 salt, sizeof (salt),
2102 &key_material, sizeof (key_material), NULL);
2103
2104 if (0 == memcmp (&ax->RK, &keys[0], sizeof(ax->RK)))
2105 {
2106 LOG (GNUNET_ERROR_TYPE_INFO, " known handshake key, exit\n");
2107 return;
2108 }
2109 ax->RK = keys[0];
2110 if (GNUNET_YES == am_I_alice)
2111 {
2112 ax->HKr = keys[1];
2113 ax->NHKs = keys[2];
2114 ax->NHKr = keys[3];
2115 ax->CKr = keys[4];
2116 ax->ratchet_flag = GNUNET_YES;
2117 }
2118 else
2119 {
2120 ax->HKs = keys[1];
2121 ax->NHKr = keys[2];
2122 ax->NHKs = keys[3];
2123 ax->CKs = keys[4];
2124 ax->ratchet_flag = GNUNET_NO;
2125 ax->ratchet_allowed = GNUNET_NO;
2126 ax->ratchet_counter = 0;
2127 ax->ratchet_expiration =
2128 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), ratchet_time);
2281 } 2129 }
2130 ax->PNs = 0;
2131 ax->Nr = 0;
2132 ax->Ns = 0;
2133 GCT_change_estate (t, CADET_TUNNEL_KEY_PING);
2134 send_queued_data (t);
2282} 2135}
2283 2136
2284/** 2137/**
@@ -2296,7 +2149,7 @@ GCT_init (const struct GNUNET_CONFIGURATION_Handle *c,
2296 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); 2149 LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
2297 2150
2298 expected_overhead = 0; 2151 expected_overhead = 0;
2299 expected_overhead += sizeof (struct GNUNET_CADET_AX); 2152 expected_overhead += sizeof (struct GNUNET_CADET_Encrypted);
2300 expected_overhead += sizeof (struct GNUNET_CADET_Data); 2153 expected_overhead += sizeof (struct GNUNET_CADET_Data);
2301 expected_overhead += sizeof (struct GNUNET_CADET_ACK); 2154 expected_overhead += sizeof (struct GNUNET_CADET_ACK);
2302 GNUNET_assert (GNUNET_CONSTANTS_CADET_P2P_OVERHEAD == expected_overhead); 2155 GNUNET_assert (GNUNET_CONSTANTS_CADET_P2P_OVERHEAD == expected_overhead);
@@ -2396,8 +2249,8 @@ GCT_change_cstate (struct CadetTunnel* t, enum CadetTunnelCState cstate)
2396 } 2249 }
2397 else if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate) 2250 else if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate)
2398 { 2251 {
2399 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered kx\n"); 2252 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered KX\n");
2400 GCT_send_ax_kx (t, GNUNET_NO); 2253 GCT_send_kx (t, GNUNET_NO);
2401 } 2254 }
2402 else 2255 else
2403 { 2256 {
@@ -3346,34 +3199,55 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3346 3199
3347 3200
3348/** 3201/**
3349 * Send an Axolotl KX message. 3202 * Send a KX message.
3350 * 3203 *
3351 * @param t Tunnel on which to send it. 3204 * @param t Tunnel on which to send it.
3352 * @param force_reply Force the other peer to reply with a KX message. 3205 * @param force_reply Force the other peer to reply with a KX message.
3353 */ 3206 */
3354void 3207void
3355GCT_send_ax_kx (struct CadetTunnel *t, int force_reply) 3208GCT_send_kx (struct CadetTunnel *t, int force_reply)
3356{ 3209{
3357 struct GNUNET_CADET_AX_KX msg; 3210 struct CadetConnection *c;
3358 enum GNUNET_CADET_AX_KX_Flags flags; 3211 struct GNUNET_CADET_KX msg;
3212 enum GNUNET_CADET_KX_Flags flags;
3359 3213
3360 LOG (GNUNET_ERROR_TYPE_INFO, "==> { AX_KX} on %s\n", GCT_2s (t)); 3214 LOG (GNUNET_ERROR_TYPE_INFO, "==> { KX} on %s\n", GCT_2s (t));
3361 if (NULL != t->ephm_h) 3215 if (NULL != t->ephm_h)
3362 { 3216 {
3363 LOG (GNUNET_ERROR_TYPE_INFO, " already queued\n"); 3217 LOG (GNUNET_ERROR_TYPE_INFO, " already queued, nop\n");
3218 return;
3219 }
3220
3221 /* Avoid loopback. */
3222 if (GCT_is_loopback (t))
3223 {
3224 GNUNET_break (0);
3225 return;
3226 }
3227 c = tunnel_get_connection (t);
3228 if (NULL == c)
3229 {
3230 if (NULL == t->destroy_task && CADET_TUNNEL_READY == t->cstate)
3231 {
3232 GNUNET_break (0);
3233 GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
3234 }
3364 return; 3235 return;
3365 } 3236 }
3366 3237
3367 msg.header.size = htons (sizeof (msg)); 3238 msg.header.size = htons (sizeof (msg));
3368 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_AX_KX); 3239 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX);
3369 flags = GNUNET_CADET_AX_KX_FLAG_NONE; 3240 flags = GNUNET_CADET_KX_FLAG_NONE;
3370 if (force_reply) 3241 if (GNUNET_YES == force_reply)
3371 flags |= GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY; 3242 flags |= GNUNET_CADET_KX_FLAG_FORCE_REPLY;
3372 msg.flags = htonl (flags); 3243 msg.flags = htonl (flags);
3244 msg.cid = *GCC_get_id (c);
3373 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->kx_0, &msg.ephemeral_key); 3245 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->kx_0, &msg.ephemeral_key);
3374 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->DHRs, &msg.ratchet_key); 3246 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->DHRs, &msg.ratchet_key);
3375 3247
3376 t->ephm_h = send_kx (t, &msg.header); 3248 t->ephm_h = GCC_send_prebuilt_message (&msg.header, 0, 0,
3249 c, GCC_is_origin (c, GNUNET_YES),
3250 GNUNET_YES, &ephm_sent, t);
3377 if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate) 3251 if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate)
3378 GCT_change_estate (t, CADET_TUNNEL_KEY_SENT); 3252 GCT_change_estate (t, CADET_TUNNEL_KEY_SENT);
3379} 3253}
@@ -3532,8 +3406,8 @@ ax_debug (const struct CadetTunnelAxolotl *ax, enum GNUNET_ErrorType level)
3532void 3406void
3533GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level) 3407GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level)
3534{ 3408{
3535 struct CadetTChannel *iterch; 3409 struct CadetTChannel *iter_ch;
3536 struct CadetTConnection *iterc; 3410 struct CadetTConnection *iter_c;
3537 int do_log; 3411 int do_log;
3538 3412
3539 do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK), 3413 do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK),
@@ -3546,33 +3420,20 @@ GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level)
3546 LOG2 (level, "TTT cstate %s, estate %s\n", 3420 LOG2 (level, "TTT cstate %s, estate %s\n",
3547 cstate2s (t->cstate), estate2s (t->estate)); 3421 cstate2s (t->cstate), estate2s (t->estate));
3548#if DUMP_KEYS_TO_STDERR 3422#if DUMP_KEYS_TO_STDERR
3549 if (CADET_Axolotl == t->enc_type) 3423 ax_debug (t->ax, level);
3550 {
3551 ax_debug (t->ax, level);
3552 }
3553 else
3554 {
3555 LOG2 (level, "TTT peers EPHM:\t %s\n",
3556 GNUNET_i2s ((struct GNUNET_PeerIdentity *) &t->peers_ephemeral_key));
3557 LOG2 (level, "TTT ENC key:\t %s\n",
3558 GNUNET_i2s ((struct GNUNET_PeerIdentity *) &t->e_key));
3559 LOG2 (level, "TTT DEC key:\t %s\n",
3560 GNUNET_i2s ((struct GNUNET_PeerIdentity *) &t->d_key));
3561 }
3562#endif 3424#endif
3563 LOG2 (level, "TTT tq_head %p, tq_tail %p\n", t->tq_head, t->tq_tail); 3425 LOG2 (level, "TTT tq_head %p, tq_tail %p\n", t->tq_head, t->tq_tail);
3564 LOG2 (level, "TTT destroy %p\n", t->destroy_task); 3426 LOG2 (level, "TTT destroy %p\n", t->destroy_task);
3565
3566 LOG2 (level, "TTT channels:\n"); 3427 LOG2 (level, "TTT channels:\n");
3567 for (iterch = t->channel_head; NULL != iterch; iterch = iterch->next) 3428 for (iter_ch = t->channel_head; NULL != iter_ch; iter_ch = iter_ch->next)
3568 { 3429 {
3569 GCCH_debug (iterch->ch, level); 3430 GCCH_debug (iter_ch->ch, level);
3570 } 3431 }
3571 3432
3572 LOG2 (level, "TTT connections:\n"); 3433 LOG2 (level, "TTT connections:\n");
3573 for (iterc = t->connection_head; NULL != iterc; iterc = iterc->next) 3434 for (iter_c = t->connection_head; NULL != iter_c; iter_c = iter_c->next)
3574 { 3435 {
3575 GCC_debug (iterc->c, level); 3436 GCC_debug (iter_c->c, level);
3576 } 3437 }
3577 3438
3578 LOG2 (level, "TTT DEBUG TUNNEL END\n"); 3439 LOG2 (level, "TTT DEBUG TUNNEL END\n");
@@ -3636,3 +3497,4 @@ GCT_iterate_channels (struct CadetTunnel *t, GCT_chan_iter iter, void *cls)
3636 for (cht = t->channel_head; NULL != cht; cht = cht->next) 3497 for (cht = t->channel_head; NULL != cht; cht = cht->next)
3637 iter (cls, cht->ch); 3498 iter (cls, cht->ch);
3638} 3499}
3500
diff --git a/src/cadet/gnunet-service-cadet_tunnel.h b/src/cadet/gnunet-service-cadet_tunnel.h
index 8d65cbebd..e3ca57e9c 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.h
+++ b/src/cadet/gnunet-service-cadet_tunnel.h
@@ -295,26 +295,27 @@ GCT_get_channel (struct CadetTunnel *t, CADET_ChannelNumber chid);
295 295
296 296
297/** 297/**
298 * Decrypt and demultiplex by message type. Call appropriate handler 298 * Decrypt and process an encrypted message.
299 * for a message towards a channel of a local tunnel. 299 *
300 * Calls the appropriate handler for a message in a channel of a local tunnel.
300 * 301 *
301 * @param t Tunnel this message came on. 302 * @param t Tunnel this message came on.
302 * @param msg Message header. 303 * @param msg Message header.
303 */ 304 */
304void 305void
305GCT_handle_encrypted (struct CadetTunnel *t, 306GCT_handle_encrypted (struct CadetTunnel *t,
306 const struct GNUNET_MessageHeader *msg); 307 const struct GNUNET_CADET_Encrypted *msg);
307 308
308 309
309/** 310/**
310 * Demultiplex an encapsulated KX message by message type. 311 * Handle a Key eXchange message.
311 * 312 *
312 * @param t Tunnel on which the message came. 313 * @param t Tunnel on which the message came.
313 * @param message KX message itself. 314 * @param msg KX message itself.
314 */ 315 */
315void 316void
316GCT_handle_kx (struct CadetTunnel *t, 317GCT_handle_kx (struct CadetTunnel *t,
317 const struct GNUNET_MessageHeader *message); 318 const struct GNUNET_CADET_KX *msg);
318 319
319 320
320/** 321/**
@@ -494,13 +495,13 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
494 495
495 496
496/** 497/**
497 * Send an Axolotl KX message. 498 * Send a KX message.
498 * 499 *
499 * @param t Tunnel on which to send it. 500 * @param t Tunnel on which to send it.
500 * @param force_reply Force the other peer to reply with a KX message. 501 * @param force_reply Force the other peer to reply with a KX message.
501 */ 502 */
502void 503void
503GCT_send_ax_kx (struct CadetTunnel *t, int force_reply); 504GCT_send_kx (struct CadetTunnel *t, int force_reply);
504 505
505 506
506/** 507/**
diff --git a/src/include/gnunet_constants.h b/src/include/gnunet_constants.h
index a40354fb5..ef9b27318 100644
--- a/src/include/gnunet_constants.h
+++ b/src/include/gnunet_constants.h
@@ -127,7 +127,7 @@ extern "C"
127 127
128/** 128/**
129 * Size of the CADET message overhead: 129 * Size of the CADET message overhead:
130 * + sizeof (struct GNUNET_CADET_AX) 130 * = sizeof (struct GNUNET_CADET_Encrypted)
131 * + sizeof (struct GNUNET_CADET_Data) 131 * + sizeof (struct GNUNET_CADET_Data)
132 * + sizeof (struct GNUNET_CADET_ACK)) 132 * + sizeof (struct GNUNET_CADET_ACK))
133 * 133 *
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index ea94645c5..9cb553282 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -2610,77 +2610,82 @@ extern "C"
2610/*******************************************************************************/ 2610/*******************************************************************************/
2611 2611
2612 2612
2613/******************************************************************************* 2613/******************************************************************************/
2614 * CADET message types 2614/*********************************** CADET **********************************/
2615 ******************************************************************************/ 2615/******************************************************************************/
2616 2616/* CADET: message types 1000-1059
2617/** 2617 * 1000-1009 Connection-level Messages
2618 * Type of message used to transport messages throug a CADET-tunnel (LEGACY) 2618 * 1010-1019 Channel-level Messages
2619 * 1020-1029 Local Client-Service
2620 * 1030-1039 Local Service Monitoring
2621 * 1040-1049 Application Data
2622 * 1050-1059 Reserved
2619 */ 2623 */
2620#define GNUNET_MESSAGE_TYPE_CADET 1000
2621 2624
2622/** 2625/******************************** Connection ********************************/
2623 * Type of message used to send another peer which messages we want to receive
2624 * through a cadet-tunnel (LEGACY)
2625 */
2626#define GNUNET_MESSAGE_TYPE_CADET_HELLO 1001
2627 2626
2628/** 2627/**
2629 * Request the creation of a connection 2628 * Request the creation of a connection
2630 */ 2629 */
2631#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE 1002 2630#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE 1000
2632 2631
2633/** 2632/**
2634 * Send origin an ACK that the connection is complete 2633 * Send origin an ACK that the connection is complete
2635 */ 2634 */
2636#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK 1003 2635#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK 1001
2637 2636
2638/** 2637/**
2639 * Notify that a connection is no longer valid 2638 * Notify that a connection is no longer valid
2640 */ 2639 */
2641#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN 1004 2640#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN 1002
2641
2642/**
2643 * Request the destuction of a connection
2644 */
2645#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY 1003
2642 2646
2643/** 2647/**
2644 * At some point, the route will spontaneously change TODO 2648 * At some point, the route will spontaneously change TODO
2645 */ 2649 */
2646#define GNUNET_MESSAGE_TYPE_CADET_PATH_CHANGED 1005 2650#define GNUNET_MESSAGE_TYPE_CADET_PATH_CHANGED 1004
2647 2651
2648/** 2652/**
2649 * Payload data (usually inside a encrypted tunnel). 2653 * Hop-by-hop, connection dependent ACK.
2650 */ 2654 */
2651#define GNUNET_MESSAGE_TYPE_CADET_DATA 1006 2655#define GNUNET_MESSAGE_TYPE_CADET_ACK 1005
2652 2656
2653/** 2657/**
2654 * Confirm payload data end-to-end. 2658 * Poll for a hop-by-hop ACK.
2655 */ 2659 */
2656#define GNUNET_MESSAGE_TYPE_CADET_DATA_ACK 1007 2660#define GNUNET_MESSAGE_TYPE_CADET_POLL 1006
2657 2661
2658/** 2662/**
2659 * Key exchange encapsulation. 2663 * Key exchange encapsulation.
2660 */ 2664 */
2661#define GNUNET_MESSAGE_TYPE_CADET_KX 1008 2665#define GNUNET_MESSAGE_TYPE_CADET_KX 1007
2662 2666
2663/** 2667/**
2664 * Request the destuction of a connection 2668 * Axolotl encrypted data.
2665 */ 2669 */
2666#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY 1009 2670#define GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED 1008
2671
2672/********************************** Channel *********************************/
2667 2673
2668/** 2674/**
2669 * Hop-by-hop, connection dependent ACK. 2675 * Payload data (inside an encrypted tunnel).
2670 */ 2676 */
2671#define GNUNET_MESSAGE_TYPE_CADET_ACK 1010 2677#define GNUNET_MESSAGE_TYPE_CADET_DATA 1010
2672 2678
2673/** 2679/**
2674 * Poll for a hop-by-hop ACK. 2680 * Confirm payload data end-to-end.
2675 */ 2681 */
2676#define GNUNET_MESSAGE_TYPE_CADET_POLL 1011 2682#define GNUNET_MESSAGE_TYPE_CADET_DATA_ACK 1011
2677 2683
2678/** 2684/**
2679 * Announce connection is still alive (direction sensitive). 2685 * Announce connection is still alive (direction sensitive).
2680 */ 2686 */
2681#define GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE 1012 2687#define GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE 1012
2682 2688
2683
2684/** 2689/**
2685 * Ask the cadet service to create a new channel. 2690 * Ask the cadet service to create a new channel.
2686 */ 2691 */
@@ -2701,86 +2706,89 @@ extern "C"
2701 */ 2706 */
2702#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK 1016 2707#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK 1016
2703 2708
2704/** 2709/*********************************** Local **********************************/
2705 * Axolotl key exchange.
2706 */
2707#define GNUNET_MESSAGE_TYPE_CADET_AX_KX 1017
2708
2709/**
2710 * Axolotl encrypted data.
2711 */
2712#define GNUNET_MESSAGE_TYPE_CADET_AX 1018
2713 2710
2714/** 2711/**
2715 * Payload client <-> service 2712 * Payload client <-> service
2716 */ 2713 */
2717#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA 1019 2714#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA 1020
2718 2715
2719/** 2716/**
2720 * Local ACK for data. 2717 * Local ACK for data.
2721 */ 2718 */
2722#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK 1020 2719#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK 1021
2723 2720
2724/** 2721/**
2725 * Start listening on a port. 2722 * Start listening on a port.
2726 */ 2723 */
2727#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN 1021 2724#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN 1022
2728 2725
2729/** 2726/**
2730 * Stop listening on a port. 2727 * Stop listening on a port.
2731 */ 2728 */
2732#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE 1022 2729#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE 1023
2730
2731/********************************** Monitor *********************************/
2732
2733 2733
2734/** 2734/**
2735 * Local information about all channels of service. 2735 * Local information about all channels of service.
2736 */ 2736 */
2737#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNELS 1023 2737#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNELS 1030
2738 2738
2739/** 2739/**
2740 * Local information of service about a specific channel. 2740 * Local information of service about a specific channel.
2741 */ 2741 */
2742#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL 1024 2742#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL 1031
2743 2743
2744/** 2744/**
2745 * Local information about all tunnels of service. 2745 * Local information about all tunnels of service.
2746 */ 2746 */
2747#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS 1025 2747#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS 1032
2748 2748
2749/** 2749/**
2750 * Local information of service about a specific tunnel. 2750 * Local information of service about a specific tunnel.
2751 */ 2751 */
2752#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL 1026 2752#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL 1033
2753 2753
2754/** 2754/**
2755 * Local information about all connections of service. 2755 * Local information about all connections of service.
2756 */ 2756 */
2757#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTIONS 1027 2757#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTIONS 1034
2758 2758
2759/** 2759/**
2760 * Local information of service about a specific connection. 2760 * Local information of service about a specific connection.
2761 */ 2761 */
2762#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTION 1028 2762#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTION 1035
2763 2763
2764/** 2764/**
2765 * Local information about all peers known to the service. 2765 * Local information about all peers known to the service.
2766 */ 2766 */
2767#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS 1029 2767#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS 1036
2768 2768
2769/** 2769/**
2770 * Local information of service about a specific peer. 2770 * Local information of service about a specific peer.
2771 */ 2771 */
2772#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER 1030 2772#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER 1037
2773 2773
2774/** 2774/**
2775 * Traffic (net-cat style) used by the Command Line Interface. 2775 * Debug request.
2776 */ 2776 */
2777#define GNUNET_MESSAGE_TYPE_CADET_CLI 1031 2777#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP 1038
2778
2779/******************************** Application *******************************/
2778 2780
2779/** 2781/**
2780 * Debug request. 2782 * Traffic (net-cat style) used by the Command Line Interface.
2781 */ 2783 */
2782#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP 1032 2784#define GNUNET_MESSAGE_TYPE_CADET_CLI 1040
2785
2786/******************************************************************************/
2787
2783 2788
2789/******************************************************************************/
2790/************************************* NAT **********************************/
2791/******************************************************************************/
2784 2792
2785/** 2793/**
2786 * Message to ask NAT service to register a client. 2794 * Message to ask NAT service to register a client.