diff options
author | 2014-12-08 21:45:19 +0000 | |
---|---|---|
committer | 2014-12-08 21:45:19 +0000 | |
commit | f7510a6ece7d11f60752a2ac701b127e460d8361 (patch) | |
tree | 1513b6608a14d945d1d50bdb13e294073890e337 /lib/libc/stdlib/mrand48.c | |
parent | typo (diff) | |
download | wireguard-openbsd-f7510a6ece7d11f60752a2ac701b127e460d8361.tar.xz wireguard-openbsd-f7510a6ece7d11f60752a2ac701b127e460d8361.zip |
Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode. If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).
Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.
Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert
Diffstat (limited to 'lib/libc/stdlib/mrand48.c')
-rw-r--r-- | lib/libc/stdlib/mrand48.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/stdlib/mrand48.c b/lib/libc/stdlib/mrand48.c index 977264aba50..7bfccbbf837 100644 --- a/lib/libc/stdlib/mrand48.c +++ b/lib/libc/stdlib/mrand48.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ +/* $OpenBSD: mrand48.c,v 1.4 2014/12/08 21:45:20 deraadt Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier * All rights reserved. @@ -19,6 +19,8 @@ extern unsigned short __rand48_seed[3]; long mrand48(void) { + if (__rand48_deterministic == 0) + return arc4random(); __dorand48(__rand48_seed); return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1]; } |