diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-10-10 20:13:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-10-10 20:13:12 +0000 |
commit | cc06212dfd7d742814b313f05049f70b030f363c (patch) | |
tree | c0307be9c318721552dc639f864ecfbc916075d9 | |
parent | 6bac9c290620ecee62acc1d229cbd8262c8ddb72 (diff) |
minor 3 was /dev/prandom, which used random(). make that use the
arandom code, just like minor 4. in fact, make them act exactly
the same.
-rw-r--r-- | sys/dev/rnd.c | 16 | ||||
-rw-r--r-- | sys/dev/rndvar.h | 6 |
2 files changed, 9 insertions, 13 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 3cd0a96ec1c..d8d62fa92b7 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.93 2008/09/10 14:01:23 blambert Exp $ */ +/* $OpenBSD: rnd.c,v 1.94 2008/10/10 20:13:11 deraadt Exp $ */ /* * rnd.c -- A strong random number generator @@ -966,7 +966,7 @@ arc4random_uniform(u_int32_t upper_bound) } /* - * random, srandom, urandom, prandom, arandom char devices + * random, srandom, urandom, arandom char devices * ------------------------------------------------------- */ @@ -1000,7 +1000,6 @@ int randomread(dev_t dev, struct uio *uio, int ioflag) { int ret = 0; - int i; u_int32_t *buf; if (uio->uio_resid == 0) @@ -1051,11 +1050,7 @@ randomread(dev_t dev, struct uio *uio, int ioflag) printf("rnd: %u bytes for output\n", n); #endif break; - case RND_PRND: - i = (n + 3) / 4; - while (i--) - buf[i] = random() << 16 | (random() & 0xFFFF); - break; + case RND_ARND_OLD: case RND_ARND: arc4random_buf(buf, n); break; @@ -1149,7 +1144,7 @@ randomwrite(dev_t dev, struct uio *uio, int flags) int ret = 0; u_int32_t *buf; - if (minor(dev) == RND_RND || minor(dev) == RND_PRND) + if (minor(dev) == RND_RND) return ENXIO; if (uio->uio_resid == 0) @@ -1168,7 +1163,8 @@ randomwrite(dev_t dev, struct uio *uio, int flags) } } - if (minor(dev) == RND_ARND && !ret) + if ((minor(dev) == RND_ARND || minor(dev) == RND_ARND_OLD) && + !ret) arc4random_initialized = 0; free(buf, M_TEMP); diff --git a/sys/dev/rndvar.h b/sys/dev/rndvar.h index 4e58b342736..a3ece9bca9d 100644 --- a/sys/dev/rndvar.h +++ b/sys/dev/rndvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rndvar.h,v 1.21 2008/06/09 07:07:16 djm Exp $ */ +/* $OpenBSD: rndvar.h,v 1.22 2008/10/10 20:13:11 deraadt Exp $ */ /* * Copyright (c) 1996,2000 Michael Shalayeff. @@ -36,8 +36,8 @@ #define RND_RND 0 /* real randomness like nuclear chips */ #define RND_SRND 1 /* strong random source */ #define RND_URND 2 /* less strong random source */ -#define RND_PRND 3 /* pseudo random source */ -#define RND_ARND 4 /* aRC4 based random number generator */ +#define RND_ARND 3 /* aRC4 based random number generator */ +#define RND_ARND_OLD 4 /* old: delete when we reach OpenBSD 4.6 */ #define RND_NODEV 5 /* First invalid minor device number */ #define RND_SRC_TRUE 0 |