70 lines
1.8 KiB
Groff
70 lines
1.8 KiB
Groff
.\" $OpenBSD: getentropy.2,v 1.11 2024/08/02 01:53:21 guenther Exp $
|
|
.\"
|
|
.\" Copyright (c) 2014 Theo de Raadt
|
|
.\"
|
|
.\" Permission to use, copy, modify, and distribute this software for any
|
|
.\" purpose with or without fee is hereby granted, provided that the above
|
|
.\" copyright notice and this permission notice appear in all copies.
|
|
.\"
|
|
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
.\"
|
|
.Dd $Mdocdate: August 2 2024 $
|
|
.Dt GETENTROPY 2
|
|
.Os
|
|
.Sh NAME
|
|
.Nm getentropy
|
|
.Nd get entropy
|
|
.Sh SYNOPSIS
|
|
.In unistd.h
|
|
.Ft int
|
|
.Fn getentropy "void *buf" "size_t buflen"
|
|
.Sh DESCRIPTION
|
|
.Fn getentropy
|
|
fills a buffer with high-quality entropy, which can be used
|
|
as input for process-context pseudorandom generators like
|
|
.Xr arc4random 3 .
|
|
.Pp
|
|
The maximum buffer size permitted is
|
|
.Dv GETENTROPY_MAX
|
|
(256) bytes.
|
|
.Pp
|
|
.Fn getentropy
|
|
is not intended for regular code; use the
|
|
.Xr arc4random 3
|
|
family of functions instead.
|
|
.Pp
|
|
The high-quality entropy data is provided by the
|
|
.Xr random 4
|
|
subsystem.
|
|
.Sh RETURN VALUES
|
|
.Rv -std
|
|
.Sh ERRORS
|
|
.Fn getentropy
|
|
will succeed unless:
|
|
.Bl -tag -width Er
|
|
.It Bq Er EFAULT
|
|
The
|
|
.Fa buf
|
|
parameter points to an
|
|
invalid address.
|
|
.It Bq Er EINVAL
|
|
Too many bytes requested.
|
|
.El
|
|
.Sh SEE ALSO
|
|
.Xr arc4random 3
|
|
.Sh STANDARDS
|
|
The
|
|
.Fn getentropy
|
|
function conforms to
|
|
.St -p1003.1-2024 .
|
|
.Sh HISTORY
|
|
The
|
|
.Fn getentropy
|
|
function appeared in
|
|
.Ox 5.6 .
|