202 lines
4.2 KiB
HTML
202 lines
4.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of GETENTROPY</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>GETENTROPY</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
getentropy - fill a buffer with random bytes
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/unistd.h">unistd.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>int getentropy(void *</B><I>buffer</I><B>, size_t </B><I>length</I><B>);</B>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
<B>getentropy</B>():
|
|
|
|
<BR>
|
|
|
|
<DL COMPACT><DT id="1"><DD>
|
|
|
|
_DEFAULT_SOURCE
|
|
</DL>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>getentropy</B>()
|
|
|
|
function writes
|
|
<I>length</I>
|
|
|
|
bytes of high-quality random data to the buffer starting
|
|
at the location pointed to by
|
|
<I>buffer</I>.
|
|
|
|
The maximum permitted value for the
|
|
<I>length</I>
|
|
|
|
argument is 256.
|
|
<P>
|
|
|
|
A successful call to
|
|
<B>getentropy</B>()
|
|
|
|
always provides the requested number of bytes of entropy.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success, this function returns zero.
|
|
On error, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="2"><B>EFAULT</B>
|
|
|
|
<DD>
|
|
Part or all of the buffer specified by
|
|
<I>buffer</I>
|
|
|
|
and
|
|
<I>length</I>
|
|
|
|
is not in valid addressable memory.
|
|
<DT id="3"><B>EIO</B>
|
|
|
|
<DD>
|
|
<I>length</I>
|
|
|
|
is greater than 256.
|
|
<DT id="4"><B>EIO</B>
|
|
|
|
<DD>
|
|
An unspecified error occurred while trying to overwrite
|
|
<I>buffer</I>
|
|
|
|
with random data.
|
|
<DT id="5"><B>ENOSYS</B>
|
|
|
|
<DD>
|
|
This kernel version does not implement the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrandom">getrandom</A></B>(2)
|
|
|
|
system call required to implement this function.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
The
|
|
<B>getentropy</B>()
|
|
|
|
function first appeared in glibc 2.25.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
This function is nonstandard.
|
|
It is also present on OpenBSD.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
The
|
|
<B>getentropy</B>()
|
|
|
|
function is implemented using
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrandom">getrandom</A></B>(2).
|
|
|
|
<P>
|
|
|
|
Whereas the glibc wrapper makes
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrandom">getrandom</A></B>(2)
|
|
|
|
a cancellation point,
|
|
<B>getentropy</B>()
|
|
|
|
is not a cancellation point.
|
|
<P>
|
|
|
|
<B>getentropy</B>()
|
|
|
|
is also declared in
|
|
<B><<A HREF="file:///usr/include/sys/random.h">sys/random.h</A>></B>.
|
|
|
|
(No feature test macro need be defined to obtain the declaration from
|
|
that header file.)
|
|
<P>
|
|
|
|
A call to
|
|
<B>getentropy</B>()
|
|
|
|
may block if the system has just booted and the kernel has
|
|
not yet collected enough randomness to initialize the entropy pool.
|
|
In this case,
|
|
<B>getentropy</B>()
|
|
|
|
will keep blocking even if a signal is handled,
|
|
and will return only once the entropy pool has been initialized.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrandom">getrandom</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?4+urandom">urandom</A></B>(4),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+random">random</A></B>(7)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="10"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="11"><A HREF="#lbAG">VERSIONS</A><DD>
|
|
<DT id="12"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="13"><A HREF="#lbAI">NOTES</A><DD>
|
|
<DT id="14"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="15"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:44 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|