aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cadet/cadet_protocol.h5
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c69
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.h3
-rw-r--r--src/cadet/test_cadet.c2
4 files changed, 72 insertions, 7 deletions
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h
index bb23ce921..a51be3939 100644
--- a/src/cadet/cadet_protocol.h
+++ b/src/cadet/cadet_protocol.h
@@ -122,6 +122,11 @@ struct GNUNET_CADET_AX_KX
122 struct GNUNET_MessageHeader header; 122 struct GNUNET_MessageHeader header;
123 123
124 /** 124 /**
125 * Should the peer reply with its KX details?
126 */
127 uint32_t force_reply;
128
129 /**
125 * An EdDSA signature of the permanent ECDH key with the Peer's ID key. 130 * An EdDSA signature of the permanent ECDH key with the Peer's ID key.
126 */ 131 */
127 struct GNUNET_CRYPTO_EddsaSignature signature; 132 struct GNUNET_CRYPTO_EddsaSignature signature;
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index f0232fee2..cbbb26593 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -2008,6 +2008,29 @@ send_queued_data (struct CadetTunnel *t)
2008 2008
2009 2009
2010/** 2010/**
2011 * @brief Resend the AX KX until we complete the handshake.
2012 *
2013 * @param cls Closure (tunnel).
2014 * @param tc Task context.
2015 */
2016static void
2017ax_kx_resend (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2018{
2019 struct CadetTunnel *t = cls;
2020
2021 t->rekey_task = NULL;
2022
2023 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
2024 return;
2025
2026 if (CADET_TUNNEL_KEY_OK == t->estate)
2027 return;
2028
2029 GCT_send_ax_kx (t, GNUNET_YES);
2030}
2031
2032
2033/**
2011 * Callback called when a queued message is sent. 2034 * Callback called when a queued message is sent.
2012 * 2035 *
2013 * @param cls Closure. 2036 * @param cls Closure.
@@ -2018,15 +2041,31 @@ send_queued_data (struct CadetTunnel *t)
2018 */ 2041 */
2019static void 2042static void
2020ephm_sent (void *cls, 2043ephm_sent (void *cls,
2021 struct CadetConnection *c, 2044 struct CadetConnection *c,
2022 struct CadetConnectionQueue *q, 2045 struct CadetConnectionQueue *q,
2023 uint16_t type, int fwd, size_t size) 2046 uint16_t type, int fwd, size_t size)
2024{ 2047{
2025 struct CadetTunnel *t = cls; 2048 struct CadetTunnel *t = cls;
2026 LOG (GNUNET_ERROR_TYPE_DEBUG, "ephemeral sent %s\n", GC_m2s (type)); 2049 LOG (GNUNET_ERROR_TYPE_DEBUG, "ephemeral sent %s\n", GC_m2s (type));
2050
2027 t->ephm_h = NULL; 2051 t->ephm_h = NULL;
2052
2053 if (CADET_TUNNEL_KEY_OK == t->estate)
2054 return;
2055
2056 if (CADET_Axolotl == t->enc_type && CADET_TUNNEL_KEY_OK != t->estate)
2057 {
2058 if (NULL != t->rekey_task)
2059 {
2060 GNUNET_break (0);
2061 GNUNET_SCHEDULER_cancel (t->rekey_task);
2062 }
2063 t->rekey_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
2064 &ax_kx_resend, t);
2065 }
2028} 2066}
2029 2067
2068
2030/** 2069/**
2031 * Callback called when a queued message is sent. 2070 * Callback called when a queued message is sent.
2032 * 2071 *
@@ -2048,6 +2087,7 @@ pong_sent (void *cls,
2048 t->pong_h = NULL; 2087 t->pong_h = NULL;
2049} 2088}
2050 2089
2090
2051/** 2091/**
2052 * Sends key exchange message on a tunnel, choosing the best connection. 2092 * Sends key exchange message on a tunnel, choosing the best connection.
2053 * Should not be called on loopback tunnels. 2093 * Should not be called on loopback tunnels.
@@ -2663,6 +2703,17 @@ destroy_ax (struct CadetTunnel *t)
2663 2703
2664 GNUNET_free (t->ax); 2704 GNUNET_free (t->ax);
2665 t->ax = NULL; 2705 t->ax = NULL;
2706
2707 if (NULL != t->rekey_task)
2708 {
2709 GNUNET_SCHEDULER_cancel (t->rekey_task);
2710 t->rekey_task = NULL;
2711 }
2712 if (NULL != t->ephm_h)
2713 {
2714 GCC_cancel (t->ephm_h);
2715 t->ephm_h = NULL;
2716 }
2666} 2717}
2667 2718
2668 2719
@@ -2846,6 +2897,12 @@ handle_kx_ax (struct CadetTunnel *t, const struct GNUNET_CADET_AX_KX *msg)
2846 return; 2897 return;
2847 } 2898 }
2848 2899
2900 if (GNUNET_YES == ntohl (msg->force_reply))
2901 GCT_send_ax_kx (t, GNUNET_NO);
2902
2903 if (CADET_TUNNEL_KEY_OK == t->estate)
2904 return;
2905
2849 LOG (GNUNET_ERROR_TYPE_INFO, " is Alice? %s\n", am_I_alice ? "YES" : "NO"); 2906 LOG (GNUNET_ERROR_TYPE_INFO, " is Alice? %s\n", am_I_alice ? "YES" : "NO");
2850 2907
2851 ax = t->ax; 2908 ax = t->ax;
@@ -3228,7 +3285,7 @@ GCT_change_cstate (struct CadetTunnel* t, enum CadetTunnelCState cstate)
3228 else if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate) 3285 else if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate)
3229 { 3286 {
3230 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered kx\n"); 3287 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate triggered kx\n");
3231 GCT_send_ax_kx (t); 3288 GCT_send_ax_kx (t, GNUNET_NO);
3232 } 3289 }
3233 else 3290 else
3234 { 3291 {
@@ -4126,9 +4183,10 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
4126 * Send an Axolotl KX message. 4183 * Send an Axolotl KX message.
4127 * 4184 *
4128 * @param t Tunnel on which to send it. 4185 * @param t Tunnel on which to send it.
4186 * @param force_reply Force the other peer to reply with a KX message.
4129 */ 4187 */
4130void 4188void
4131GCT_send_ax_kx (struct CadetTunnel *t) 4189GCT_send_ax_kx (struct CadetTunnel *t, int force_reply)
4132{ 4190{
4133 struct GNUNET_CADET_AX_KX msg; 4191 struct GNUNET_CADET_AX_KX msg;
4134 4192
@@ -4141,6 +4199,7 @@ GCT_send_ax_kx (struct CadetTunnel *t)
4141 4199
4142 msg.header.size = htons (sizeof (msg)); 4200 msg.header.size = htons (sizeof (msg));
4143 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_AX_KX); 4201 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_AX_KX);
4202 msg.force_reply = htonl (force_reply);
4144 msg.permanent_key = ax_identity.permanent_key; 4203 msg.permanent_key = ax_identity.permanent_key;
4145 msg.purpose = ax_identity.purpose; 4204 msg.purpose = ax_identity.purpose;
4146 msg.signature = ax_identity.signature; 4205 msg.signature = ax_identity.signature;
diff --git a/src/cadet/gnunet-service-cadet_tunnel.h b/src/cadet/gnunet-service-cadet_tunnel.h
index 4bc7ca7da..8b3f26ff0 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.h
+++ b/src/cadet/gnunet-service-cadet_tunnel.h
@@ -446,9 +446,10 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
446 * Send an Axolotl KX message. 446 * Send an Axolotl KX message.
447 * 447 *
448 * @param t Tunnel on which to send it. 448 * @param t Tunnel on which to send it.
449 * @param force_reply Force the other peer to reply with a KX message.
449 */ 450 */
450void 451void
451GCT_send_ax_kx (struct CadetTunnel *t); 452GCT_send_ax_kx (struct CadetTunnel *t, int force_reply);
452 453
453/** 454/**
454 * Sends an already built and encrypted message on a tunnel, choosing the best 455 * Sends an already built and encrypted message on a tunnel, choosing the best
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index e37679bb7..98c920014 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -33,7 +33,7 @@
33/** 33/**
34 * How many messages to send 34 * How many messages to send
35 */ 35 */
36#define TOTAL_PACKETS 50 36#define TOTAL_PACKETS 500
37 37
38/** 38/**
39 * How long until we give up on connecting the peers? 39 * How long until we give up on connecting the peers?