static int ALL_RSI_GenerateBlock(byte *output, size_t size, unsigned int safety) { CRYPTOPP_ASSERT((output && size) || !(output || size)); #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 word32 val; #else word64 val; #endif while (size >= sizeof(val)) { #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 if (_rdseed32_step((word32*)output)) #else // Cast due to GCC, http://github.com/weidai11/cryptopp/issues/236 if (_rdseed64_step(reinterpret_cast<unsigned long long*>(output))) #endif { output += sizeof(val); size -= sizeof(val); } else { if (!safety--) { CRYPTOPP_ASSERT(0); return 0; } } } if (size) { #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 if (_rdseed32_step(&val)) #else // Cast due to GCC, http://github.com/weidai11/cryptopp/issues/236 if (_rdseed64_step(reinterpret_cast<unsigned long long*>(&val))) #endif { memcpy(output, &val, size); size = 0; } else { if (!safety--) { CRYPTOPP_ASSERT(0); return 0; } } } SecureWipeBuffer(&val, 1); return int(size == 0); }
static int ALL_RSI_GenerateBlock(byte *output, size_t size, unsigned int safety) { assert((output && size) || !(output || size)); #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 word32 val; #else word64 val; #endif while (size >= sizeof(val)) { #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 if (_rdseed32_step((word32*)output)) #else if (_rdseed64_step((word64*)output)) #endif { output += sizeof(val); size -= sizeof(val); } else { if (!safety--) { assert(0); return 0; } } } if (size) { #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 if (_rdseed32_step(&val)) #else if (_rdseed64_step(&val)) #endif { memcpy(output, &val, size); size = 0; } else { if (!safety--) { assert(0); return 0; } } } SecureWipeBuffer(&val, 1); return int(size == 0); }
void main(void) { #if 1 /* * 1 Word, * 2 Byte, * 4 Kb * * #define Bit (1) Single Binary Digit (1 or 0) * #define KB (1<<4) Kilobyte * #define MB (1<<8) Megabyte (MB) 1,024 Kilobytes * #define GB (1<<12) Gigabyte (GB) 1,024 Megabytes * #define TB (1<<16) Terabyte (TB) 1,024 Gigabytes * #define PB (1<<20) Petabyte (PB) 1,024 Terabytes * #define EB (1<<24) Exabyte (EB) 1,024 Petabytes */ #define BUFSIZE (1<<24) unsigned int ok, i; unsigned long long *rand = malloc(BUFSIZE*sizeof(unsigned long long)), *seed = malloc(BUFSIZE*sizeof(unsigned long long)); clock_t start, end, bm; // RDRAND (the benchmark) start = clock(); for (i = 0; i < BUFSIZE; i++) { while (!_rdrand64_step(&rand[i])) ; } bm = clock() - start; printf("RDRAND: %li\n", bm); // RDSEED start = clock(); for (i = 0; i < BUFSIZE; i++) { while (!_rdseed64_step(&seed[i])) ; } end = clock(); exit(0); #endif printf("Linked List Testing\n"); // Master thread head = create_list(NULL,0,0); // Choice 1: Create a server socket // Create a server socket. // Client socket will connect and update the linked list // Choice 2: // Shared Memory buffer so that threads can read from the shared memory buffer. // // Choice 3: // Message Queue Processing the linked list }