|
@ -29,7 +29,7 @@ |
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
|
.\" SUCH DAMAGE. |
|
|
.\" SUCH DAMAGE. |
|
|
.\" |
|
|
.\" |
|
|
.\" $OpenBSD: random.3,v 1.10 2000/01/19 05:25:43 pjanzen Exp $ |
|
|
|
|
|
|
|
|
.\" $OpenBSD: random.3,v 1.11 2000/04/03 23:23:48 millert Exp $ |
|
|
.\" |
|
|
.\" |
|
|
.Dd April 19, 1991 |
|
|
.Dd April 19, 1991 |
|
|
.Dt RANDOM 3 |
|
|
.Dt RANDOM 3 |
|
@ -37,6 +37,7 @@ |
|
|
.Sh NAME |
|
|
.Sh NAME |
|
|
.Nm random , |
|
|
.Nm random , |
|
|
.Nm srandom , |
|
|
.Nm srandom , |
|
|
|
|
|
.Nm srandomdev , |
|
|
.Nm initstate , |
|
|
.Nm initstate , |
|
|
.Nm setstate |
|
|
.Nm setstate |
|
|
.Nd better random number generator; routines for changing generators |
|
|
.Nd better random number generator; routines for changing generators |
|
@ -46,6 +47,8 @@ |
|
|
.Fn random void |
|
|
.Fn random void |
|
|
.Ft void |
|
|
.Ft void |
|
|
.Fn srandom "unsigned int seed" |
|
|
.Fn srandom "unsigned int seed" |
|
|
|
|
|
.Ft void |
|
|
|
|
|
.Fn srandomdev void |
|
|
.Ft char * |
|
|
.Ft char * |
|
|
.Fn initstate "unsigned int seed" "char *state" "size_t n" |
|
|
.Fn initstate "unsigned int seed" "char *state" "size_t n" |
|
|
.Ft char * |
|
|
.Ft char * |
|
@ -92,6 +95,19 @@ with |
|
|
as the seed. |
|
|
as the seed. |
|
|
.Pp |
|
|
.Pp |
|
|
The |
|
|
The |
|
|
|
|
|
.Fn srandomdev |
|
|
|
|
|
routine initialize a state array using the |
|
|
|
|
|
.Xr arandom 4 |
|
|
|
|
|
random number device which returns good random numbers, |
|
|
|
|
|
suitable for cryptographic use. |
|
|
|
|
|
Note that this particular seeding procedure can generate |
|
|
|
|
|
states which are impossible to reproduce by calling |
|
|
|
|
|
.Fn srandom |
|
|
|
|
|
with any value, since the succeeding terms in the |
|
|
|
|
|
state buffer are no longer derived from the LC algorithm applied to |
|
|
|
|
|
a fixed seed. |
|
|
|
|
|
.Pp |
|
|
|
|
|
The |
|
|
.Fn initstate |
|
|
.Fn initstate |
|
|
routine allows a state array, passed in as an argument, to be initialized |
|
|
routine allows a state array, passed in as an argument, to be initialized |
|
|
for future use. The size of the state array (in bytes) is used by |
|
|
for 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. |
|
|
.Sh SEE ALSO |
|
|
.Sh SEE ALSO |
|
|
.Xr arc4random 3 , |
|
|
.Xr arc4random 3 , |
|
|
.Xr drand48 3 , |
|
|
.Xr drand48 3 , |
|
|
.Xr rand 3 |
|
|
|
|
|
|
|
|
.Xr rand 3 , |
|
|
|
|
|
.Xr random 4 , |
|
|
.Sh STANDARDS |
|
|
.Sh STANDARDS |
|
|
The |
|
|
The |
|
|
.Fn random , |
|
|
.Fn random , |
|
@ -163,6 +180,10 @@ and |
|
|
.Fn setstate |
|
|
.Fn setstate |
|
|
functions conform to |
|
|
functions conform to |
|
|
.St -xpg4.2 . |
|
|
.St -xpg4.2 . |
|
|
|
|
|
.Pp |
|
|
|
|
|
The |
|
|
|
|
|
.Fn srandomdev |
|
|
|
|
|
function is an extension. |
|
|
.Sh HISTORY |
|
|
.Sh HISTORY |
|
|
These |
|
|
These |
|
|
functions appeared in |
|
|
functions appeared in |
|
|