diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-04-24 21:26:44 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-04-24 21:26:44 +0000 |
commit | d75a6262c9d4b16c12eec1d91f48d682bd42a75d (patch) | |
tree | da1782838bbdc61a80636dc3a8981380fddf26a8 /sys/dev | |
parent | 4a62f54b689d2fa867d78306a66cd87925df3e6c (diff) |
Supply randomness source for the rnd device.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/rnd.c | 22 | ||||
-rw-r--r-- | sys/dev/rndvar.h | 4 |
2 files changed, 21 insertions, 5 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 242343ada66..7730f1baf0d 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.2 1996/04/17 04:59:48 mickey Exp $ */ +/* $OpenBSD: rnd.c,v 1.3 1996/04/24 21:26:41 mickey Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff. @@ -266,7 +266,7 @@ struct timer_rand_state { /* tags for different random sources */ #define ENT_NET 0x100 #define ENT_BLKDEV 0x200 -#define ENT_IRQ 0x300 +#define ENT_TTY 0x300 /* device functions prototypes: XXX move em to dev_conf.h */ cdev_decl(rnd); @@ -278,6 +278,7 @@ static struct timer_rand_state mouse_timer_state; static struct timer_rand_state extract_timer_state; static struct timer_rand_state net_timer_state[32]; /* XXX */ static struct timer_rand_state *blkdev_timer_state; +static struct timer_rand_state *tty_timer_state; static int rnd_sleep = 0; #ifndef MIN @@ -297,6 +298,9 @@ rndattach(num) blkdev_timer_state = malloc(nblkdev*sizeof(*blkdev_timer_state), M_DEVBUF, M_WAITOK); bzero(blkdev_timer_state, nblkdev*sizeof(*blkdev_timer_state)); + tty_timer_state = malloc(nchrdev*sizeof(*tty_timer_state), + M_DEVBUF, M_WAITOK); + bzero(tty_timer_state, nchrdev*sizeof(*tty_timer_state)); extract_timer_state.dont_count_entropy = 1; } @@ -466,13 +470,25 @@ void add_blkdev_randomness(dev) dev_t dev; { - if (major(dev) >= nblkdev || blkdev_timer_state == NULL) + if (major(dev) <= nblkdev || blkdev_timer_state == NULL) return; add_timer_randomness(&random_state, &blkdev_timer_state[major(dev)], ENT_BLKDEV + major(dev)); } +void +add_tty_randomness(dev, c) + dev_t dev; + int c; +{ + if (major(dev) <= nchrdev || tty_timer_state == NULL) + return; + + add_timer_randomness(&random_state, &tty_timer_state[major(dev)], + ENT_TTY + c); +} + #if POOLWORDS % 16 #error extract_entropy() assumes that POOLWORDS is a multiple of 16 words. #endif diff --git a/sys/dev/rndvar.h b/sys/dev/rndvar.h index 44b37d98f0d..a808f0dfe3e 100644 --- a/sys/dev/rndvar.h +++ b/sys/dev/rndvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rndvar.h,v 1.1 1996/03/29 12:09:58 mickey Exp $ */ +/* $OpenBSD: rndvar.h,v 1.2 1996/04/24 21:26:43 mickey Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff. @@ -46,10 +46,10 @@ #ifdef _KERNEL -extern void add_keyboard_randomness __P((u_char)); extern void add_mouse_randomness __P((u_int32_t)); extern void add_net_randomness __P((int)); 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)); |