1
0

In a server handshake initialise all the shit before sending our hello.

This commit is contained in:
Alexander Andreev 2024-03-26 04:59:24 +04:00
parent 2680674c71
commit 722baa7da3
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34

View File

@ -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) if ((hello = crypt_hello(ok)) == NULL)
return -1; 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 = n->inaddr;
n->raddr_len = n->inaddr_len; 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; return -1;
} }
if ((nonce = crypt_hello_get_nonce(hello, (unsigned char *)buffer, false)) == NULL) {
free(hello); free(hello);
return -1;
}
free(hello);
if (crypt_session_init(s, ok, rk, nonce, false) == -1) {
free(nonce);
return -3;
}
free(nonce); free(nonce);
return 0; return 0;