xref: /openbsd-src/lib/libc/sys/getentropy.2 (revision 0b7734b3d77bb9b21afec6f4621cae6c805dbd45)
1.\"	$OpenBSD: getentropy.2,v 1.8 2015/01/31 00:20:12 schwarze 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: January 31 2015 $
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.
34If
35.Fa buflen
36exceeds this, an error of
37.Er EIO
38will be indicated.
39.Pp
40.Fn getentropy
41is not intended for regular code; please use the
42.Xr arc4random 3
43family of functions instead.
44.Sh RETURN VALUES
45.Rv -std
46.Sh ERRORS
47.Fn getentropy
48will succeed unless:
49.Bl -tag -width Er
50.It Bq Er EFAULT
51The
52.Fa buf
53parameter points to an
54invalid address.
55.It Bq Er EIO
56Too many bytes requested, or some other fatal error occurred.
57.El
58.Sh SEE ALSO
59.Xr arc4random 3
60.Sh HISTORY
61The
62.Fn getentropy
63function appeared in
64.Ox 5.6 .
65