5 .\" The Regents of the University of California. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 .Nm is_random_seeded ,
40 .Nd supply pseudo-random numbers
46 .Fn arc4random_buf "void *ptr" "size_t len"
48 .Fn arc4rand "void *ptr" "u_int length" "int reseed"
52 .Fn is_random_seeded "void"
54 .Fn read_random "void *buffer" "int count"
56 .Fn read_random_uio "struct uio *uio" "bool nonblock"
66 functions will return very good quality random numbers, suited for
67 security-related purposes.
68 Both are wrappers around the underlying
72 returns a 32-bit random value, while
85 kernel abstract entropy device.
86 Automatic reseeding happens at unspecified time and bytes (of output)
88 A reseed can be forced by passing a non-zero
94 function is used to read entropy directly from the kernel abstract entropy
97 blocks if and until the entropy device is seeded.
100 is filled with no more than
103 It is strongly advised that
105 is not used directly;
112 function can be used to check in advance if
115 (If random is seeded, it will not block.)
119 function behaves identically to
125 argument points to a buffer where random data should be stored.
128 is true and the random device is not seeded, this function does not return any
130 Otherwise, this function may block interruptibly until the random device is seeded.
131 If the function is interrupted before the random device is seeded, no data is
136 function will produce a sequence of pseudorandom numbers using a similar weak
137 linear congruential generator as
139 (the 1988 Park-Miller LCG).
140 It is obsolete and scheduled to be removed in
142 It is strongly advised that the
144 function not be used to generate random numbers.
146 .Sx SECURITY CONSIDERATIONS .
150 function uses the Chacha20 algorithm to generate a pseudo-random sequence of
156 to generate pseudo-random numbers
157 in the range from 0 to
158 .if t 2\u\s732\s10\d\(mi1.
164 the number of bytes placed in
168 returns zero when successful,
169 otherwise an error code is returned.
176 points to an invalid memory region.
177 .It Bq Er EWOULDBLOCK
178 The random device is unseeded and
189 .Sh SECURITY CONSIDERATIONS
194 It is important to remember that the
196 function is entirely predictable.
197 It is easy for attackers to predict future output of
199 by recording some generated values.
200 We cannot emphasize strongly enough that
202 must not be used to generate values that are intended to be unpredictable.