FreeBSD kernel libkern code
arc4random.c File Reference
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/random.h>
#include <sys/libkern.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/time.h>
Include dependency graph for arc4random.c:

Go to the source code of this file.

Macros

#define ARC4_RESEED_BYTES   65536
 
#define ARC4_RESEED_SECONDS   300
 
#define ARC4_KEYBYTES   (256 / 8)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static u_int8_t arc4_randbyte (void)
 
static __inline void arc4_swap (u_int8_t *a, u_int8_t *b)
 
static void arc4_randomstir (void)
 
static void arc4_init (void)
 
 SYSINIT (arc4_init, SI_SUB_LOCK, SI_ORDER_ANY, arc4_init, NULL)
 
void arc4rand (void *ptr, u_int len, int reseed)
 
uint32_t arc4random (void)
 

Variables

int arc4rand_iniseed_state = ARC4_ENTR_NONE
 
static u_int8_t arc4_i
 
static u_int8_t arc4_j
 
static int arc4_numruns = 0
 
static u_int8_t arc4_sbox [256]
 
static time_t arc4_t_reseed
 
static struct mtx arc4_mtx
 

Macro Definition Documentation

#define ARC4_KEYBYTES   (256 / 8)

Definition at line 25 of file arc4random.c.

Referenced by arc4_randomstir().

#define ARC4_RESEED_BYTES   65536

Definition at line 23 of file arc4random.c.

Referenced by arc4rand().

#define ARC4_RESEED_SECONDS   300

Definition at line 24 of file arc4random.c.

Referenced by arc4_randomstir().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static void arc4_init ( void  )
static

Definition at line 94 of file arc4random.c.

References arc4_i, arc4_j, arc4_mtx, arc4_sbox, and arc4_t_reseed.

static u_int8_t arc4_randbyte ( void  )
static

Definition at line 112 of file arc4random.c.

References arc4_i, arc4_j, arc4_sbox, and arc4_swap().

Referenced by arc4_randomstir(), and arc4rand().

Here is the call graph for this function:

Here is the caller graph for this function:

static void arc4_randomstir ( void  )
static

Definition at line 51 of file arc4random.c.

References arc4_i, arc4_j, ARC4_KEYBYTES, arc4_mtx, arc4_numruns, arc4_randbyte(), ARC4_RESEED_SECONDS, arc4_sbox, arc4_swap(), and arc4_t_reseed.

Referenced by arc4rand().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline void arc4_swap ( u_int8_t *  a,
u_int8_t *  b 
)
static

Definition at line 38 of file arc4random.c.

References c.

Referenced by arc4_randbyte(), and arc4_randomstir().

Here is the caller graph for this function:

void arc4rand ( void *  ptr,
u_int  len,
int  reseed 
)

Definition at line 129 of file arc4random.c.

References arc4_mtx, arc4_numruns, arc4_randbyte(), arc4_randomstir(), ARC4_RESEED_BYTES, arc4_t_reseed, and arc4rand_iniseed_state.

Referenced by arc4random().

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t arc4random ( void  )

Definition at line 150 of file arc4random.c.

References arc4rand().

Here is the call graph for this function:

SYSINIT ( arc4_init  ,
SI_SUB_LOCK  ,
SI_ORDER_ANY  ,
arc4_init  ,
NULL   
)

Variable Documentation

u_int8_t arc4_i
static

Definition at line 29 of file arc4random.c.

Referenced by arc4_init(), arc4_randbyte(), and arc4_randomstir().

u_int8_t arc4_j
static

Definition at line 29 of file arc4random.c.

Referenced by arc4_init(), arc4_randbyte(), and arc4_randomstir().

struct mtx arc4_mtx
static

Definition at line 33 of file arc4random.c.

Referenced by arc4_init(), arc4_randomstir(), and arc4rand().

int arc4_numruns = 0
static

Definition at line 30 of file arc4random.c.

Referenced by arc4_randomstir(), and arc4rand().

u_int8_t arc4_sbox[256]
static

Definition at line 31 of file arc4random.c.

Referenced by arc4_init(), arc4_randbyte(), and arc4_randomstir().

time_t arc4_t_reseed
static

Definition at line 32 of file arc4random.c.

Referenced by arc4_init(), arc4_randomstir(), and arc4rand().

int arc4rand_iniseed_state = ARC4_ENTR_NONE

Definition at line 27 of file arc4random.c.

Referenced by arc4rand().