summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/noise.c6
-rw-r--r--src/noise.h2
-rw-r--r--src/receive.c2
-rw-r--r--src/send.c2
4 files changed, 6 insertions, 6 deletions
diff --git a/src/noise.c b/src/noise.c
index 4ffe549..199c9d5 100644
--- a/src/noise.c
+++ b/src/noise.c
@@ -579,7 +579,7 @@ out:
return ret_peer;
}
-bool noise_handshake_begin_session(struct noise_handshake *handshake, struct noise_keypairs *keypairs, bool i_am_the_initiator)
+bool noise_handshake_begin_session(struct noise_handshake *handshake, struct noise_keypairs *keypairs)
{
struct noise_keypair *new_keypair;
@@ -590,10 +590,10 @@ bool noise_handshake_begin_session(struct noise_handshake *handshake, struct noi
new_keypair = keypair_create(handshake->entry.peer);
if (!new_keypair)
goto fail;
- new_keypair->i_am_the_initiator = i_am_the_initiator;
+ new_keypair->i_am_the_initiator = handshake->state == HANDSHAKE_CONSUMED_RESPONSE;
new_keypair->remote_index = handshake->remote_index;
- if (i_am_the_initiator)
+ if (new_keypair->i_am_the_initiator)
derive_keys(&new_keypair->sending, &new_keypair->receiving, handshake->chaining_key);
else
derive_keys(&new_keypair->receiving, &new_keypair->sending, handshake->chaining_key);
diff --git a/src/noise.h b/src/noise.h
index c2d7e63..2024b80 100644
--- a/src/noise.h
+++ b/src/noise.h
@@ -117,6 +117,6 @@ struct wireguard_peer *noise_handshake_consume_initiation(struct message_handsha
bool noise_handshake_create_response(struct message_handshake_response *dst, struct noise_handshake *peer);
struct wireguard_peer *noise_handshake_consume_response(struct message_handshake_response *src, struct wireguard_device *wg);
-bool noise_handshake_begin_session(struct noise_handshake *handshake, struct noise_keypairs *keypairs, bool i_am_the_initiator);
+bool noise_handshake_begin_session(struct noise_handshake *handshake, struct noise_keypairs *keypairs);
#endif
diff --git a/src/receive.c b/src/receive.c
index 5a6d975..08b2fe2 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -121,7 +121,7 @@ static void receive_handshake_packet(struct wireguard_device *wg, struct sk_buff
}
update_latest_addr(peer, skb);
net_dbg_ratelimited("%s: Receiving handshake response from peer %Lu (%pISpfsc)\n", wg->dev->name, peer->internal_id, &peer->endpoint.addr);
- if (noise_handshake_begin_session(&peer->handshake, &peer->keypairs, true)) {
+ if (noise_handshake_begin_session(&peer->handshake, &peer->keypairs)) {
timers_session_derived(peer);
timers_handshake_complete(peer);
/* Calling this function will either send any existing packets in the queue
diff --git a/src/send.c b/src/send.c
index a4f2ccc..3a3e544 100644
--- a/src/send.c
+++ b/src/send.c
@@ -72,7 +72,7 @@ void packet_send_handshake_response(struct wireguard_peer *peer)
if (noise_handshake_create_response(&packet, &peer->handshake)) {
cookie_add_mac_to_packet(&packet, sizeof(packet), peer);
- if (noise_handshake_begin_session(&peer->handshake, &peer->keypairs, false)) {
+ if (noise_handshake_begin_session(&peer->handshake, &peer->keypairs)) {
timers_session_derived(peer);
timers_any_authenticated_packet_traversal(peer);
socket_send_buffer_to_peer(peer, &packet, sizeof(struct message_handshake_response), HANDSHAKE_DSCP);