Cryptographically relevant random numbers.
More...
#include <secure.h>
|
static size_t | fill (uint8_t *memory, size_t size) |
| Fill memory with pseudo-random values.
|
|
static int | get (int min, int max) |
| Get a pseudo-random integer in a preset range.
|
|
static int | get (void) |
| Get a pseudo-random integer, range 0 - 32767.
|
|
static size_t | key (uint8_t *memory, size_t size) |
| Get high-entropy random data.
|
|
static double | real (double min, double max) |
| Get a pseudo-random floating point value in a preset range.
|
|
static double | real (void) |
| Get a pseudo-random floating point value.
|
|
static bool | seed (const uint8_t *buffer, size_t size) |
| Push entropic seed.
|
|
static void | seed (void) |
| Re-seed pseudo-random generation and entropy pools.
|
|
static bool | status (void) |
| Determine if we have sufficient entropy to return random values.
|
|
static void | uuid (char *string) |
| Create 36 character random uuid string.
|
|
static secure::string | uuid (void) |
|
template<class T > |
static T | value (T max) |
|
template<class T > |
static T | value (T min, T max) |
|
template<class T > |
static T | value (void) |
|
Cryptographically relevant random numbers.
This is used both to gather entropy pools and pseudo-random values.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 765 of file secure.h.
◆ fill()
static size_t ucommon::Random::fill |
( |
uint8_t * | memory, |
|
|
size_t | size ) |
|
static |
Fill memory with pseudo-random values.
This is used as the basis for all get and real operations and does not depend on seed entropy.
- Parameters
-
memory | buffer to fill. |
size | of buffer to fill. |
- Returns
- number of bytes set.
◆ get() [1/2]
static int ucommon::Random::get |
( |
int | min, |
|
|
int | max ) |
|
static |
Get a pseudo-random integer in a preset range.
- Parameters
-
min | value of random integer. |
max | value of random integer. |
- Returns
- random value from min to max.
◆ get() [2/2]
static int ucommon::Random::get |
( |
void | | ) |
|
|
static |
Get a pseudo-random integer, range 0 - 32767.
- Returns
- random integer.
◆ key()
static size_t ucommon::Random::key |
( |
uint8_t * | memory, |
|
|
size_t | size ) |
|
static |
Get high-entropy random data.
This is often used to initialize keys. This operation may block if there is insufficient entropy immediately available.
- Parameters
-
memory | buffer to fill. |
size | of buffer. |
- Returns
- number of bytes filled.
◆ real() [1/2]
static double ucommon::Random::real |
( |
double | min, |
|
|
double | max ) |
|
static |
Get a pseudo-random floating point value in a preset range.
- Parameters
-
min | value of random floating point number. |
max | value of random floating point number. |
- Returns
- random value from min to max.
◆ real() [2/2]
static double ucommon::Random::real |
( |
void | | ) |
|
|
static |
Get a pseudo-random floating point value.
- Returns
- psudo-random value 0 to 1.
◆ seed()
static bool ucommon::Random::seed |
( |
const uint8_t * | buffer, |
|
|
size_t | size ) |
|
static |
Push entropic seed.
- Parameters
-
buffer | of random data to push. |
size | of buffer. |
- Returns
- true if successful.
◆ status()
static bool ucommon::Random::status |
( |
void | | ) |
|
|
static |
Determine if we have sufficient entropy to return random values.
- Returns
- true if sufficient entropy.
◆ uuid()
static void ucommon::Random::uuid |
( |
char * | string | ) |
|
|
static |
Create 36 character random uuid string.
- Parameters
-
string | to write uuid into, must be 37 bytes or more. |
◆ value() [1/3]
template<class T >
static T ucommon::Random::value |
( |
T | max | ) |
|
|
inlinestatic |
◆ value() [2/3]
template<class T >
static T ucommon::Random::value |
( |
T | min, |
|
|
T | max ) |
|
inlinestatic |
◆ value() [3/3]
template<class T >
static T ucommon::Random::value |
( |
void | | ) |
|
|
inlinestatic |
The documentation for this class was generated from the following file:
- /builddir/build/BUILD/ucommon-7.0.0-build/ucommon-7.0.0/inc/ucommon/secure.h