xref: /openbsd/lib/libc/sys/getentropy.2 (revision 76d0caae)
1.\"	$OpenBSD: getentropy.2,v 1.9 2019/09/28 14:55:12 deraadt Exp $
2.\"
3.\" Copyright (c) 2014 Theo de Raadt
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 28 2019 $
18.Dt GETENTROPY 2
19.Os
20.Sh NAME
21.Nm getentropy
22.Nd get entropy
23.Sh SYNOPSIS
24.In unistd.h
25.Ft int
26.Fn getentropy "void *buf" "size_t buflen"
27.Sh DESCRIPTION
28.Fn getentropy
29fills a buffer with high-quality entropy, which can be used
30as input for process-context pseudorandom generators like
31.Xr arc4random 3 .
32.Pp
33The maximum buffer size permitted is 256 bytes.
34.Pp
35.Fn getentropy
36is not intended for regular code; please use the
37.Xr arc4random 3
38family of functions instead.
39.Pp
40The high-quality entropy data is provided by the
41.Xr random 4
42subsystem.
43.Sh RETURN VALUES
44.Rv -std
45.Sh ERRORS
46.Fn getentropy
47will succeed unless:
48.Bl -tag -width Er
49.It Bq Er EFAULT
50The
51.Fa buf
52parameter points to an
53invalid address.
54.It Bq Er EIO
55Too many bytes requested, or some other fatal error occurred.
56.El
57.Sh SEE ALSO
58.Xr arc4random 3
59.Sh HISTORY
60The
61.Fn getentropy
62function appeared in
63.Ox 5.6 .
64