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.
39 .Nd supply pseudo-random numbers
43 .Fn srandom "u_long seed"
47 .Fn arc4rand "void *ptr" "u_int length" "int reseed"
53 .Fn read_random "void *buffer" "int count"
55 .Fn read_random_uio "struct uio *uio" "bool nonblock"
59 function will by default produce
61 that can be duplicated
69 function may be called with any arbitrary
71 value to get slightly more unpredictable numbers.
72 It is important to remember that the
74 function is entirely predictable,
75 and is therefore not of use where
76 knowledge of the sequence of numbers
77 may be of benefit to an attacker.
81 function will return very good quality random numbers,
83 for security-related purposes.
84 The random numbers from
86 are seeded from the entropy device
88 Automatic reseeds happen
89 after a certain timeinterval
90 and after a certain number of bytes
101 function is used to return entropy directly from the entropy device
102 if it has been loaded.
103 If the entropy device is not loaded, then
107 and zero is returned.
110 is filled with no more than
113 It is strongly advised that
125 function behaves identically to
131 argument points to a buffer where random data should be stored.
132 This function only returns data if the random device is seeded.
133 It blocks if unseeded,
138 All the bits returned by
147 will produce a random binary value.
151 is a convenience function which calls
153 to return a 32 bit pseudo-random integer.
158 a non-linear additive feedback random number generator
159 employing a default table
161 containing long integers
162 to return successive pseudo-random
163 numbers in the range from 0 to
164 .if t 2\u\s731\s10\d\(mi1.
166 The period of this random number generator
169 .if t 16\(mu(2\u\s731\s10\d\(mi1).
170 .if n 16*((2**31)\(mi1).
174 function uses the RC4 algorithm
175 to generate successive pseudo-random bytes.
180 to generate pseudo-random numbers
181 in the range from 0 to
182 .if t 2\u\s732\s10\d\(mi1.
188 the number of bytes placed in
192 returns zero when successful,
193 otherwise an error code is returned.
200 points to an invalid memory region.
201 .It Bq Er EWOULDBLOCK
202 The random device is unseeded and