Secure random number generation.
◆ generate_password()
void generate_password |
( |
char * |
buffer, |
|
|
unsigned |
length, |
|
|
const unsigned short * |
random, |
|
|
unsigned |
random_length |
|
) |
| |
Generates a null-terminated password of length 2 * random_length
.
- Parameters
-
buffer | Pointer to the start of the output buffer. |
length | Length of the buffer. |
random | Pointer to a randomly-initialized array of shorts. |
random_length | Length of the short array. |
◆ secure_rand()
Returns random int
.
- Returns
- Random int.
◆ secure_rand_below()
int secure_rand_below |
( |
int |
below | ) |
|
Returns a random nonnegative integer below the given number, with a uniform distribution.
- Parameters
-
below | Upper limit (exclusive) of integers to return. |
- Returns
- Random nonnegative below the given number.
◆ secure_random_fill()
void secure_random_fill |
( |
void * |
bytes, |
|
|
unsigned |
length |
|
) |
| |
Fills the buffer with the specified amount of random bytes.
- Parameters
-
buffer | Pointer to the start of the buffer. |
length | Length of the buffer. |
◆ secure_random_init()
int secure_random_init |
( |
| ) |
|
Initializes the secure random module. You MUST check the return value of this function.
- Returns
0
on success.
◆ secure_random_password()
void secure_random_password |
( |
char * |
buffer, |
|
|
unsigned |
length, |
|
|
unsigned |
pw_length |
|
) |
| |
Fills the buffer with the specified amount of random password characters.
- Parameters
-
buffer | Pointer to the start of the buffer. |
length | Length of the buffer. |
pw_length | Length of the desired password. |
◆ secure_random_uninit()
int secure_random_uninit |
( |
| ) |
|
Uninitializes the secure random module.
- Returns
0
on success.