diff --git a/src/main.c b/src/main.c index 2724557..168bcaa 100644 --- a/src/main.c +++ b/src/main.c @@ -1,20 +1,57 @@ #include +#include +#include #include "audio.h" +#include "crypt.h" + +#define CHANNELS 1 +#define SAMPLE_RATE 48000 +#define FRAMES_PER_BUFFFER 480 + +#define BUF_SIZE (FRAMES_PER_BUFFFER * CHANNELS) int main(int argc, char **argv) { (void)argv; (void)argc; - - audio_t aud; - audio_init_default(&aud, 1, 48000, 480, audio_default_callback); + if (sodium_init() < 0) { + fprintf(stderr, "A Sodium cryptography library is failed to initialise!\n"); + return -1; + } - printf("Listening... "); - getchar(); - printf("Done!\n"); - - audio_destroy(&aud); + crypt_key_t own, remote; + + if (crypt_key_gen(&own) < 0) { + fprintf(stderr, "Failed to generate the keys."); + return -1; + } + + if (crypt_key_gen(&remote) < 0) { + fprintf(stderr, "Failed to generate the keys."); + return -1; + } + + crypt_session_t sess, sess_r; + + crypt_session_init(&sess, &own, &remote, true); + crypt_session_init(&sess_r, &remote, &own, false); + + // audio_t aud; + + // uint8_t buf[BUF_SIZE]; + // memset(buf, 0, BUF_SIZE); + + // audio_init(&aud, CHANNELS, SAMPLE_RATE, FRAMES_PER_BUFFFER); + + // printf("Listening... "); + // for (int i = 0; i < (2 * SAMPLE_RATE)/FRAMES_PER_BUFFFER; ++i) { + // audio_read(&aud, buf, BUF_SIZE); + // audio_write(&aud, buf, BUF_SIZE); + // } + // printf("Done!\n"); + + // audio_destroy(&aud); return 0; } \ No newline at end of file