From c54f0c24042fd60ab328f5b4c42eb5a758706925 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 25 Jul 2014 03:30:02 +0000 Subject: [PATCH] - if an "old_key" is not valid (for instance, at tunnel establishment), clear the context ASAP --- src/cadet/gnunet-service-cadet_tunnel.c | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index e0f8567e7..189c94ff8 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c @@ -410,6 +410,28 @@ is_ready (struct CadetTunnel *t) } +/** + * Check if a key is invalid (NULL pointer or all 0) + * + * @param key Key to check. + * + * @return #GNUNET_YES if key is null, #GNUNET_NO if exists and is not 0. + */ +static int +is_key_null (struct GNUNET_CRYPTO_SymmetricSessionKey *key) +{ + struct GNUNET_CRYPTO_SymmetricSessionKey null_key; + + if (NULL == key) + return GNUNET_YES; + + memset (&null_key, 0, sizeof (null_key)); + if (0 == memcmp (key, &null_key, sizeof (null_key))) + return GNUNET_YES; + return GNUNET_NO; +} + + /** * Ephemeral key message purpose size. * @@ -900,6 +922,12 @@ destroy_kx_ctx (struct CadetTunnel *t) if (NULL == t->kx_ctx || GNUNET_SCHEDULER_NO_TASK != t->kx_ctx->finish_task) return; + if (is_key_null (&t->kx_ctx->e_key_old)) + { + t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_now (finish_kx, t); + return; + } + delay = GNUNET_TIME_relative_divide (rekey_period, 4); delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_MINUTES); -- 2.25.1