1 .\" Copyright (C) 2017, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of
9 .\" this manual under the conditions for verbatim copying, provided that
10 .\" the entire resulting derived work is distributed under the terms of
11 .\" a permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume.
15 .\" no responsibility for errors or omissions, or for damages resulting.
16 .\" from the use of the information contained herein. The author(s) may.
17 .\" not have taken the same level of care in the production of this.
18 .\" manual, which is licensed free of charge, as they might when working.
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH GETENTROPY 3 2021-03-22 "Linux" "Linux Programmer's Manual"
27 getentropy \- fill a buffer with random bytes
30 .B #include <unistd.h>
32 .BI "int getentropy(void *" buffer ", size_t " length );
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
49 bytes of high-quality random data to the buffer starting
50 at the location pointed to by
52 The maximum permitted value for the
58 always provides the requested number of bytes of entropy.
60 On success, this function returns zero.
61 On error, \-1 is returned, and
63 is set to indicate the error.
67 Part or all of the buffer specified by
71 is not in valid addressable memory.
78 An unspecified error occurred while trying to overwrite
83 This kernel version does not implement the
85 system call required to implement this function.
89 function first appeared in glibc 2.25.
91 This function is nonstandard.
92 It is also present on OpenBSD.
96 function is implemented using
99 Whereas the glibc wrapper makes
101 a cancellation point,
103 is not a cancellation point.
108 (No feature test macro need be defined to obtain the declaration from
113 may block if the system has just booted and the kernel has
114 not yet collected enough randomness to initialize the entropy pool.
117 will keep blocking even if a signal is handled,
118 and will return only once the entropy pool has been initialized.