1 .\" $OpenBSD: arc4random.3,v 1.19 2005/07/17 08:50:55 jaredy Exp $
3 .\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
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.
31 .\" Manual page, using -mandoc macros
39 .Nm arc4random_addrandom
40 .Nd arc4 random number generator
42 .Fd #include <stdlib.h>
46 .Fn arc4random_stir "void"
48 .Fn arc4random_addrandom "u_char *dat" "int datlen"
52 function provides a high quality 32-bit pseudo-random
55 seeds itself on a regular basis from the kernel strong random number
56 subsystem described in
58 On each call, an ARC4 generator is used to generate a new result.
61 function uses the ARC4 cipher key stream generator,
62 which uses 8*8 8-bit S-Boxes.
63 The S-Boxes can be in about (2**1700) states.
66 fits into a middle ground not covered by other subsystems such as
67 the strong, slow, and resource expensive random
70 versus the fast but poor quality interfaces described in
78 function reads data from a pseudo-random device, usually
80 and uses it to permute the S-Boxes via
81 .Fn arc4random_addrandom .
83 There is no need to call
89 automatically initializes itself.
97 was designed by RSA Data Security, Inc.
98 It was considered a trade secret.
99 Because it was a trade secret, it obviously could not be patented.
100 A clone of this was posted anonymously to USENET and confirmed to
101 be equivalent by several sources who had access to the original cipher.
102 Because of the trade secret situation, RSA Data Security, Inc. can do
103 nothing about the release of the ARC4 algorithm.
106 used to be a trade secret, the cipher is now referred to as
109 These functions first appeared in