1
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

View File

@ -1,5 +1,6 @@
#include <portaudio.h> #include <portaudio.h>
#include <sodium/core.h> #include <sodium/core.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.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 hlr[CRYPT_HELLO_LEN], hrl[CRYPT_HELLO_LEN];
unsigned char *nonce; unsigned char *nonce;
net_t nl, nr; net_t nl, nr;
crypt_session_t sl, sr;
const int incom_len = 512; const int incom_len = 512;
char incom[incom_len]; char incom[incom_len];
@ -148,6 +150,18 @@ int main(int argc, char **argv) {
goto cleanup; 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! */ /* Now we're talking securely! */
@ -159,6 +173,9 @@ cleanup:
crypt_key_destroy(&kl); crypt_key_destroy(&kl);
crypt_key_destroy(&kr); crypt_key_destroy(&kr);
crypt_session_destroy(&sl);
crypt_session_destroy(&sr);
free(hl); free(hl);
free(hr); free(hr);
free(nonce); free(nonce);