The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
rand.c File Reference

Functions to get randomness. More...

#include <freeradius-devel/util/rand.h>
#include <freeradius-devel/util/hash.h>
#include <fcntl.h>
#include <stdbool.h>
+ Include dependency graph for rand.c:

Go to the source code of this file.

Macros

#define fill(_expr)
 

Functions

uint32_t fr_fast_rand (fr_fast_rand_t *ctx)
 
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 *data, size_t size)
 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...
 

Variables

static _Thread_local bool fr_rand_initialized = false
 
static _Thread_local fr_randctx fr_rand_pool
 A pool of pre-generated random integers. More...
 

Detailed Description

Functions to get randomness.

Definition in file rand.c.

Macro Definition Documentation

◆ fill

#define fill (   _expr)
Value:
do { \
while (p < end) { \
if ((mod = ((p - out) & (sizeof(word) - 1))) == 0) word = fr_rand(); \
byte = ((uint8_t *)&word)[mod]; \
*p++ = (_expr); \
} } while (0)
while(1)
Definition: acutest.h:856
unsigned char uint8_t
Definition: merged_model.c:30
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition: rand.c:106
static size_t char ** out
Definition: value.h:984

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_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:

Variable Documentation

◆ fr_rand_initialized

_Thread_local bool fr_rand_initialized = false
static

Definition at line 32 of file rand.c.

◆ fr_rand_pool

_Thread_local fr_randctx fr_rand_pool
static

A pool of pre-generated random integers.

Definition at line 31 of file rand.c.