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