diff options
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/crypt/Makefile.inc | 5 | ||||
| -rw-r--r-- | src/lib/libc/crypt/arc4random.3 | 82 |
2 files changed, 85 insertions, 2 deletions
diff --git a/src/lib/libc/crypt/Makefile.inc b/src/lib/libc/crypt/Makefile.inc index af67278f44..d353236231 100644 --- a/src/lib/libc/crypt/Makefile.inc +++ b/src/lib/libc/crypt/Makefile.inc | |||
| @@ -1,11 +1,12 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.7 1997/02/16 20:58:11 provos Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.8 1997/04/15 13:06:54 provos Exp $ |
| 2 | 2 | ||
| 3 | .PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/crypt ${.CURDIR}/crypt | 3 | .PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/crypt ${.CURDIR}/crypt |
| 4 | 4 | ||
| 5 | SRCS+= crypt.c morecrypt.c md5crypt.c arc4random.c blowfish.c | 5 | SRCS+= crypt.c morecrypt.c md5crypt.c arc4random.c blowfish.c |
| 6 | SRCS+= bcrypt.c | 6 | SRCS+= bcrypt.c |
| 7 | 7 | ||
| 8 | MAN+= crypt.3 blowfish.3 | 8 | MAN+= crypt.3 blowfish.3 arc4random.3 |
| 9 | MLINKS+=crypt.3 encrypt.3 crypt.3 setkey.3 crypt.3 des_cipher.3 | 9 | MLINKS+=crypt.3 encrypt.3 crypt.3 setkey.3 crypt.3 des_cipher.3 |
| 10 | MLINKS+=crypt.3 des_setkey.3 blowfish.3 blf_key.3 blowfish.3 blf_enc.3 | 10 | MLINKS+=crypt.3 des_setkey.3 blowfish.3 blf_key.3 blowfish.3 blf_enc.3 |
| 11 | MLINKS+=blowfish.3 blf_dec.3 | 11 | MLINKS+=blowfish.3 blf_dec.3 |
| 12 | MLINKS+=arc4ranom.3 arc4random_stir.3 arc4random.3 arc4random_addrandom.3 | ||
diff --git a/src/lib/libc/crypt/arc4random.3 b/src/lib/libc/crypt/arc4random.3 new file mode 100644 index 0000000000..71a3c003f6 --- /dev/null +++ b/src/lib/libc/crypt/arc4random.3 | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | .\" $OpenBSD: arc4random.3,v 1.1 1997/04/15 13:06:54 provos Exp $ | ||
| 2 | .\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> | ||
| 3 | .\" All rights reserved. | ||
| 4 | .\" | ||
| 5 | .\" Redistribution and use in source and binary forms, with or without | ||
| 6 | .\" modification, are permitted provided that the following conditions | ||
| 7 | .\" are met: | ||
| 8 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 9 | .\" notice, this list of conditions and the following disclaimer. | ||
| 10 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 12 | .\" documentation and/or other materials provided with the distribution. | ||
| 13 | .\" 3. All advertising materials mentioning features or use of this software | ||
| 14 | .\" must display the following acknowledgement: | ||
| 15 | .\" This product includes software developed by Niels Provos. | ||
| 16 | .\" 4. The name of the author may not be used to endorse or promote products | ||
| 17 | .\" derived from this software without specific prior written permission. | ||
| 18 | .\" | ||
| 19 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| 20 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 21 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| 22 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 23 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 24 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 25 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 26 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 27 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 28 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 29 | .\" | ||
| 30 | .\" Manual page, using -mandoc macros | ||
| 31 | .\" | ||
| 32 | .Dd April 15, 1997 | ||
| 33 | .Dt ARC4RANDOM 3 | ||
| 34 | .Os "OpenBSD 2.0" | ||
| 35 | .Sh NAME | ||
| 36 | .Nm arc4random, | ||
| 37 | .Nm arc4random_stir, | ||
| 38 | .Nm arc4random_addrandom | ||
| 39 | .Nd arc4 random number generator. | ||
| 40 | .Sh SYNOPSIS | ||
| 41 | .Fd #include <stdlib.h> | ||
| 42 | .Ft void | ||
| 43 | .Fn arc4random "void" | ||
| 44 | .Ft void | ||
| 45 | .Fn arc4random_stir "void" | ||
| 46 | .Ft void | ||
| 47 | .Fn arc4random_addrandom "u_char *dat" "int datlen" | ||
| 48 | .Sh DESCRIPTION | ||
| 49 | The | ||
| 50 | .Fn arc4random | ||
| 51 | function uses the key stream generator employed by the | ||
| 52 | arc4 cipher, which uses 8*8 8 bit S-Boxes. The S-Boxes | ||
| 53 | can be in about | ||
| 54 | .if t 2\u\s71700\s10\d | ||
| 55 | .if n (2**1700) | ||
| 56 | states. | ||
| 57 | .Pp | ||
| 58 | The | ||
| 59 | .Fn arc4random_stir | ||
| 60 | function reads data from | ||
| 61 | .Pa /dev/arandom | ||
| 62 | and uses it to permutate the S-Boxes via | ||
| 63 | .Fn arc4random_addrandom . | ||
| 64 | .Pp | ||
| 65 | There is no need to call | ||
| 66 | .Fn arc4random_stir | ||
| 67 | before using | ||
| 68 | .Fn arc4random , | ||
| 69 | since | ||
| 70 | .Fn arc4random | ||
| 71 | automatically initalizes itself. | ||
| 72 | .Sh SEE ALSO | ||
| 73 | .Xr rand 3 , | ||
| 74 | .Xr random 3 | ||
| 75 | .Sh HISTORY | ||
| 76 | .Pa RC4 | ||
| 77 | has been designed by RSA Data Security, Inc. It was posted anonymously | ||
| 78 | to the USENET and was confirmed to be equivalent by several sources who | ||
| 79 | had access to the original cipher. Since | ||
| 80 | .Pa RC4 | ||
| 81 | used to by a trade secret, the cipher is now refered to as | ||
| 82 | .Pa ARC4 . | ||
