summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordm <dm@openbsd.org>1996-08-11 07:31:31 +0000
committerdm <dm@openbsd.org>1996-08-11 07:31:31 +0000
commit48d51be3221fc463717c3a34ede4698f978685e4 (patch)
treef93ea26ff28d292c078bcf1456ad1f0445c0ab3b
parentAdded arc4random and /dev/arnd. (diff)
downloadwireguard-openbsd-48d51be3221fc463717c3a34ede4698f978685e4.tar.xz
wireguard-openbsd-48d51be3221fc463717c3a34ede4698f978685e4.zip
Increased entropy through decreased typos.
-rw-r--r--sys/dev/rnd.c10
-rw-r--r--sys/dev/rndioctl.h3
-rw-r--r--sys/dev/rndvar.h5
3 files changed, 11 insertions, 7 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index 0357eab82db..aab64ab4c60 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rnd.c,v 1.5 1996/08/11 06:41:38 dm Exp $ */
+/* $OpenBSD: rnd.c,v 1.6 1996/08/11 07:31:31 dm Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff.
@@ -278,7 +278,7 @@ struct arc4_stream {
cdev_decl(rnd);
static struct random_bucket random_state;
-static struct arc4_stream arc4random_state;
+struct arc4_stream arc4random_state;
static u_int32_t random_pool[POOLWORDS];
static struct timer_rand_state keyboard_timer_state;
static struct timer_rand_state mouse_timer_state;
@@ -315,14 +315,14 @@ arc4_getbyte (struct arc4_stream *as)
as->i = (as->i + 1) & 0xff;
si = as->s[as->i];
- as->i = (as->i + si) & 0xff;
+ as->j = (as->j + si) & 0xff;
sj = as->s[as->j];
as->s[as->i] = sj;
as->s[as->j] = si;
return (as->s[(si + sj) & 0xff]);
}
-u_int
+u_long
arc4random (void)
{
return ((arc4_getbyte (&arc4random_state) << 24)
@@ -365,7 +365,7 @@ rndopen(dev, flag, mode, p)
int mode;
struct proc *p;
{
- return 0;
+ return (minor (dev) < RND_NODEV) ? 0 : ENXIO;
}
int
diff --git a/sys/dev/rndioctl.h b/sys/dev/rndioctl.h
index b50d233cf14..7a13f6103b1 100644
--- a/sys/dev/rndioctl.h
+++ b/sys/dev/rndioctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rndioctl.h,v 1.1 1996/03/29 12:09:57 mickey Exp $ */
+/* $OpenBSD: rndioctl.h,v 1.2 1996/08/11 07:31:32 dm Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff.
@@ -51,6 +51,7 @@ struct rnd_pool_info {
#define RNDGETPOOL _IOWR('R', 2, sizeof(struct rnd_pool_info))
#define RNDADDENTROPY _IOW('R', 3, sizeof(u_int))
#define RNDZAPENTCNT _IO( 'R', 4)
+#define RNDSTIRARC4 _IO( 'R', 5)
#endif /* __RNDIOCTL_H__ */
diff --git a/sys/dev/rndvar.h b/sys/dev/rndvar.h
index a808f0dfe3e..34297e6922e 100644
--- a/sys/dev/rndvar.h
+++ b/sys/dev/rndvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rndvar.h,v 1.2 1996/04/24 21:26:43 mickey Exp $ */
+/* $OpenBSD: rndvar.h,v 1.3 1996/08/11 07:31:32 dm Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff.
@@ -43,6 +43,8 @@
#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_NODEV 5 /* First invalid minor device number */
#ifdef _KERNEL
@@ -52,6 +54,7 @@ extern void add_blkdev_randomness __P((dev_t));
extern void add_tty_randomness __P((dev_t, int));
extern void get_random_bytes __P((void *, size_t));
+extern unsigned long arc4random __P((void));
#endif /* _KERNEL */