arc4random.3 (180657) | arc4random.3 (180688) |
---|---|
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 --- 14 unchanged lines hidden (view full) --- 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 | 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 --- 14 unchanged lines hidden (view full) --- 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.\" $FreeBSD: head/lib/libc/gen/arc4random.3 180657 2008-07-21 13:52:06Z ache $ | 31.\" $FreeBSD: head/lib/libc/gen/arc4random.3 180688 2008-07-22 11:33:49Z ache $ |
32.\" 33.Dd April 15, 1997 34.Dt ARC4RANDOM 3 35.Os 36.Sh NAME 37.Nm arc4random , 38.Nm arc4random_buf , | 32.\" 33.Dd April 15, 1997 34.Dt ARC4RANDOM 3 35.Os 36.Sh NAME 37.Nm arc4random , 38.Nm arc4random_buf , |
39.Nm arc4random_uniform , |
|
39.Nm arc4random_stir , 40.Nm arc4random_addrandom 41.Nd arc4 random number generator 42.Sh LIBRARY 43.Lb libc 44.Sh SYNOPSIS 45.In stdlib.h 46.Ft u_int32_t 47.Fn arc4random "void" 48.Ft void 49.Fn arc4random_buf "void *buf" "size_t nbytes" | 40.Nm arc4random_stir , 41.Nm arc4random_addrandom 42.Nd arc4 random number generator 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.In stdlib.h 47.Ft u_int32_t 48.Fn arc4random "void" 49.Ft void 50.Fn arc4random_buf "void *buf" "size_t nbytes" |
51.Ft u_int32_t 52.Fn arc4random_uniform "u_int32_t upper_bound" |
|
50.Ft void 51.Fn arc4random_stir "void" 52.Ft void 53.Fn arc4random_addrandom "unsigned char *dat" "int datlen" 54.Sh DESCRIPTION 55The 56.Fn arc4random 57function uses the key stream generator employed by the --- 15 unchanged lines hidden (view full) --- 73.Pp 74.Fn arc4random_buf 75function fills the region 76.Fa buf 77of length 78.Fa nbytes 79with ARC4-derived random data. 80.Pp | 53.Ft void 54.Fn arc4random_stir "void" 55.Ft void 56.Fn arc4random_addrandom "unsigned char *dat" "int datlen" 57.Sh DESCRIPTION 58The 59.Fn arc4random 60function uses the key stream generator employed by the --- 15 unchanged lines hidden (view full) --- 76.Pp 77.Fn arc4random_buf 78function fills the region 79.Fa buf 80of length 81.Fa nbytes 82with ARC4-derived random data. 83.Pp |
84.Fn arc4random_uniform 85will return a uniformly distributed random number less than 86.Fa upper_bound . 87.Fn arc4random_uniform 88is recommended over constructions like 89.Dq Li arc4random() % upper_bound 90as it avoids "modulo bias" when the upper bound is not a power of two. 91.Pp |
|
81The 82.Fn arc4random_stir 83function reads data from 84.Pa /dev/urandom 85and uses it to permute the S-Boxes via 86.Fn arc4random_addrandom . 87.Pp 88There is no need to call --- 28 unchanged lines hidden --- | 92The 93.Fn arc4random_stir 94function reads data from 95.Pa /dev/urandom 96and uses it to permute the S-Boxes via 97.Fn arc4random_addrandom . 98.Pp 99There is no need to call --- 28 unchanged lines hidden --- |