diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-07-25 03:30:02 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-07-25 03:30:02 +0000 |
commit | c54f0c24042fd60ab328f5b4c42eb5a758706925 (patch) | |
tree | 982c7f4491a06e9b7bd1287810dcd9f1f704aaee /src/cadet | |
parent | 32603bde75597d2732141139cc2de66137977ba1 (diff) | |
download | gnunet-c54f0c24042fd60ab328f5b4c42eb5a758706925.tar.gz gnunet-c54f0c24042fd60ab328f5b4c42eb5a758706925.zip |
- if an "old_key" is not valid (for instance, at tunnel establishment), clear the context ASAP
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnel.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 | |||
@@ -411,6 +411,28 @@ is_ready (struct CadetTunnel *t) | |||
411 | 411 | ||
412 | 412 | ||
413 | /** | 413 | /** |
414 | * Check if a key is invalid (NULL pointer or all 0) | ||
415 | * | ||
416 | * @param key Key to check. | ||
417 | * | ||
418 | * @return #GNUNET_YES if key is null, #GNUNET_NO if exists and is not 0. | ||
419 | */ | ||
420 | static int | ||
421 | is_key_null (struct GNUNET_CRYPTO_SymmetricSessionKey *key) | ||
422 | { | ||
423 | struct GNUNET_CRYPTO_SymmetricSessionKey null_key; | ||
424 | |||
425 | if (NULL == key) | ||
426 | return GNUNET_YES; | ||
427 | |||
428 | memset (&null_key, 0, sizeof (null_key)); | ||
429 | if (0 == memcmp (key, &null_key, sizeof (null_key))) | ||
430 | return GNUNET_YES; | ||
431 | return GNUNET_NO; | ||
432 | } | ||
433 | |||
434 | |||
435 | /** | ||
414 | * Ephemeral key message purpose size. | 436 | * Ephemeral key message purpose size. |
415 | * | 437 | * |
416 | * @return Size of the part of the ephemeral key message that must be signed. | 438 | * @return Size of the part of the ephemeral key message that must be signed. |
@@ -900,6 +922,12 @@ destroy_kx_ctx (struct CadetTunnel *t) | |||
900 | if (NULL == t->kx_ctx || GNUNET_SCHEDULER_NO_TASK != t->kx_ctx->finish_task) | 922 | if (NULL == t->kx_ctx || GNUNET_SCHEDULER_NO_TASK != t->kx_ctx->finish_task) |
901 | return; | 923 | return; |
902 | 924 | ||
925 | if (is_key_null (&t->kx_ctx->e_key_old)) | ||
926 | { | ||
927 | t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_now (finish_kx, t); | ||
928 | return; | ||
929 | } | ||
930 | |||
903 | delay = GNUNET_TIME_relative_divide (rekey_period, 4); | 931 | delay = GNUNET_TIME_relative_divide (rekey_period, 4); |
904 | delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_MINUTES); | 932 | delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_MINUTES); |
905 | 933 | ||