diff options
author | 2014-01-19 12:45:35 +0000 | |
---|---|---|
committer | 2014-01-19 12:45:35 +0000 | |
commit | 4193b9a6533f1b0a3eb74293c611f18e506e278b (patch) | |
tree | e73d7e3bb264f19dc7ef2032d83520314492f7d4 /sys/lib/libkern/random.c | |
parent | Retain local changes from rev 1.13. (diff) | |
download | wireguard-openbsd-4193b9a6533f1b0a3eb74293c611f18e506e278b.tar.xz wireguard-openbsd-4193b9a6533f1b0a3eb74293c611f18e506e278b.zip |
Initialize ci_randseed better using arc4random() + a trick. Remove the
libkern srandom() API since it is not suitable for this use.
ok kettenis miod
Diffstat (limited to 'sys/lib/libkern/random.c')
-rw-r--r-- | sys/lib/libkern/random.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/sys/lib/libkern/random.c b/sys/lib/libkern/random.c index d78e1b0607a..26a9173702d 100644 --- a/sys/lib/libkern/random.c +++ b/sys/lib/libkern/random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: random.c,v 1.8 2008/10/15 23:23:51 deraadt Exp $ */ +/* $OpenBSD: random.c,v 1.9 2014/01/19 12:45:36 deraadt Exp $ */ /* $NetBSD: random.c,v 1.2 1994/10/26 06:42:42 cgd Exp $ */ /*- @@ -38,22 +38,10 @@ #include <lib/libkern/libkern.h> /* - * Pseudo-random number generator for randomizing the profiling clock, - * and whatever else we might use it for. The result is uniform on - * [0, 2^31 - 1]. + * Pseudo-random number generator for randomizing the profiling clock. + * The result is uniform on [0, 2^31 - 1]. */ -void -srandom(u_int32_t seed) -{ - struct cpu_info *ci = curcpu(); - - seed &= 0x7fffffff; - if (seed == 0) - seed = 1; - ci->ci_randseed = seed; -} - u_int32_t random(void) { |