diff options
Diffstat (limited to 'src/lib/libc/crypt/arc4random.3')
| -rw-r--r-- | src/lib/libc/crypt/arc4random.3 | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/src/lib/libc/crypt/arc4random.3 b/src/lib/libc/crypt/arc4random.3 deleted file mode 100644 index 476bc28017..0000000000 --- a/src/lib/libc/crypt/arc4random.3 +++ /dev/null | |||
| @@ -1,114 +0,0 @@ | |||
| 1 | .\" $OpenBSD: arc4random.3,v 1.32 2013/10/22 06:51:41 jmc Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> | ||
| 4 | .\" All rights reserved. | ||
| 5 | .\" | ||
| 6 | .\" Redistribution and use in source and binary forms, with or without | ||
| 7 | .\" modification, are permitted provided that the following conditions | ||
| 8 | .\" are met: | ||
| 9 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 10 | .\" notice, this list of conditions and the following disclaimer. | ||
| 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 12 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 13 | .\" documentation and/or other materials provided with the distribution. | ||
| 14 | .\" 3. All advertising materials mentioning features or use of this software | ||
| 15 | .\" must display the following acknowledgement: | ||
| 16 | .\" This product includes software developed by Niels Provos. | ||
| 17 | .\" 4. The name of the author may not be used to endorse or promote products | ||
| 18 | .\" derived from this software without specific prior written permission. | ||
| 19 | .\" | ||
| 20 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| 21 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 22 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| 23 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 24 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 25 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 26 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 27 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 28 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 29 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 30 | .\" | ||
| 31 | .\" Manual page, using -mandoc macros | ||
| 32 | .\" | ||
| 33 | .Dd $Mdocdate: October 22 2013 $ | ||
| 34 | .Dt ARC4RANDOM 3 | ||
| 35 | .Os | ||
| 36 | .Sh NAME | ||
| 37 | .Nm arc4random , | ||
| 38 | .Nm arc4random_buf , | ||
| 39 | .Nm arc4random_uniform | ||
| 40 | .Nd random number generator | ||
| 41 | .Sh SYNOPSIS | ||
| 42 | .In stdlib.h | ||
| 43 | .Ft u_int32_t | ||
| 44 | .Fn arc4random "void" | ||
| 45 | .Ft void | ||
| 46 | .Fn arc4random_buf "void *buf" "size_t nbytes" | ||
| 47 | .Ft u_int32_t | ||
| 48 | .Fn arc4random_uniform "u_int32_t upper_bound" | ||
| 49 | .Sh DESCRIPTION | ||
| 50 | This family of functions provides higher quality data than those | ||
| 51 | described in | ||
| 52 | .Xr rand 3 , | ||
| 53 | .Xr random 3 , | ||
| 54 | and | ||
| 55 | .Xr drand48 3 . | ||
| 56 | .Pp | ||
| 57 | Use of these functions is encouraged for almost all random number | ||
| 58 | consumption because the other interfaces are deficient in either | ||
| 59 | quality, portability, standardization, or availability. | ||
| 60 | These functions can be called in almost all coding environments, | ||
| 61 | including | ||
| 62 | .Xr pthreads 3 | ||
| 63 | and | ||
| 64 | .Xr chroot 2 . | ||
| 65 | .Pp | ||
| 66 | High quality 32-bit pseudo-random numbers are generated very quickly. | ||
| 67 | On each call, a cryptographic pseudo-random number generator is used | ||
| 68 | to generate a new result. | ||
| 69 | One data pool is used for all consumers in a process, so that consumption | ||
| 70 | under program flow can act as additional stirring. | ||
| 71 | The subsystem is re-seeded from the kernel random number subsystem using | ||
| 72 | .Xr sysctl 3 | ||
| 73 | on a regular basis, and also upon | ||
| 74 | .Xr fork 2 . | ||
| 75 | .Pp | ||
| 76 | The | ||
| 77 | .Fn arc4random | ||
| 78 | function returns a single 32-bit value. | ||
| 79 | .Pp | ||
| 80 | .Fn arc4random_buf | ||
| 81 | fills the region | ||
| 82 | .Fa buf | ||
| 83 | of length | ||
| 84 | .Fa nbytes | ||
| 85 | with random data. | ||
| 86 | .Pp | ||
| 87 | .Fn arc4random_uniform | ||
| 88 | will return a single 32-bit value, uniformly distributed but less than | ||
| 89 | .Fa upper_bound . | ||
| 90 | This is recommended over constructions like | ||
| 91 | .Dq Li arc4random() % upper_bound | ||
| 92 | as it avoids "modulo bias" when the upper bound is not a power of two. | ||
| 93 | In the worst case, this function may consume multiple iterations | ||
| 94 | to ensure uniformity; see the source code to understand the problem | ||
| 95 | and solution. | ||
| 96 | .Sh RETURN VALUES | ||
| 97 | These functions are always successful, and no return value is | ||
| 98 | reserved to indicate an error. | ||
| 99 | .Sh SEE ALSO | ||
| 100 | .Xr rand 3 , | ||
| 101 | .Xr rand48 3 , | ||
| 102 | .Xr random 3 | ||
| 103 | .Sh HISTORY | ||
| 104 | These functions first appeared in | ||
| 105 | .Ox 2.1 . | ||
| 106 | .Pp | ||
| 107 | The original version of this random number generator used the | ||
| 108 | RC4 (also known as ARC4) algorithm. | ||
| 109 | In | ||
| 110 | .Ox 5.5 | ||
| 111 | it was replaced with the ChaCha20 cipher, and it may be replaced | ||
| 112 | again in the future as cryptographic techniques advance. | ||
| 113 | A good mnemonic is | ||
| 114 | .Dq A Replacement Call for Random . | ||
