// ======================================================================================================== // ======================================================================================================== // *********************************************** common.h *********************************************** // ======================================================================================================== // ======================================================================================================== #include #include #include #include #include #include #include #include #include #include #include #include #include // ===================================================================================================================== // ===================================================================================================================== // COMMON PARAMETERS for verifier_regeneration.c and token_regeneration.c // Tune these as needed to the desired key size for SessionEncryption (SE) and KEK. #define SE_TARGET_NUM_KEY_BITS 512 #define KEK_TARGET_NUM_KEY_BITS 2000 // NOTE: THIS PARAMETER IS HARDCODED TO SKE 5 IN THE VHDL SO SETTING THIS TO 0 HAS NOT EFFECT. LEAVE IT AT 1. // Recommended value for SKE_3_or_5 is 1. Secure key encoding level as given here protects against bit flip errors when // HELP is configured to carry out the KEK function. MUST BE SET TO 0 or 1. Setting to 1 provides a higher level of // protection but generates more helper data. Used only in token_regeneration.c. #define SKE_3_OR_5 1 // Specify minimum number of bits that must be generated for token and verifier authentication to succeed. Currently, // all bits in the generated bitstrings must match in order for authenication to be classified as successful. This restriction // can be relaxed as needed with appropriate changes in the TokenAuthenication and VerifierAuthenication functions. #define AUTHEN_MIN_BITSTRING_SIZE 80 // Recommended offset mode is 4. There are 5 basic Offset modes: 0) no Offset, 1) random Offset, 2) Population Offset, // 3) PerChip Offset and 4) both Population and PerChip Offset. The difference in these modes is described in the documentation. // !!! WARNING: DO NOT USE 1) Random Offsets with the multi-threaded version in XWIN_VERSION -- the ComputeRandomOffset routine // calls LFSR_11_A_bit_low which uses a static variable and so it will get corrupted! // Made this a parameter. //#define OFFSET_MODE 4 // THIS MUST REMAIN AT 4. VHDL code is hardcoded with 4 bits. #define OFFSET_RESOLUTION_BITS 4 // Recommendation is to set this parameter to 0. For testing purposes, it can be set to 1 to disable random (XOR_nonce) // selection of the HELP parameters, and instead to force the HELP parameters to remain constant for all innocations. // The fixed values used for the HELP parameters can be specified below, see constants labelel with prefix 'FIXED_'. // Made this a parameter. //#define FIX_PARAMS 0 // These 'FIXED_' parameters are ONLY used when the flag 'FIX_PARAMS' is set to 1. // Constraint: Values assigned for the LFSR seeds must be >= 0 and <= 2047 #define FIXED_LFSR_SEED_LOW 0 #define FIXED_LFSR_SEED_HIGH 0 // Constraint: Values assigned for the mean must be >= -500 and <= 500 #define FIXED_REFERENCE_MEAN -18.0 // Constraint: Values for range must be > 0 (NOTE: if set to 0, the HELP Engine will be disabled and will return to idle) and <= 500. #define FIXED_REFERENCE_RANGE 168.0 // Constraint: Values for modulus must be > 0 and <= 30, and is further constrained by the value assigned to FIXED_MODULUS, i.e., // FIXED_MODULUS >= 4*FIXED_MARGIN + 2. // (NOTE: if less than this minimum value, the HELP Engine will be disabled and will return to idle). #define FIXED_MODULUS 16.0 //#define FIXED_MODULUS 12.0 // Constraint: Values for Margin must be >= 0 and <= 5, and has additional constraints as specified for FIXED_MODULUS above. //#define FIXED_MARGIN 0.0 //#define FIXED_MARGIN 1.0 //#define FIXED_MARGIN 2.0 #define FIXED_MARGIN 3.0 // ===================================================================================================================== // ===================================================================================================================== // MAX_VECS MUST be equal or larger than vector set. #define MAX_VECS 1500 #define MAX_SAMS 128 // Scratch pad string size #define MAX_STRING_LEN 2000 // Entropy source datapath characteristics for processing vectors on the token side. #define VEC_LEN_BITS 64 #define MAX_OUTPUTS 64 #define VEC_CHUNK_SIZE 16 #define MAX_BINARY_BYTES 500 #define MAX_NONCE_BYTES 40 // MAX that the HELP Engine can generate before overflow (where further nonce bytes are ignored). #define MAX_GENERATED_NONCE_BYTES 10000 // Use upto the larger of the number of rising or falling PNs. Usually just set to 2048 (NOTE: rising and falling // PNs are stored now in separate arrays so this refers to the number of each, NOT THE SUM of the two. // BYTE-TO-WORD: NOTE: ALL CONSTANTS HERE MUST BE AN EVEN NUMBER, in particular, MAX_PNDIFFS. #define MAX_PNS 2048 #define MAX_PNDIFFS 2048 // 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. NUM_PNDIFFS defined above. #define RANGE_LOW_LIMIT 128 #define RANGE_HIGH_LIMIT 1920 // For checks that the hardware version is not overflowing. #define LARGEST_POS_VAL (16384/16) - 1 #define LARGEST_NEG_VAL -LARGEST_POS_VAL // ===================================================================================================================== // ===================================================================================================================== 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); void PrintHeaderAndHexVals(int max_string_len, char header_str[max_string_len], int max_vals, int num_vals, unsigned char vals[max_vals], int max_vals_per_row);