1.\" $OpenBSD: arc4random.3,v 1.2 1997/04/27 22:40:25 angelos 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 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 u_int32_t 43.Fn arc4random "void" 44.Ft void 45.Fn arc4random_stir "void" 46.Ft void 47.Fn arc4random_addrandom "unsigned char *dat" "int datlen" 48.Sh DESCRIPTION 49The 50.Fn arc4random 51function uses the key stream generator employed by the 52arc4 cipher, which uses 8*8 8 bit S-Boxes. The S-Boxes 53can be in about 54.if t 2\u\s71700\s10\d 55.if n (2**1700) 56states. 57.Pp 58The 59.Fn arc4random_stir 60function reads data from 61.Pa /dev/urandom 62and uses it to permute the S-Boxes via 63.Fn arc4random_addrandom . 64.Pp 65There is no need to call 66.Fn arc4random_stir 67before using 68.Fn arc4random , 69since 70.Fn arc4random 71automatically initializes itself. 72.Sh SEE ALSO 73.Xr rand 3 , 74.Xr random 3 , 75.Xr srandomdev 3 76.Sh HISTORY 77.Pa RC4 78has been designed by RSA Data Security, Inc. It was posted anonymously 79to the USENET and was confirmed to be equivalent by several sources who 80had access to the original cipher. Since 81.Pa RC4 82used to be a trade secret, the cipher is now referred to as 83.Pa ARC4 . 84