-/* $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.
/* 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);
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
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;
}
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
-/* $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.
#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));
-/* $OpenBSD: tty.c,v 1.4 1996/04/21 22:27:28 deraadt Exp $ */
+/* $OpenBSD: tty.c,v 1.5 1996/04/24 21:26:36 mickey Exp $ */
/* $NetBSD: tty.c,v 1.68 1996/03/29 01:55:12 christos Exp $ */
/*-
#include <vm/vm.h>
+#include "rnd.h"
+#if NRND
+#include <dev/rndvar.h>
+#endif
+
static int ttnread __P((struct tty *));
static void ttyblock __P((struct tty *));
static void ttyecho __P((int, struct tty *));
register u_char *cc;
int i, error;
+#if NRND
+ add_tty_randomness(tp->t_dev, c);
+#endif
/*
* If input is pending take it first.
*/