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.

comm.h 740B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef COMM_H
  2. #define COMM_H
  3. #include <sys/types.h>
  4. #include <sys/socket.h>
  5. #include <gmp.h>
  6. #include <stdint.h>
  7. struct sock_params
  8. {
  9. int sock;
  10. struct sockaddr *addr;
  11. socklen_t addrlen;
  12. struct addrinfo *freeme;
  13. };
  14. struct elgamal
  15. {
  16. mpz_t m;
  17. mpz_t g;
  18. mpz_t p;
  19. mpz_t x;
  20. };
  21. struct session
  22. {
  23. uint32_t key[60];
  24. struct sock_params params;
  25. struct elgamal eg;
  26. gmp_randstate_t rs;
  27. char last_sent_enc[16];
  28. char last_recv_enc[16];
  29. };
  30. void sess_init(struct session *sess);
  31. void sess_destroy(struct session *sess);
  32. int do_resolve(char *address, char *portstr, struct sock_params *params);
  33. void do_unresolve(struct sock_params params);
  34. int do_connect(struct session *sess);
  35. int do_receive(struct session *sess);
  36. #endif