summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/random.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/random.3')
-rw-r--r--src/lib/libc/stdlib/random.325
1 files changed, 23 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/random.3 b/src/lib/libc/stdlib/random.3
index 9558a672eb..260c239816 100644
--- a/src/lib/libc/stdlib/random.3
+++ b/src/lib/libc/stdlib/random.3
@@ -29,7 +29,7 @@
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" $OpenBSD: random.3,v 1.10 2000/01/19 05:25:43 pjanzen Exp $ 32.\" $OpenBSD: random.3,v 1.11 2000/04/03 23:23:48 millert Exp $
33.\" 33.\"
34.Dd April 19, 1991 34.Dd April 19, 1991
35.Dt RANDOM 3 35.Dt RANDOM 3
@@ -37,6 +37,7 @@
37.Sh NAME 37.Sh NAME
38.Nm random , 38.Nm random ,
39.Nm srandom , 39.Nm srandom ,
40.Nm srandomdev ,
40.Nm initstate , 41.Nm initstate ,
41.Nm setstate 42.Nm setstate
42.Nd better random number generator; routines for changing generators 43.Nd better random number generator; routines for changing generators
@@ -46,6 +47,8 @@
46.Fn random void 47.Fn random void
47.Ft void 48.Ft void
48.Fn srandom "unsigned int seed" 49.Fn srandom "unsigned int seed"
50.Ft void
51.Fn srandomdev void
49.Ft char * 52.Ft char *
50.Fn initstate "unsigned int seed" "char *state" "size_t n" 53.Fn initstate "unsigned int seed" "char *state" "size_t n"
51.Ft char * 54.Ft char *
@@ -92,6 +95,19 @@ with
92as the seed. 95as the seed.
93.Pp 96.Pp
94The 97The
98.Fn srandomdev
99routine initialize a state array using the
100.Xr arandom 4
101random number device which returns good random numbers,
102suitable for cryptographic use.
103Note that this particular seeding procedure can generate
104states which are impossible to reproduce by calling
105.Fn srandom
106with any value, since the succeeding terms in the
107state buffer are no longer derived from the LC algorithm applied to
108a fixed seed.
109.Pp
110The
95.Fn initstate 111.Fn initstate
96routine allows a state array, passed in as an argument, to be initialized 112routine allows a state array, passed in as an argument, to be initialized
97for future use. The size of the state array (in bytes) is used by 113for future use. The size of the state array (in bytes) is used by
@@ -153,7 +169,8 @@ messages are printed on the standard error output.
153.Sh SEE ALSO 169.Sh SEE ALSO
154.Xr arc4random 3 , 170.Xr arc4random 3 ,
155.Xr drand48 3 , 171.Xr drand48 3 ,
156.Xr rand 3 172.Xr rand 3 ,
173.Xr random 4 ,
157.Sh STANDARDS 174.Sh STANDARDS
158The 175The
159.Fn random , 176.Fn random ,
@@ -163,6 +180,10 @@ and
163.Fn setstate 180.Fn setstate
164functions conform to 181functions conform to
165.St -xpg4.2 . 182.St -xpg4.2 .
183.Pp
184The
185.Fn srandomdev
186function is an extension.
166.Sh HISTORY 187.Sh HISTORY
167These 188These
168functions appeared in 189functions appeared in