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;