Simple AES chat program
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
708 B

#include <stdio.h>
#include <errno.h>
#include "comm.h"
#include "aes.h"
int main()
{
struct session sess;
initializeSBox();
sess_init(&sess);
FILE *keyf = fopen("key.out", "r");
if (keyf == NULL)
{
perror("could not open key file");
return 1;
}
if (4 != gmp_fscanf(keyf, "m=%Zd\ng=%Zd\nx=%Zd\np=%Zd\n", sess.eg.m, sess.eg.g, sess.eg.x, sess.eg.p))
{
fprintf(stderr, "not a valid key file");
return 2;
}
fclose(keyf);
if (do_resolve("127.0.0.1", NULL, &sess.params))
{
perror("could not open socket");
return 1;
}
if (do_receive(&sess))
{
perror("could not accept");
return 1;
}
do_unresolve(sess.params);
sess_destroy(&sess);
}