Functions

void get_rand_128 (rng_128_t *rand128)
 Get 128-bit random numberThis method may be safely called from either core or from an IRQ, but be careful in the latter case as the call may block for a number of microseconds waiting on more entropy. More...
 
uint64_t get_rand_64 (void)
 Get 64-bit random numberThis method may be safely called from either core or from an IRQ, but be careful in the latter case as the call may block for a number of microseconds waiting on more entropy. More...
 
uint32_t get_rand_32 (void)
 Get 32-bit random numberThis method may be safely called from either core or from an IRQ, but be careful in the latter case as the call may block for a number of microseconds waiting on more entropy. More...
 

Detailed Description

Random Number Generator API

This module generates random numbers at runtime utilizing a number of possible entropy sources and uses those sources to modify the state of a 128-bit 'Pseudo Random Number Generator' implemented in software.

The random numbers (32 to 128 bit) to be supplied are read from the PRNG which is used to help provide a large number space.

The following (multiple) sources of entropy are available (of varying quality), each enabled by a #define:

Note
All entropy sources are hashed before application to the PRNG state machine.
The first time a random number is requested, the 128-bit PRNG state must be seeded. Multiple entropy sources are also available for the seeding operation:

With default settings, the seed generation takes approximately 1 millisecond while subsequent random numbers generally take between 10 and 20 microseconds to generate.

pico_rand methods may be safely called from either core or from an IRQ, but be careful in the latter case as the calls may block for a number of microseconds waiting on more entropy.

Function Documentation

◆ get_rand_128()

void get_rand_128 ( rng_128_t rand128)

Get 128-bit random numberThis method may be safely called from either core or from an IRQ, but be careful in the latter case as the call may block for a number of microseconds waiting on more entropy.

Parameters
rand128Pointer to storage to accept a 128-bit random number

◆ get_rand_32()

uint32_t get_rand_32 ( void  )

Get 32-bit random numberThis method may be safely called from either core or from an IRQ, but be careful in the latter case as the call may block for a number of microseconds waiting on more entropy.

Returns
32-bit random number

◆ get_rand_64()

uint64_t get_rand_64 ( void  )

Get 64-bit random numberThis method may be safely called from either core or from an IRQ, but be careful in the latter case as the call may block for a number of microseconds waiting on more entropy.

Returns
64-bit random number