aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/noise.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-08-04 20:02:51 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-08-04 20:29:48 +0200
commit3e94472c8268ed0b90b0accedcd6824661be1fc0 (patch)
tree975e416c64b1e7cf16f9b5361b096bbf2cce18f7 /src/noise.c
parenttimers: rename confusingly named functions and variables (diff)
downloadwireguard-monolithic-historical-3e94472c8268ed0b90b0accedcd6824661be1fc0.tar.xz
wireguard-monolithic-historical-3e94472c8268ed0b90b0accedcd6824661be1fc0.zip
noise: infer initiator or not from handshake state
Suggested-by: Mathias Hall-Andersen <mathias@hall-andersen.dk>
Diffstat (limited to 'src/noise.c')
-rw-r--r--src/noise.c6
1 files changed, 3 insertions, 3 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);