15 #include <sys/random.h>
22 errno_t __cdecl rand_s( _Out_
unsigned int* _RandomValue );
29 coap_prng_impl(
unsigned char *buf,
size_t len ) {
33 if ( rand_s( &r ) != 0 )
35 for ( i = 0; i < len && i < 4; i++ ) {
49 return getrandom(buf, len, 0);
52 return coap_prng_impl(buf,len);
54 unsigned char *dst = (
unsigned char *)buf;
56 *dst++ = rand() & 0xFF;
64 #if defined(WITH_CONTIKI)
66 #elif defined(WITH_LWIP) && defined(LWIP_RAND)
Pulls together all the internal only header files.
static int coap_prng_default(void *buf, size_t len)
static coap_rand_func_t rand_func
int(* coap_rand_func_t)(void *out, size_t len)
Data type for random number generator function.
void coap_set_prng(coap_rand_func_t rng)
Replaces the current random number generation function with the default function rng.
int coap_prng(void *buf, size_t len)
Fills buf with len random bytes using the default pseudo random number generator.
void coap_prng_init(unsigned int seed)
Seeds the default random number generation function with the given seed.
#define COAP_STATIC_INLINE