OpenBSD manual page server

Manual Page Search Parameters

ARC4RANDOM(9) Kernel Developer's Manual ARC4RANDOM(9)

arc4random, arc4random_buf, arc4random_uniform, enqueue_randomnesskernel random subsystem

#include <sys/systm.h>

u_int32_t
arc4random(void);

void
arc4random_buf(void *buf, size_t nbytes);

u_int32_t
arc4random_uniform(u_int32_t upper_bound);

#include <dev/rndvar.h>

void
enqueue_randomness(int);

The () functions below mix input into the system entropy pool, which is then used to create a key for the ChaCha stream cipher used in the arc4random() series of functions.

() causes the supplied data argument to be added to the entropy pool, increasing the entropy counter by 32 bits.

() and () provide random numbers and are intended to be called in any circumstance where random numbers are required.

() will return a uniformly distributed random number less than upper_bound, avoiding "modulo bias" when the upper bound is not a power of two. In the worst case, this function may consume multiple iterations to ensure uniformity; see the source code to understand the problem and solution.

(), (), and arc4random_uniform() may be called in nearly any kernel context.

arc4random(3), pchb(4), random(4)

April 28, 2018 OpenBSD-6.4