summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-07-12 01:39:22 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-07-12 01:39:22 +0200
commit4d36f3c08334aaf9533488988278750141ef51e7 (patch)
treebe10fe97e1a21fa5297929d77e8be3ab3fdf8496 /src
parenta1da1232783068149313dd0a1fdb353894bca07e (diff)
downloadfastd-4d36f3c08334aaf9533488988278750141ef51e7.tar
fastd-4d36f3c08334aaf9533488988278750141ef51e7.zip
Invalidate old session on method changes
Diffstat (limited to 'src')
-rw-r--r--src/protocol_ec25519_fhmqvc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c
index b963185..78f5ebf 100644
--- a/src/protocol_ec25519_fhmqvc.c
+++ b/src/protocol_ec25519_fhmqvc.c
@@ -368,6 +368,12 @@ static bool establish(fastd_context_t *ctx, fastd_peer_t *peer, const fastd_meth
peer->protocol_state->session.method->session_free(ctx, peer->protocol_state->session.method_state);
}
+ if (peer->protocol_state->old_session.method && peer->protocol_state->old_session.method != method) {
+ pr_debug(ctx, "method of %P[%I] has changed, terminating old session", peer, remote_addr);
+ peer->protocol_state->old_session.method->session_free(ctx, peer->protocol_state->old_session.method_state);
+ peer->protocol_state->old_session = (protocol_session_t){};
+ }
+
memcpy(hashinput, X->p, PUBLICKEYBYTES);
memcpy(hashinput+PUBLICKEYBYTES, Y->p, PUBLICKEYBYTES);
memcpy(hashinput+2*PUBLICKEYBYTES, A->p, PUBLICKEYBYTES);
@@ -799,7 +805,7 @@ static void protocol_handle_recv(fastd_context_t *ctx, fastd_peer_t *peer, fastd
if (peer->protocol_state->old_session.method_state) {
pr_debug(ctx, "invalidating old session with %P", peer);
peer->protocol_state->old_session.method->session_free(ctx, peer->protocol_state->old_session.method_state);
- peer->protocol_state->old_session.method_state = NULL;
+ peer->protocol_state->old_session = (protocol_session_t){};
}
if (!peer->protocol_state->session.handshakes_cleaned) {