123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
-
-
- #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);
- }
|