Simple AES chat program
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
846 B

#ifndef COMM_H
#define COMM_H
#include <sys/types.h>
#include <sys/socket.h>
#include <gmp.h>
#include <stdint.h>
struct sock_params
int sock;
struct sockaddr *addr;
socklen_t addrlen;
struct addrinfo *freeme;
struct elgamal
mpz_t m;
mpz_t g;
mpz_t p;
mpz_t x;
struct session
uint32_t key[60];
struct sock_params params;
struct elgamal eg;
gmp_randstate_t rs;
char last_sent_enc[16];
char last_recv_enc[16];
void sess_init(struct session *sess);
void sess_destroy(struct session *sess);
int do_resolve(char *address, char *portstr, struct sock_params *params);
void do_unresolve(struct sock_params params);
int do_connect(struct session *sess);
int do_receive(struct session *sess);
void send_encrypted_byte(struct session *sess, char byte);
int recv_encrypted_byte(struct session *sess);