summaryrefslogtreecommitdiffstats
path: root/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-31 21:18:07 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-31 21:18:07 +0200
commit4f0cfe26bf5445fc06a59a6db47cb2fa3158b87b (patch)
tree05396b7c13482ab27beb4593236b260c4bdf06c3 /src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
parentf25c92359e57b1e97c86174067485acf6a9445de (diff)
downloadfastd-4f0cfe26bf5445fc06a59a6db47cb2fa3158b87b.tar
fastd-4f0cfe26bf5445fc06a59a6db47cb2fa3158b87b.zip
Trigger handshake when unexpected data is received from a floating peer
Diffstat (limited to 'src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c')
-rw-r--r--src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
index a7a635c..32c459a 100644
--- a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
+++ b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
@@ -561,8 +561,13 @@ static void protocol_handshake_handle(fastd_context *ctx, fastd_peer *peer, cons
}
if (peer->protocol_state->initiating_handshake->peer_config != peer_config) {
- pr_debug(ctx, "received handshake response with wrong sender key from %P", peer);
- return;
+ if (peer->protocol_state->initiating_handshake->peer_config) {
+ pr_debug(ctx, "received handshake response with wrong sender key from %P", peer);
+ return;
+ }
+ else {
+ peer->protocol_state->initiating_handshake->peer_config = peer_config;
+ }
}
if (memcmp(peer->protocol_state->initiating_handshake->public_key.p, handshake->records[RECORD_RECEIPIENT_HANDSHAKE_KEY].data, PUBLICKEYBYTES) != 0) {
@@ -606,14 +611,21 @@ static void protocol_handshake_handle(fastd_context *ctx, fastd_peer *peer, cons
}
static void protocol_handle_recv(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) {
- if (!fastd_peer_is_established(peer))
+ if (!fastd_peer_is_established(peer)) {
+ pr_debug(ctx, "received unexpected packet from %P", peer);
+
+ if (fastd_peer_is_temporary(peer)) {
+ pr_debug(ctx, "sending handshake to temporary peer %P", peer);
+ fastd_task_schedule_handshake(ctx, peer, 0);
+ }
+
goto end;
+ }
if (buffer.len < NONCEBYTES)
goto end;
if (!peer->protocol_state || !is_session_valid(ctx, &peer->protocol_state->session)) {
- pr_debug(ctx, "received unexpected packet from %P", peer);
goto end;
}
@@ -644,7 +656,7 @@ static void protocol_handle_recv(fastd_context *ctx, fastd_peer *peer, fastd_buf
if (!is_nonce_valid(nonce, session->receive_nonce)) {
pr_debug(ctx, "received packet with invalid nonce from %P", peer);
-
+ fastd_buffer_free(recv_buffer);
goto end;
}