static void accumulator_output(struct fortuna_state *st, unsigned char *dst, size_t len) { /* Reseed the generator with data from pools if we have accumulated enough * data and enough time has passed since the last accumulator reseed. */ if (st->pool0_bytes >= MIN_POOL_LEN && enough_time_passed(st)) accumulator_reseed(st); generator_output(st, dst, len); }
static void extract_data(FState * st, unsigned count, unsigned char *dst) { unsigned n; unsigned block_nr = 0; pid_t pid = getpid(); /* Should we reseed? */ if (st->pool0_bytes >= POOL0_FILL || st->reseed_count == 0) if (enough_time_passed(st)) reseed(st); /* Do some randomization on first call */ if (!st->tricks_done) startup_tricks(st); /* If we forked, force a reseed again */ if (pid != st->pid) { st->pid = pid; reseed(st); } while (count > 0) { /* produce bytes */ encrypt_counter(st, st->result); /* copy result */ if (count > CIPH_BLOCK) n = CIPH_BLOCK; else n = count; memcpy(dst, st->result, n); dst += n; count -= n; /* must not give out too many bytes with one key */ block_nr++; if (block_nr > (RESEED_BYTES / CIPH_BLOCK)) { rekey(st); block_nr = 0; } } /* Set new key for next request. */ rekey(st); }
static void extract_data(FState *st, unsigned count, uint8_t *dst) { unsigned n; unsigned block_nr = 0; /* Should we reseed? */ if (st->pool0Bytes >= pool0Fill || st->reseedCount == 0) if (enough_time_passed(st)) reseed(st); /* Do some randomization on first call */ if (!st->tricksDone) startup_tricks(st); while (count > 0) { /* produce bytes */ encrypt_counter(st, st->result); /* copy result */ if (count > ciphBlock) n = ciphBlock; else n = count; memmove(dst, st->result, n); dst += n; count -= n; /* must not give out too many bytes with one key */ block_nr++; if (block_nr > (reseedBytes / ciphBlock)) { rekey(st); block_nr = 0; } } /* Set new key for next request. */ rekey(st); }