/*
* Seed the random pool with data.
*/
- fr_rand_seed(&statbuf, sizeof(statbuf));
+ fr_rand_mixin(&statbuf, sizeof(statbuf));
memset(&base_flags, 0, sizeof(base_flags));
} while (0)
/* if (flag==1), then use the contents of randrsl[] to initialize mm[]. */
-void fr_rand_init(fr_randctx *ctx, int flag)
+void fr_isaac_init(fr_randctx *ctx, int flag)
{
int i;
uint32_t a, b, c, d, e, f, g, h;
for (i = 0; i < 256; ++i) ctx.randrsl[i] = (uint32_t)0;
- fr_rand_init(&ctx, 1);
+ fr_isaac_init(&ctx, 1);
for (i = 0; i < 2; ++i) {
fr_isaac(&ctx);
for (j = 0; j < 256; ++j) {
static _Thread_local fr_randctx fr_rand_pool; //!< A pool of pre-generated random integers
static _Thread_local bool fr_rand_initialized = false;
-/** Seed the random number generator
+/** Mix data into the random number generator.
*
* May be called any number of times.
*/
-void fr_rand_seed(void const *data, size_t size)
+void fr_rand_mixin(void const *data, size_t size)
{
uint32_t hash;
memcpy((void *) &fr_rand_pool.randrsl[0], &when, sizeof(when));
}
- fr_rand_init(&fr_rand_pool, 1);
+ fr_isaac_init(&fr_rand_pool, 1);
fr_rand_pool.randcnt = 0;
fr_rand_initialized = 1;
}
* Ensure that the pool is initialized.
*/
if (!fr_rand_initialized) {
- fr_rand_seed(NULL, 0);
+ fr_rand_mixin(NULL, 0);
}
num = fr_rand_pool.randrsl[fr_rand_pool.randcnt++];
} fr_fast_rand_t;
void fr_isaac(fr_randctx *ctx);
-void fr_rand_init(fr_randctx *ctx, int flag);
+void fr_isaac_init(fr_randctx *ctx, int flag);
/** @hidecallergraph */
uint32_t fr_rand(void); /* like rand(), but better. */
void fr_rand_buffer(void *start, size_t length) CC_HINT(nonnull);
void fr_rand_str(uint8_t *out, size_t len, char class);
-void fr_rand_seed(void const *, size_t ); /* seed the random pool */
+void fr_rand_mixin(void const *, size_t ); /* seed the random pool */
uint32_t fr_fast_rand(fr_fast_rand_t *ctx);
#ifdef __cplusplus
* Create our own random pool.
*/
for (i = 0; i < 256; i++) inst->rand_pool.randrsl[i] = fr_rand();
- fr_rand_init(&inst->rand_pool, 1);
+ fr_isaac_init(&inst->rand_pool, 1);
inst->rand_pool.randcnt = 0;
return 0;