libcoap 4.3.5-develop-19cef11
|
API for generating pseudo random numbers. More...
Typedefs | |
typedef int(* | coap_rand_func_t) (void *out, size_t len) |
Data type for random number generator function. More... | |
Functions | |
void | coap_set_prng (coap_rand_func_t rng) |
Replaces the current random number generation function with the default function rng . More... | |
COAP_API void | coap_prng_init (unsigned int seed) |
Seeds the default random number generation function with the given seed . More... | |
COAP_API int | coap_prng (void *buf, size_t len) |
Fills buf with len random bytes using the default pseudo random number generator. More... | |
API for generating pseudo random numbers.
typedef int(* coap_rand_func_t) (void *out, size_t len) |
Data type for random number generator function.
The function must fill len
bytes of random data into the buffer starting at out
. On success, the function should return 1, zero otherwise.
Definition at line 32 of file coap_prng.h.
COAP_API int coap_prng | ( | void * | buf, |
size_t | len | ||
) |
Fills buf
with len
random bytes using the default pseudo random number generator.
The default PRNG can be changed with coap_set_prng(). This function returns 1 when len
random bytes have been written to buf
, zero otherwise.
buf | The buffer to fill with random bytes. |
len | The number of random bytes to write into buf . |
Definition at line 66 of file coap_prng.c.
COAP_API void coap_prng_init | ( | unsigned int | seed | ) |
Seeds the default random number generation function with the given seed
.
The default random number generation function will use getrandom() if available, ignoring the seed.
seed | The seed for the pseudo random number generator. |
Definition at line 59 of file coap_prng.c.
void coap_set_prng | ( | coap_rand_func_t | rng | ) |
Replaces the current random number generation function with the default function rng
.
rng | The random number generation function to use. |
Definition at line 161 of file coap_prng.c.