GETENTROPY(3) NetBSD Library Functions Manual GETENTROPY(3)Powered by man-cgi (2021-06-01). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.
NAME
getentropy -- fill a buffer with high quality random data
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <unistd.h> int getentropy(void *buf, size_t buflen); #include <limits.h> #define GETENTROPY_MAX 256
DESCRIPTION
The getentropy() function fills a buffer with high quality random data, suitable for seeding cryptographically secure psuedorandom number genera- tors. getentropy() is only intended for seeding random number generators and is not intended for use by regular code which simply needs secure random data. For this purpose, please use arc4random(3). The maximum value for buflen is 256 bytes.
IMPLEMENTATION NOTES
getentropy() reads from the sysctl(7) variable kern.arandom.
RETURN VALUES
The getentropy() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
ERRORS
getentropy() will succeed unless: [EFAULT] The buf argument points to an invalid memory address. [EINVAL] More than 256 bytes were requested.
SEE ALSO
arc4random(3), rnd(4)
STANDARDS
The getentropy() function is non-standard. However, it is likely to be included in the next revision of POSIX.
HISTORY
The getentropy() function first appeared in OpenBSD 5.6, then in FreeBSD 12.0, and NetBSD 10. NetBSD 10.99 May 1, 2020 NetBSD 10.99