DDraceNetwork Documentation
Loading...
Searching...
No Matches
Secure Random

Functions

void generate_password (char *buffer, unsigned length, const unsigned short *random, unsigned random_length)
void secure_random_password (char *buffer, unsigned length, unsigned pw_length)
void secure_random_fill (void *bytes, unsigned length)
int secure_rand_below (int below)

Detailed Description

Secure random number generation.

Function Documentation

◆ 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
bufferPointer to the start of the output buffer.
lengthLength of the buffer.
randomPointer to a randomly-initialized array of shorts.
random_lengthLength of the short array.

◆ secure_rand_below()

int secure_rand_below ( int below)

Returns a random nonnegative integer below the given number, with a uniform distribution.

Parameters
belowUpper 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
bytesPointer to the start of the buffer.
lengthLength of the buffer.

◆ 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
bufferPointer to the start of the buffer.
lengthLength of the buffer.
pw_lengthLength of the desired password.
Remarks
The desired password length must be greater or equal to 6, even and smaller or equal to 128.