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.

57 rivejä
889 B

#include <stdio.h>
#include <errno.h>
#include "comm.h"
#include "aes.h"
int main(int argc, char **argv)
{
struct session sess;
initializeSBox();
sess_init(&sess);
if (argc != 3)
{
printf("Usage: %s <connect address> <port>\n", argv[0]);
return 0;
}
if (do_resolve(argv[1], argv[2], &sess.params))
{
perror("could not open socket");
return 1;
}
if (do_connect(&sess))
{
perror("could not connect");
return 1;
}
int byte;
while (1)
{
byte = getchar();
if (byte == EOF)
break;
send_encrypted_byte(&sess, byte);
if (byte == '\n')
{
send_encrypted_byte(&sess, 0);
while ((byte = recv_encrypted_byte(&sess)))
{
if (byte == EOF)
{
goto break2;
}
printf("%c", byte);
}
}
}
break2:
do_unresolve(sess.params);
sess_destroy(&sess);
}