The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
random.h File Reference

random bytes from the kernel's generator (getrandom). More...

#include <sys/types.h>

Go to the source code of this file.

Macros

#define GRND_NONBLOCK   0x0001
#define GRND_RANDOM   0x0002
#define GRND_INSECURE   0x0004

Functions

ssize_t getrandom (void *buf, size_t length, unsigned int flags)
 fill buf with length random bytes.

Detailed Description

random bytes from the kernel's generator (getrandom).

Macro Definition Documentation

◆ GRND_NONBLOCK

#define GRND_NONBLOCK   0x0001

◆ GRND_RANDOM

#define GRND_RANDOM   0x0002

◆ GRND_INSECURE

#define GRND_INSECURE   0x0004

Function Documentation

◆ getrandom()

ssize_t getrandom ( void * buf,
size_t length,
unsigned int flags )

fill buf with length random bytes.

waits until the kernel's generator is seeded (early at boot only), unless GRND_NONBLOCK or GRND_INSECURE.

Returns
the bytes given (a long request can stop early at a signal), or -1 with errno EAGAIN, EINTR, EINVAL or EFAULT.