3 .\" The Regents of the University of California. All rights reserved.
5 .\" 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.
29 .Dd September 25, 2000
38 .Nd supply pseudo-random numbers
42 .Fn srandom "u_long seed"
46 .Fn arc4rand "void *ptr" "u_int length" "int reseed"
52 .Fn read_random "void *buffer" "int count"
56 function will by default produce a sequence of numbers that can be duplicated
65 function may be called with any arbitrary
67 value to get slightly more unpredictable numbers.
68 It is important to remember that the
70 function is entirely predictable, and is therefore not of use where
71 knowledge of the sequence of numbers may be of benefit to an attacker.
75 function will return very good quality random numbers, slightly better
76 suited for security-related purposes.
77 The random numbers from
79 are seeded from the entropy device if it is available.
80 Automatic reseeds happen after a certain timeinterval and after a
81 certain number of bytes have been delivered.
82 A forced reseed can be forced by passing a non-zero value in the
88 function is used to return entropy directly from the entropy device
89 if it has been loaded.
90 If the entropy device is not loaded, then
93 is filled with output generated by
97 is filled with no more than
102 is not used; instead use
105 All the bits generated by
113 will produce a random binary value.
117 is a convenience function which calls
119 to return a 32 bit pseudo-random integer.
124 uses a non-linear additive feedback random number generator employing a
125 default table of size 31 long integers to return successive pseudo-random
126 numbers in the range from 0 to
127 .if t 2\u\s731\s10\d\(mi1.
129 The period of this random number generator is very large, approximately
130 .if t 16\(mu(2\u\s731\s10\d\(mi1).
131 .if n 16*((2**31)\(mi1).
135 function uses the RC4 algorithm to generate successive pseudo-random
142 to generate pseudo-random numbers in the range from 0 to
143 .if t 2\u\s732\s10\d\(mi1.
148 function returns the number of bytes placed in