diff options
author | ache <ache@FreeBSD.org> | 2006-10-04 01:17:23 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2006-10-04 01:17:23 +0000 |
commit | 152e82b738c28491ad901ef7e2523542866b8d2e (patch) | |
tree | 7013a99312e56648ee066eb4b36a8b4a7e5f0465 /lib/libc | |
parent | b5bc2576e3e6a6afcc9a6c6696904b4810216a2c (diff) | |
download | FreeBSD-src-152e82b738c28491ad901ef7e2523542866b8d2e.zip FreeBSD-src-152e82b738c28491ad901ef7e2523542866b8d2e.tar.gz |
Automatically re-stir every 400000 calls
Obtained from: OpenBSD
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/arc4random.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index e2448d5..52e28ad 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -61,6 +61,7 @@ static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; static struct arc4_stream rs; static int rs_initialized; static int rs_stired; +static int arc4_count; static inline u_int8_t arc4_getbyte(struct arc4_stream *); static void arc4_stir(struct arc4_stream *); @@ -127,7 +128,8 @@ arc4_stir(as) * by Ilya Mironov. */ for (n = 0; n < 1024; n++) - arc4_getbyte(as); + (void) arc4_getbyte(as); + arc4_count = 400000; } static inline u_int8_t @@ -172,7 +174,7 @@ arc4_check_init(void) static void arc4_check_stir(void) { - if (!rs_stired) { + if (!rs_stired || --arc4_count == 0) { arc4_stir(&rs); rs_stired = 1; } |