random.h File Reference

Common interface to the software PRNG. More...

Detailed Description

Common interface to the software PRNG.

Various implementations of a PRNG are available:

  • Tiny Mersenne Twister (default)
  • Mersenne Twister
  • Simple Park-Miller PRNG
  • Musl C PRNG
  • Fortuna (CS)PRNG
  • Hardware Random Number Generator (non-seedable) HWRNG differ in how they generate random numbers and may not use a PRNG internally. Refer to the manual of your MCU for details.

Definition in file random.h.

#include <inttypes.h>
#include <stddef.h>
+ Include dependency graph for random.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RANDOM_SEED_DEFAULT   (1)
 Seed selected when all tries to collect seeds from a random source failed.
 
#define PRNG_FLOAT   (0)
 Enables support for floating point random number generation.
 

Functions

void random_init (uint32_t s)
 initializes PRNG with a seed More...
 
void random_init_by_array (uint32_t init_key[], int key_length)
 initialize by an array with array-length init_key is the array for initializing keys key_length is its length slight change for C++, 2004/2/26 More...
 
uint32_t random_uint32 (void)
 generates a random number on [0,0xffffffff]-interval More...
 
void random_bytes (uint8_t *buf, size_t size)
 writes random bytes in the [0,0xff]-interval to memory
 
uint32_t random_uint32_range (uint32_t a, uint32_t b)
 generates a random number r with a <= r < b. More...