diff options
Diffstat (limited to 'src/lib/libc/stdlib/random.3')
| -rw-r--r-- | src/lib/libc/stdlib/random.3 | 25 |
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 | |||
| 92 | as the seed. | 95 | as the seed. |
| 93 | .Pp | 96 | .Pp |
| 94 | The | 97 | The |
| 98 | .Fn srandomdev | ||
| 99 | routine initialize a state array using the | ||
| 100 | .Xr arandom 4 | ||
| 101 | random number device which returns good random numbers, | ||
| 102 | suitable for cryptographic use. | ||
| 103 | Note that this particular seeding procedure can generate | ||
| 104 | states which are impossible to reproduce by calling | ||
| 105 | .Fn srandom | ||
| 106 | with any value, since the succeeding terms in the | ||
| 107 | state buffer are no longer derived from the LC algorithm applied to | ||
| 108 | a fixed seed. | ||
| 109 | .Pp | ||
| 110 | The | ||
| 95 | .Fn initstate | 111 | .Fn initstate |
| 96 | routine allows a state array, passed in as an argument, to be initialized | 112 | routine allows a state array, passed in as an argument, to be initialized |
| 97 | for future use. The size of the state array (in bytes) is used by | 113 | 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. | |||
| 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 |
| 158 | The | 175 | The |
| 159 | .Fn random , | 176 | .Fn random , |
| @@ -163,6 +180,10 @@ and | |||
| 163 | .Fn setstate | 180 | .Fn setstate |
| 164 | functions conform to | 181 | functions conform to |
| 165 | .St -xpg4.2 . | 182 | .St -xpg4.2 . |
| 183 | .Pp | ||
| 184 | The | ||
| 185 | .Fn srandomdev | ||
| 186 | function is an extension. | ||
| 166 | .Sh HISTORY | 187 | .Sh HISTORY |
| 167 | These | 188 | These |
| 168 | functions appeared in | 189 | functions appeared in |
