diff options
Diffstat (limited to 'share/man/man9/random.9')
-rw-r--r-- | share/man/man9/random.9 | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/share/man/man9/random.9 b/share/man/man9/random.9 index a6bccda..68df7dc 100644 --- a/share/man/man9/random.9 +++ b/share/man/man9/random.9 @@ -1,4 +1,6 @@ .\" +.\" Copyright (c) 2015 +.\" Mark R V Murray .\" Copyright (c) 2000 .\" The Regents of the University of California. All rights reserved. .\" @@ -26,7 +28,7 @@ .\" .\" $FreeBSD$ .\" " -.Dd September 25, 2000 +.Dd June 30, 2015 .Dt RANDOM 9 .Os .Sh NAME @@ -53,11 +55,12 @@ .Sh DESCRIPTION The .Fn random -function will by default produce a sequence of numbers that can be duplicated +function will by default produce +a sequence of numbers +that can be duplicated by calling .Fn srandom -with -.Ql 1 +with some constant as the .Fa seed . The @@ -67,19 +70,28 @@ function may be called with any arbitrary value to get slightly more unpredictable numbers. It is important to remember that the .Fn random -function is entirely predictable, and is therefore not of use where -knowledge of the sequence of numbers may be of benefit to an attacker. +function is entirely predictable, +and is therefore not of use where +knowledge of the sequence of numbers +may be of benefit to an attacker. .Pp The .Fn arc4rand -function will return very good quality random numbers, slightly better -suited for security-related purposes. +function will return very good quality random numbers, +better suited +for security-related purposes. The random numbers from .Fn arc4rand -are seeded from the entropy device if it is available. -Automatic reseeds happen after a certain timeinterval and after a -certain number of bytes have been delivered. -A forced reseed can be forced by passing a non-zero value in the +are seeded from the entropy device +if it is available. +Automatic reseeds happen +after a certain timeinterval +and after a certain number of bytes +have been delivered. +A forced reseed +can be forced +by passing a non-zero +value in the .Fa reseed argument. .Pp @@ -90,19 +102,24 @@ if it has been loaded. If the entropy device is not loaded, then the .Fa buffer -is filled with output generated by -.Fn random . +is ignored +and zero is returned. The .Fa buffer is filled with no more than .Fa count bytes. -It is advised that +It is strongly advised that .Fn read_random -is not used; instead use +is not used; +instead use .Fn arc4rand +unless it is +necessary to know +that no entropy +has been returned. .Pp -All the bits generated by +All the bits returned by .Fn random , .Fn arc4rand and @@ -120,32 +137,38 @@ to return a 32 bit pseudo-random integer. .Sh RETURN VALUES The .Fn random -function -uses a non-linear additive feedback random number generator employing a -default table of size 31 long integers to return successive pseudo-random +function uses +a non-linear additive feedback random number generator +employing a default table +of size 31 +containing long integers +to return successive pseudo-random numbers in the range from 0 to .if t 2\u\s731\s10\d\(mi1. .if n (2**31)\(mi1. -The period of this random number generator is very large, approximately +The period of this random number generator +is very large, +approximately .if t 16\(mu(2\u\s731\s10\d\(mi1). .if n 16*((2**31)\(mi1). .Pp The .Fn arc4rand -function uses the RC4 algorithm to generate successive pseudo-random -bytes. +function uses the RC4 algorithm +to generate successive pseudo-random bytes. The .Fn arc4random -function -uses +function uses .Fn arc4rand -to generate pseudo-random numbers in the range from 0 to +to generate pseudo-random numbers +in the range from 0 to .if t 2\u\s732\s10\d\(mi1. .if n (2**32)\(mi1. .Pp The .Fn read_random -function returns the number of bytes placed in +function returns +the number of bytes placed in .Fa buffer . .Sh AUTHORS .An Dan Moschuk |