getentropy(2) - OpenBSD manual pages (original) (raw)
NAME
getentropy
—get entropy
SYNOPSIS
#include <unistd.h>
intgetentropy
(void *buf, size_t buflen);
DESCRIPTION
getentropy() fills a buffer with high-quality entropy, which can be used as input for process-context pseudorandom generators likearc4random(3).
The maximum buffer size permitted isGETENTROPY_MAX
(256) bytes.
getentropy() is not intended for regular code; use thearc4random(3) family of functions instead.
The high-quality entropy data is provided by therandom(4) subsystem.
RETURN VALUES
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variableerrno is set to indicate the error.
ERRORS
getentropy
() will succeed unless:
[EFAULT]
The buf parameter points to an invalid address.
[EINVAL]
Too many bytes requested.
SEE ALSO
STANDARDS
The getentropy
() function conforms toIEEE Std 1003.1-2024 (“POSIX.1”).
HISTORY
The getentropy
() function appeared inOpenBSD 5.6.