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.

server.c 708B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include "comm.h"
  4. #include "aes.h"
  5. int main()
  6. {
  7. struct session sess;
  8. initializeSBox();
  9. sess_init(&sess);
  10. FILE *keyf = fopen("key.out", "r");
  11. if (keyf == NULL)
  12. {
  13. perror("could not open key file");
  14. return 1;
  15. }
  16. 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))
  17. {
  18. fprintf(stderr, "not a valid key file");
  19. return 2;
  20. }
  21. fclose(keyf);
  22. if (do_resolve("127.0.0.1", NULL, &sess.params))
  23. {
  24. perror("could not open socket");
  25. return 1;
  26. }
  27. if (do_receive(&sess))
  28. {
  29. perror("could not accept");
  30. return 1;
  31. }
  32. do_unresolve(sess.params);
  33. sess_destroy(&sess);
  34. }