void testrun_performance_entropium(void){ uint64_t t; char str[16]; uint8_t data[32]; calibrateTimer(); print_overhead(); startTimer(1); entropium_addEntropy(128, data); t = stopTimer(); cli_putstr_P(PSTR("\r\n\tadd entropy time: ")); ultoa((unsigned long)t, str, 10); cli_putstr(str); startTimer(1); entropium_getRandomBlock(data); t = stopTimer(); cli_putstr_P(PSTR("\r\n\tget random time: ")); ultoa((unsigned long)t, str, 10); cli_putstr(str); cli_putstr_P(PSTR("\r\n")); }
uint8_t entropium_getRandomByte(void){ static uint8_t block[32]; static uint8_t i = 0; if(i == 0){ entropium_getRandomBlock((void*)block); i = 32; } return block[--i]; }
void entropium_fillBlockRandom(void* block, unsigned length_B){ while(length_B>ENTROPIUM_RANDOMBLOCK_SIZE){ entropium_getRandomBlock(block); block = (uint8_t*)block + ENTROPIUM_RANDOMBLOCK_SIZE; length_B -= ENTROPIUM_RANDOMBLOCK_SIZE; } while(length_B){ *((uint8_t*)block) = entropium_getRandomByte(); block= (uint8_t*)block +1; --length_B; } }
void testrun_entropium(void){ char c, str[16]; uint8_t data[32]; uint32_t i=0; while('q'!=cli_getc()){ entropium_getRandomBlock(data); cli_putstr_P(PSTR("\r\n ")); ultoa(i, str, 10); for(c=strlen(str); c<11; ++c){ cli_putc(' '); } cli_putstr(str); ++i; cli_putstr_P(PSTR(" : ")); cli_hexdump(data, 32); } cli_putstr_P(PSTR("\r\n\r\n")); }