diff --git a/sys/dev/random/fortuna.h b/sys/dev/random/fortuna.h --- a/sys/dev/random/fortuna.h +++ b/sys/dev/random/fortuna.h @@ -27,6 +27,10 @@ #ifndef SYS_DEV_RANDOM_FORTUNA_H_INCLUDED #define SYS_DEV_RANDOM_FORTUNA_H_INCLUDED +/* Defined in FS&K */ +#define RANDOM_FORTUNA_NPOOLS 32 /* The number of accumulation pools */ +#define RANDOM_FORTUNA_DEFPOOLSIZE 64 /* The default pool size/length for a (re)seed */ + #ifdef _KERNEL typedef struct mtx mtx_t; #define RANDOM_RESEED_INIT_LOCK(x) mtx_init(&fortuna_state.fs_mtx, "reseed mutex", NULL, MTX_DEF) diff --git a/sys/dev/random/fortuna.c b/sys/dev/random/fortuna.c --- a/sys/dev/random/fortuna.c +++ b/sys/dev/random/fortuna.c @@ -71,8 +71,6 @@ #include /* Defined in FS&K */ -#define RANDOM_FORTUNA_NPOOLS 32 /* The number of accumulation pools */ -#define RANDOM_FORTUNA_DEFPOOLSIZE 64 /* The default pool size/length for a (re)seed */ #define RANDOM_FORTUNA_MAX_READ (1 << 20) /* Max bytes from AES before rekeying */ #define RANDOM_FORTUNA_BLOCKS_PER_KEY (1 << 16) /* Max blocks from AES before rekeying */ CTASSERT(RANDOM_FORTUNA_BLOCKS_PER_KEY * RANDOM_BLOCKSIZE == diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c --- a/sys/dev/random/random_harvestq.c +++ b/sys/dev/random/random_harvestq.c @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -259,8 +260,8 @@ * stuck for a few seconds with random_kthread gradually collecting a * small chunk of entropy every 1 / RANDOM_KTHREAD_HZ seconds. * - * The value 64 below is RANDOM_FORTUNA_DEFPOOLSIZE, i.e. chosen to - * fill Fortuna's pools in the default configuration. With another + * We collect RANDOM_FORTUNA_DEFPOOLSIZE bytes per pool, i.e. enough + * to fill Fortuna's pools in the default configuration. With another * PRNG or smaller pools for Fortuna, we might collect more entropy * than needed to fill the pools, but this is harmless; alternatively, * a different PRNG, larger pools, or fast entropy sources which are @@ -270,8 +271,8 @@ * try again for a large amount of entropy. */ if (!p_random_alg_context->ra_seeded()) - npools = howmany(p_random_alg_context->ra_poolcount * 64, - sizeof(entropy)); + npools = howmany(p_random_alg_context->ra_poolcount * + RANDOM_FORTUNA_DEFPOOLSIZE, sizeof(entropy)); /* * Step over all of live entropy sources, and feed their output