From 722baa7da3c697230565dfab7a58d559e3e09989 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 26 Mar 2024 04:59:24 +0400 Subject: [PATCH] In a server handshake initialise all the shit before sending our hello. --- src/main.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index c4bf0cd..a163617 100644 --- a/src/main.c +++ b/src/main.c @@ -167,6 +167,16 @@ int server_handshake(net_t *const n, crypt_session_t *const s, crypt_key_t *cons if ((hello = crypt_hello(ok)) == NULL) return -1; + if ((nonce = crypt_hello_get_nonce(hello, (unsigned char *)buffer, false)) == NULL) { + free(hello); + return -1; + } + + if (crypt_session_init(s, ok, rk, nonce, false) == -1) { + free(nonce); + return -3; + } + n->raddr = n->inaddr; n->raddr_len = n->inaddr_len; @@ -175,18 +185,7 @@ int server_handshake(net_t *const n, crypt_session_t *const s, crypt_key_t *cons return -1; } - if ((nonce = crypt_hello_get_nonce(hello, (unsigned char *)buffer, false)) == NULL) { - free(hello); - return -1; - } - free(hello); - - if (crypt_session_init(s, ok, rk, nonce, false) == -1) { - free(nonce); - return -3; - } - free(nonce); return 0;