// ======================================================================================================== // ======================================================================================================== // *********************************************** common.h *********************************************** // ======================================================================================================== // ======================================================================================================== #include #include #include #include #include #include #include #include #include #include #include #include //Final number of bits used as secret key #define SECRET_KEY_BITS 256 // Tunable parameters #define MAX_VECS 15000 #define MAX_SAMS 128 // Scratch pad string size #define MAX_STRING_LEN 2000 // Keccak and VHDL dependent constants #define VEC_LEN_BITS 16 #define MAX_OUTPUTS 16 #define MAX_VECS_OUTPUTS (MAX_OUTPUTS * MAX_VECS) #define VEC_CHUNK_SIZE 16 #define MAX_BINARY_BYTES 500 // With 8 bits/byte, this provides 2400 bits. Our max is 2048 bits (256 bytes) for helper data if we need it all. #define MAX_BS_BYTES 300 // VHDL constants #define PNL_BRAM_NUM_WORDS_NB 4096 #define TVCOMP_NUM_PNDIFFS (PNL_BRAM_NUM_WORDS_NB/2) // NOTE: This is the range I'm using in the hardware. I find the largest negative value in the distribution, subtract // that from all values (shifting the distribution left for negative largest values and right for positive). The // binning of values therefore starts at bin 0 and goes up through the largest positive value (minus the negative value). // Distribution ranges are typically between 250 to 300. In the hardware, I also preserve 1 digit of precision, which is // equivalent to multiplying the range by 2. I also do this on the server to get extra precision out of the range. #define DIST_RANGE 1024 // Represents +6.25% and -93.75% since NUMBER of PNDIFFS is 2048. Given w.r.t. TVCOMP_NUM_PNDIFFS defined above. #define RANGE_LOW_LIMIT 128 #define RANGE_HIGH_LIMIT 1920 int OpenSocketServer(int str_length, int *server_socket_desc_ptr, char server_IP[str_length], int port_number, int *client_socket_desc_ptr, struct sockaddr_in *client_addr_ptr, int accept_only, int check_and_return); void OpenSocketClient(int str_length, char server_IP[str_length], int port_number, int *server_socket_desc_ptr); int SockGetB(unsigned char *buffer, int buffer_size, int socket_desc); int SockSendB(unsigned char *buffer, int buffer_size, int socket_desc);