1
0
Fork 0

A handshake fix in main(): No, actually, NOW we're secure. :)

This commit is contained in:
Alexander Andreev 2024-03-25 03:59:38 +04:00
parent 92d7659306
commit 58c3b3fada
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
1 changed files with 17 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include <portaudio.h>
#include <sodium/core.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@ -24,6 +25,7 @@ int main(int argc, char **argv) {
unsigned char hlr[CRYPT_HELLO_LEN], hrl[CRYPT_HELLO_LEN];
unsigned char *nonce;
net_t nl, nr;
crypt_session_t sl, sr;
const int incom_len = 512;
char incom[incom_len];
@ -148,6 +150,18 @@ int main(int argc, char **argv) {
goto cleanup;
}
if (crypt_session_init(&sl, &kl, &kr, nonce, true) == -1) {
fprintf(stderr, "local session init fail\n");
ret = -1;
goto cleanup;
}
if (crypt_session_init(&sr, &kr, &kl, nonce, false) == -1) {
fprintf(stderr, "remote session init fail\n");
ret = -1;
goto cleanup;
}
/* Now we're talking securely! */
@ -159,6 +173,9 @@ cleanup:
crypt_key_destroy(&kl);
crypt_key_destroy(&kr);
crypt_session_destroy(&sl);
crypt_session_destroy(&sr);
free(hl);
free(hr);
free(nonce);