aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2015-07-15 11:45:11 +0000
committerBart Polot <bart@net.in.tum.de>2015-07-15 11:45:11 +0000
commit966b264292fa54ea2fb1d43360708c98b6bc548d (patch)
tree7e73e24b8bd382d29a0e02b4a92661c186788be5 /src
parent15c89f51a855319e027019f762fc8d51ddf06fef (diff)
downloadgnunet-966b264292fa54ea2fb1d43360708c98b6bc548d.tar.gz
gnunet-966b264292fa54ea2fb1d43360708c98b6bc548d.zip
- fix end of kx condition to reception of valid payload only
Diffstat (limited to 'src')
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index de0d87fca..11016671e 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -2037,7 +2037,11 @@ ax_kx_resend (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2037 return; 2037 return;
2038 2038
2039 if (CADET_TUNNEL_KEY_OK == t->estate) 2039 if (CADET_TUNNEL_KEY_OK == t->estate)
2040 {
2041 /* Should have been canceled on estate change */
2042 GNUNET_break (0);
2040 return; 2043 return;
2044 }
2041 2045
2042 GCT_send_ax_kx (t, GNUNET_YES); 2046 GCT_send_ax_kx (t, GNUNET_YES);
2043} 2047}
@@ -2066,7 +2070,7 @@ ephm_sent (void *cls,
2066 if (CADET_TUNNEL_KEY_OK == t->estate) 2070 if (CADET_TUNNEL_KEY_OK == t->estate)
2067 return; 2071 return;
2068 2072
2069 if (CADET_Axolotl == t->enc_type && CADET_TUNNEL_KEY_OK != t->estate) 2073 if (CADET_Axolotl == t->enc_type)
2070 { 2074 {
2071 if (NULL != t->rekey_task) 2075 if (NULL != t->rekey_task)
2072 { 2076 {
@@ -2973,7 +2977,6 @@ handle_kx_ax (struct CadetTunnel *t, const struct GNUNET_CADET_AX_KX *msg)
2973 ax->ratchet_expiration = 2977 ax->ratchet_expiration =
2974 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), ratchet_time); 2978 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), ratchet_time);
2975 } 2979 }
2976 GCT_change_estate (t, CADET_TUNNEL_KEY_OK);
2977} 2980}
2978 2981
2979 2982
@@ -3039,6 +3042,7 @@ handle_decrypted (struct CadetTunnel *t,
3039 } 3042 }
3040} 3043}
3041 3044
3045
3042/******************************************************************************/ 3046/******************************************************************************/
3043/******************************** API ***********************************/ 3047/******************************** API ***********************************/
3044/******************************************************************************/ 3048/******************************************************************************/
@@ -3086,6 +3090,7 @@ GCT_handle_encrypted (struct CadetTunnel *t,
3086 GNUNET_break_op (0); 3090 GNUNET_break_op (0);
3087 return; 3091 return;
3088 } 3092 }
3093
3089 if (-1 == decrypted_size) 3094 if (-1 == decrypted_size)
3090 { 3095 {
3091 GNUNET_break_op (0); 3096 GNUNET_break_op (0);
@@ -3093,6 +3098,7 @@ GCT_handle_encrypted (struct CadetTunnel *t,
3093 GCT_debug (t, GNUNET_ERROR_TYPE_WARNING); 3098 GCT_debug (t, GNUNET_ERROR_TYPE_WARNING);
3094 return; 3099 return;
3095 } 3100 }
3101 GCT_change_estate (t, CADET_TUNNEL_KEY_OK);
3096 3102
3097 /* FIXME: this is bad, as the structs returned from 3103 /* FIXME: this is bad, as the structs returned from
3098 this loop may be unaligned, see util's MST for 3104 this loop may be unaligned, see util's MST for
@@ -3305,6 +3311,8 @@ GCT_change_cstate (struct CadetTunnel* t, enum CadetTunnelCState cstate)
3305/** 3311/**
3306 * Change the tunnel encryption state. 3312 * Change the tunnel encryption state.
3307 * 3313 *
3314 * If the encryption state changes to OK, stop the rekey task.
3315 *
3308 * @param t Tunnel whose encryption state to change, or NULL. 3316 * @param t Tunnel whose encryption state to change, or NULL.
3309 * @param state New encryption state. 3317 * @param state New encryption state.
3310 */ 3318 */
@@ -3323,11 +3331,16 @@ GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state)
3323 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s estate is now %s\n", 3331 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel %s estate is now %s\n",
3324 GCP_2s (t->peer), estate2s (t->estate)); 3332 GCP_2s (t->peer), estate2s (t->estate));
3325 3333
3326 /* Send queued data if enc state changes to OK */ 3334 if (CADET_TUNNEL_KEY_OK != old && CADET_TUNNEL_KEY_OK == t->estate)
3327 if (myid != GCP_get_short_id (t->peer) &&
3328 CADET_TUNNEL_KEY_OK != old && CADET_TUNNEL_KEY_OK == t->estate)
3329 { 3335 {
3330 send_queued_data (t); 3336 if (NULL != t->rekey_task)
3337 {
3338 GNUNET_SCHEDULER_cancel (t->rekey_task);
3339 t->rekey_task = NULL;
3340 }
3341 /* Send queued data if tunnel is not loopback */
3342 if (myid != GCP_get_short_id (t->peer))
3343 send_queued_data (t);
3331 } 3344 }
3332} 3345}
3333 3346