summaryrefslogtreecommitdiffstats
path: root/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-27 22:43:19 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-27 22:43:19 +0200
commit3065f96f7b833701a03f5759bfc593a7f6943c4e (patch)
tree7413b460332130fc760f1c3a579a502e5e7454ea /src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
parent2190d635c1bb7d917c16b543b78d74a4ca9a735d (diff)
downloadfastd-3065f96f7b833701a03f5759bfc593a7f6943c4e.tar
fastd-3065f96f7b833701a03f5759bfc593a7f6943c4e.zip
New handshake format; don't respond to data packets from unknown peers with handshakes, but request a re-handshake
Diffstat (limited to 'src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c')
-rw-r--r--src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
index 6f59323..8ef0efb 100644
--- a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
+++ b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
@@ -281,18 +281,21 @@ static void protocol_init_peer(fastd_context *ctx, fastd_peer *peer) {
}
create_peer_state(ctx, peer);
- new_handshake(ctx, peer, true);
- fastd_buffer buffer = fastd_buffer_alloc(sizeof(protocol_handshake_init_packet), 0, 0);
- protocol_handshake_init_packet *packet = buffer.data;
+ if (!fastd_peer_is_temporary(peer)) {
+ new_handshake(ctx, peer, true);
- memset(packet->common.noncepad, 0, NONCEBYTES);
- packet->common.type = HANDSHAKE_PACKET_INIT;
- memcpy(packet->common.sender_key, ctx->conf->protocol_config->public_key.p, PUBLICKEYBYTES);
- memcpy(packet->common.receipient_key, peer->config->protocol_config->public_key.p, PUBLICKEYBYTES);
- memcpy(packet->handshake_key, peer->protocol_state->initiating_handshake->public_key.p, PUBLICKEYBYTES);
+ fastd_buffer buffer = fastd_buffer_alloc(sizeof(protocol_handshake_init_packet), 0, 0);
+ protocol_handshake_init_packet *packet = buffer.data;
- fastd_task_put_send(ctx, peer, buffer);
+ memset(packet->common.noncepad, 0, NONCEBYTES);
+ packet->common.type = HANDSHAKE_PACKET_INIT;
+ memcpy(packet->common.sender_key, ctx->conf->protocol_config->public_key.p, PUBLICKEYBYTES);
+ memcpy(packet->common.receipient_key, peer->config->protocol_config->public_key.p, PUBLICKEYBYTES);
+ memcpy(packet->handshake_key, peer->protocol_state->initiating_handshake->public_key.p, PUBLICKEYBYTES);
+
+ fastd_task_put_send(ctx, peer, buffer);
+ }
}
static void respond_handshake(fastd_context *ctx, fastd_peer *peer) {