The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Functions
rand.h File Reference

Functions to get randomness. More...

#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <stddef.h>
#include <stdint.h>
+ Include dependency graph for rand.h:

Go to the source code of this file.

Data Structures

struct  fr_fast_rand_t
 Smaller fast random number generator. More...
 
struct  fr_randctx
 

Functions

uint32_t fr_fast_rand (fr_fast_rand_t *ctx)
 
void fr_isaac (fr_randctx *ctx)
 
void fr_isaac_init (fr_randctx *ctx, int flag)
 
uint32_t fr_rand (void)
 Return a 32-bit random number. More...
 
void fr_rand_buffer (void *start, size_t length)
 
void fr_rand_init (void)
 
void fr_rand_mixin (void const *, size_t)
 Mix data into the random number generator. More...
 
void fr_rand_str (uint8_t *out, size_t len, char class)
 Generate a random string. More...
 

Detailed Description

Functions to get randomness.

Definition in file rand.h.


Data Structure Documentation

◆ fr_fast_rand_t

struct fr_fast_rand_t

Smaller fast random number generator.

From George Marsaglia's Multiply with Carry (MWC) algorithm.

The two seeds here should be initialized by calling fr_rand(), or for tests, via some static values.

Definition at line 54 of file rand.h.

Data Fields
uint32_t a
uint32_t b

◆ fr_randctx

struct fr_randctx

Definition at line 38 of file rand.h.

Data Fields
uint32_t randa
uint32_t randb
uint32_t randc
uint32_t randcnt
uint32_t randmem[256]
uint32_t randrsl[256]

Function Documentation

◆ fr_fast_rand()

uint32_t fr_fast_rand ( fr_fast_rand_t ctx)

Definition at line 280 of file rand.c.

+ Here is the caller graph for this function:

◆ fr_isaac()

void fr_isaac ( fr_randctx ctx)

Definition at line 46 of file isaac.c.

+ Here is the caller graph for this function:

◆ fr_isaac_init()

void fr_isaac_init ( fr_randctx ctx,
int  flag 
)

Definition at line 85 of file isaac.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_rand()

uint32_t fr_rand ( void  )

Return a 32-bit random number.

Definition at line 106 of file rand.c.

+ Here is the call graph for this function:

◆ fr_rand_buffer()

void fr_rand_buffer ( void *  start,
size_t  length 
)

Definition at line 126 of file rand.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_rand_init()

void fr_rand_init ( void  )

Definition at line 34 of file rand.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_rand_mixin()

void fr_rand_mixin ( void const *  data,
size_t  size 
)

Mix data into the random number generator.

May be called any number of times.

Definition at line 80 of file rand.c.

+ Here is the call graph for this function:

◆ fr_rand_str()

void fr_rand_str ( uint8_t out,
size_t  len,
char  class 
)

Generate a random string.

Note
Character selection is not perfectly distributed, should not be used for cryptographic purposes.
Parameters
[out]outWhere to write the string
[in]lenLength of the output buffer.
[in]classto pick characters from (see function body).

Definition at line 164 of file rand.c.

+ Here is the caller graph for this function: