unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (OpenBSD-5.7)
Page:
Section:
Apropos / Subsearch:
optional field

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

NAME
     arc4random -- kernel random subsystem

SYNOPSIS
     #include <&lt;sys/systm.h>&gt;

     u_int32_t
     arc4random(void);

     void
     arc4random_buf(void *buf, size_t nbytes);

     u_int32_t
     arc4random_uniform(u_int32_t upper_bound);

     #include <&lt;dev/rndvar.h>&gt;

     void
     add_true_randomness(int);

     void
     add_timer_randomness(int);

     void
     add_mouse_randomness(int);

     void
     add_tty_randomness(int);

     void
     add_net_randomness(int);

     void
     add_disk_randomness(int);

     void
     add_audio_randomness(int);

DESCRIPTION
     The add_random() 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.

     The add_mouse_randomness(), add_tty_randomness(), add_net_randomness(),
     add_disk_randomness() and add_audio_randomness() routines are used to
     supply data for the random data source device for further processing.
     The processing involves calculating inter-event timedelta and inserting
     it into a pool which is cryptographically mixed multiple times.

     add_true_randomness() does not involve the usual timing calculations, and
     causes the supplied data argument to be added to the entropy pool,
     increasing the entropy counter by 32 bits.

     add_timer_randomness() will not cause the entropy counter to rise.  It is
     used to change the state of the pool periodically, mostly by means of
     timing the random driver's operations.

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

     arc4random_uniform() 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.

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

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

BSD                            November 18, 2014                           BSD