Update to slightly altered rnd_attach_source() api

This commit is contained in:
explorer 1999-02-28 17:08:05 +00:00
parent 87ae97e3f0
commit 3ebb419571
26 changed files with 88 additions and 86 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rnd.4,v 1.3 1997/11/04 05:50:54 explorer Exp $
.\" $NetBSD: rnd.4,v 1.4 1999/02/28 17:08:05 explorer Exp $
.\"
.\" Copyright (c) 1997 Michael Graff
.\" All rights reserved.
@ -93,7 +93,8 @@ typedef struct {
u_int32_t last_delta;
u_int32_t last_delta2;
u_int32_t total;
u_int32_t tyfl;
u_int32_t type;
u_int32_t flags;
} rndsource_t;
.Ed
.Pp
@ -113,10 +114,8 @@ fields hold the last first- and second-order deltas. The
field holds a count of how many bits this device has potentially
generated. This is not the same as how many bits were used from it.
The
.Va tyfl
field holds the device flags as well as the device type. The lower
eight bits hold the device type, and the upper 24 bits are flags
represented as a bitfield.
.Va type
field holds the device type.
.Pp
.Bl -tag -width RND_TYPE_DISK
Currently, these types are defined:
@ -131,7 +130,8 @@ The device is a tape device.
The device is a terminal, mouse, or other user input device.
.El
.Pp
A device can have these flags set:
.Va flags
is a bitfield.
.Bl -tag -width RND_FLAG_NO_ESTIMATE
.It Dv RND_FLAG_NO_ESTIMATE
Do not assume any entropy is in the timing information.
@ -150,25 +150,6 @@ file, along with the data types and constants.
.It Dv RNDGETENTCNT
.Pq Li "u_int32_t"
Return the current entropy count (in bits).
.It Dv RNDSETENTCNT
.Pq Li "u_int32_t"
Sets the internal entropy count (in bits) to the value given. This
should be used with caution, as artifically increasing the entropy
count may lead to weakened security.
.It Dv RNDADDTOENTCNT
.Pq Li "u_int32_t"
Increase the entropy count (in bits) by the given amount. This should
be used with caution, as artifically increasing the entropy count may
lead to weakened security.
.It Dv RNDGETPOOL
.Pq Li "u_char *"
Return the actual contents of the entropy pool. The area pointed to
in this call should be
.Va "RND_POOLWORDS * 4"
bytes long. As this is the actual contents of the entropy pool and
not hashes of it, it is extremely important to handle this data with
care. Leaking any part of this pool would allow an attacker to
predict future random values.
.It Dv RNDGETSRCNUM
.Pq Li "rndstat_t"
.Bd -literal -offset indent
@ -250,9 +231,6 @@ The random device was first made available in
This implementation was written by Michael Graff <explorer@flame.org>
using ideas and algorithms gathered from many sources, including
the driver written by Ted Ts'o.
.Sh BUGS
This system is considered experimental in
.Nx 1.3 .
.Sh SEE ALSO
.Xr rndctl 8 ,
.Xr rnd 9 .

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rnd.9,v 1.3 1998/09/03 08:12:57 msaitoh Exp $
.\" $NetBSD: rnd.9,v 1.4 1999/02/28 17:08:18 explorer Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -47,7 +47,7 @@
.Sh SYNOPSIS
.Fd #include <sys/rnd.h>
.Ft void
.Fn rnd_attach_source "rndsource_element_t *rnd_source" "char *devname" "u_int32_t source_type_flag"
.Fn rnd_attach_source "rndsource_element_t *rnd_source" "char *devname" "u_int32_t source_type" "u_int32_t flags"
.Ft void
.Fn rnd_detach_source "rndsource_element_t *rnd_source"
.Ft void
@ -70,7 +70,7 @@ structures between two devices.
.Bl -tag -width compact
.It Fn rnd_attach_source "rndsource_element_t *rnd_source" "char *devname" "u_int32_t source_type_flag"
.It Fn rnd_attach_source "rndsource_element_t *rnd_source" "char *devname" "u_int32_t source_type" "u_int32_t flags"
This function announces the availability of a device for entropy collection.
It must be called before the source struct pointed to by
@ -83,7 +83,7 @@ compiled with ``options RND_VERBOSE'') and also for status information printed
with
.Xr rndctl 8 .
.Fa source_type_flag
.Fa source_type
is
.Dv RND_TYPE_NET
for network devices,
@ -96,6 +96,16 @@ for a tty.
.Dv RND_TYPE_UNKNOWN
is not to be used as a type. It is used internally to the rnd system.
.Fa flags
are the logical OR of
.Dv RND_FLAGS_NO_COLLECT (don't collect or estimate)
.Dv RND_FLAGS_NO_ESTIMATE (don't estimate)
to control the default setting for collection and estimation. Note that
devices of type
.Dv RND_TYPE_NET
default to
.Dv RND_FLAGS_NO_ESTIMATE .
.It Fn rnd_detach_source "rndsource_element_t *rnd_source"
This function disconnects the device from entropy collection.
@ -161,7 +171,7 @@ is permitted, and the device does not need to be attached.
.El
.\" .Sh ERRORS
.Sh HISTORY
The random device was first made available in
The random device was introduced in
.Nx 1.3 .
.Sh AUTHOR
This implementation was written by Michael Graff <explorer@flame.org>
@ -171,9 +181,6 @@ the driver written by Ted Ts'o.
The only good sources of randomness are quantum mechanical, and most
computers avidly avoid having true sources of randomness included.
Don't expect to surpass "pretty good".
This system is considered experimental in
.Nx 1.3 .
.Sh FILES
These functions are declared in src/sys/sys/rnd.h and defined in
src/sys/dev/rnd.c.

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.3 1999/02/22 02:52:24 mycroft Exp $ */
/* $NetBSD: fd.c,v 1.4 1999/02/28 17:11:24 explorer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -574,7 +574,8 @@ fdattach(parent, self, aux)
fd->sc_sdhook = shutdownhook_establish(fd_motor_off, fd);
#if NRND > 0
rnd_attach_source(&fd->rnd_source, fd->sc_dev.dv_xname, RND_TYPE_DISK);
rnd_attach_source(&fd->rnd_source, fd->sc_dev.dv_xname,
RND_TYPE_DISK, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.126 1999/02/22 02:56:13 mycroft Exp $ */
/* $NetBSD: fd.c,v 1.127 1999/02/28 17:12:30 explorer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -584,7 +584,8 @@ fdattach(parent, self, aux)
fd->sc_sdhook = shutdownhook_establish(fd_motor_off, fd);
#if NRND > 0
rnd_attach_source(&fd->rnd_source, fd->sc_dev.dv_xname, RND_TYPE_DISK);
rnd_attach_source(&fd->rnd_source, fd->sc_dev.dv_xname,
RND_TYPE_DISK, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mb8795.c,v 1.9 1998/12/27 09:03:15 dbj Exp $ */
/* $NetBSD: mb8795.c,v 1.10 1999/02/28 17:11:52 explorer Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
* All rights reserved.
@ -183,7 +183,7 @@ mb8795_config(sc)
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET);
RND_TYPE_NET, 0);
#endif
/* Initialize the dma maps */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rz.c,v 1.42 1999/01/27 03:03:51 simonb Exp $ */
/* $NetBSD: rz.c,v 1.43 1999/02/28 17:13:42 explorer Exp $ */
/*
* Copyright (c) 1992, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: rz.c,v 1.42 1999/01/27 03:03:51 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: rz.c,v 1.43 1999/02/28 17:13:42 explorer Exp $");
/*
* SCSI CCS (Command Command Set) disk driver.
@ -554,7 +554,8 @@ rzprobe(xxxsd)
/*
* attach the device into the random source list
*/
rnd_attach_source(&sd->rnd_source, sd->sc_dev.dv_xname, RND_TYPE_DISK);
rnd_attach_source(&sd->rnd_source, sd->sc_dev.dv_xname,
RND_TYPE_DISK, 0);
#endif /* NRND */
return (1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ln.c,v 1.9 1999/02/02 18:37:21 ragge Exp $ */
/* $NetBSD: if_ln.c,v 1.10 1999/02/28 17:11:33 explorer Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -305,7 +305,8 @@ lnattach(parent, self, aux)
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ed.c,v 1.9 1998/08/04 16:51:52 minoura Exp $ */
/* $NetBSD: if_ed.c,v 1.10 1999/02/28 17:11:43 explorer Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@ -513,7 +513,7 @@ edattach(parent, self, aux)
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET);
RND_TYPE_NET, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: wd.c,v 1.192 1999/02/21 00:15:42 hubertf Exp $ */
/* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer. All rights reserved.
@ -345,7 +345,8 @@ wdattach(parent, self, aux)
printf("%s: WARNING: unable to establish shutdown hook\n",
wd->sc_dev.dv_xname);
#if NRND > 0
rnd_attach_source(&wd->rnd_source, wd->sc_dev.dv_xname, RND_TYPE_DISK);
rnd_attach_source(&wd->rnd_source, wd->sc_dev.dv_xname,
RND_TYPE_DISK, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: com.c,v 1.154 1999/02/12 12:45:48 drochner Exp $ */
/* $NetBSD: com.c,v 1.155 1999/02/28 17:10:52 explorer Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -534,7 +534,7 @@ com_attach_subr(sc)
#if NRND > 0 && defined(RND_COM)
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_TTY);
RND_TYPE_TTY, 0);
#endif
/* if there are no enable/disable functions, assume the device

View File

@ -1,4 +1,4 @@
/* $NetBSD: dp8390.c,v 1.21 1999/02/17 03:40:59 thorpej Exp $ */
/* $NetBSD: dp8390.c,v 1.22 1999/02/28 17:10:52 explorer Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@ -149,7 +149,8 @@ dp8390_config(sc, media, nmedia, defmedia)
#endif
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
/* Print additional info when attached. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: elink3.c,v 1.52 1999/02/17 03:41:00 thorpej Exp $ */
/* $NetBSD: elink3.c,v 1.53 1999/02/28 17:10:53 explorer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -453,7 +453,8 @@ epconfig(sc, chipset, enaddr)
#endif
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
sc->tx_start_thresh = 20; /* probably a good starting point. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: elinkxl.c,v 1.4 1999/02/17 03:41:00 thorpej Exp $ */
/* $NetBSD: elinkxl.c,v 1.5 1999/02/28 17:10:53 explorer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -411,7 +411,8 @@ ex_config(sc)
#endif
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
/* Establish callback to reset card when we reboot. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lance.c,v 1.6 1999/02/17 03:41:01 thorpej Exp $ */
/* $NetBSD: lance.c,v 1.7 1999/02/28 17:10:53 explorer Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -290,7 +290,7 @@ lance_config(sc)
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET);
RND_TYPE_NET, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lemac.c,v 1.10 1998/07/05 06:49:11 jonathan Exp $ */
/* $NetBSD: lemac.c,v 1.11 1999/02/28 17:10:53 explorer Exp $ */
/*-
* Copyright (c) 1994, 1995, 1997 Matt Thomas <matt@3am-software.com>
@ -1065,7 +1065,8 @@ lemac_ifattach(
#endif
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dv.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dv.dv_xname,
RND_TYPE_NET, 0);
#endif
ifmedia_init(&sc->sc_ifmedia, 0,

View File

@ -1,4 +1,4 @@
/* $NetBSD: mb86960.c,v 1.30 1999/02/17 03:41:01 thorpej Exp $ */
/* $NetBSD: mb86960.c,v 1.31 1999/02/28 17:10:53 explorer Exp $ */
/*
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@ -266,7 +266,7 @@ mb86960_config(sc, media, nmedia, defmedia)
#endif
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET);
RND_TYPE_NET, 0);
#endif
/* Print additional info when attached. */
printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,

View File

@ -1,4 +1,4 @@
/* $NetBSD: smc91cxx.c,v 1.14 1999/02/17 03:41:01 thorpej Exp $ */
/* $NetBSD: smc91cxx.c,v 1.15 1999/02/28 17:10:53 explorer Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -263,7 +263,8 @@ smc91cxx_attach(sc, myea)
#endif
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_eg.c,v 1.44 1998/12/12 16:58:11 mycroft Exp $ */
/* $NetBSD: if_eg.c,v 1.45 1999/02/28 17:09:25 explorer Exp $ */
/*
* Copyright (c) 1993 Dean Huxley <dean@fsa.ca>
@ -497,7 +497,8 @@ egattach(parent, self, aux)
IPL_NET, egintr, sc);
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_el.c,v 1.55 1998/12/12 16:58:11 mycroft Exp $ */
/* $NetBSD: if_el.c,v 1.56 1999/02/28 17:09:26 explorer Exp $ */
/*
* Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted
@ -257,7 +257,8 @@ elattach(parent, self, aux)
#if NRND > 0
DPRINTF(("Attaching to random...\n"));
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
DPRINTF(("elattach() finished.\n"));

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_hp.c,v 1.27 1998/07/05 06:49:13 jonathan Exp $ */
/* $NetBSD: if_hp.c,v 1.28 1999/02/28 17:09:26 explorer Exp $ */
/* XXX THIS DRIVER IS BROKEN. IT WILL NOT EVEN COMPILE. */
@ -433,7 +433,8 @@ hpattach(dvp)
#endif
#if NRND > 0
rnd_attach_source(&ns->rnd_source, ns->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&ns->rnd_source, ns->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_iy.c,v 1.31 1999/02/16 23:34:13 is Exp $ */
/* $NetBSD: if_iy.c,v 1.32 1999/02/28 17:09:26 explorer Exp $ */
/* #define IYDEBUG */
/* #define IYMEMDEBUG */
@ -369,7 +369,8 @@ iyattach(parent, self, aux)
IPL_NET, iyintr, sc);
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname, RND_TYPE_NET);
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET, 0);
#endif
temp = bus_space_read_1(iot, ioh, INT_NO_REG);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_de.c,v 1.81 1998/11/09 23:41:14 matt Exp $ */
/* $NetBSD: if_de.c,v 1.82 1999/02/28 17:08:51 explorer Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
@ -5015,7 +5015,7 @@ tulip_attach(
#if defined(__NetBSD__) && NRND > 0
rnd_attach_source(&sc->tulip_rndsource, sc->tulip_dev.dv_xname,
RND_TYPE_NET);
RND_TYPE_NET, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fxp.c,v 1.31 1999/02/18 19:24:39 thorpej Exp $ */
/* $NetBSD: if_fxp.c,v 1.32 1999/02/28 17:08:52 explorer Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -490,7 +490,7 @@ fxp_attach(parent, self, aux)
#if NRND > 0
rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
RND_TYPE_NET);
RND_TYPE_NET, 0);
#endif
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.123 1999/02/15 18:41:04 bouyer Exp $ */
/* $NetBSD: cd.c,v 1.124 1999/02/28 17:14:57 explorer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -173,7 +173,8 @@ cdattach(parent, cd, sc_link, ops)
printf("\n");
#if NRND > 0
rnd_attach_source(&cd->rnd_source, cd->sc_dev.dv_xname, RND_TYPE_DISK);
rnd_attach_source(&cd->rnd_source, cd->sc_dev.dv_xname,
RND_TYPE_DISK, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.143 1999/02/10 12:29:50 bouyer Exp $ */
/* $NetBSD: sd.c,v 1.144 1999/02/28 17:14:57 explorer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -212,7 +212,8 @@ sdattach(parent, sd, sc_link, ops)
/*
* attach the device into the random source list
*/
rnd_attach_source(&sd->rnd_source, sd->sc_dev.dv_xname, RND_TYPE_DISK);
rnd_attach_source(&sd->rnd_source, sd->sc_dev.dv_xname,
RND_TYPE_DISK, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: st.c,v 1.109 1999/02/10 12:29:51 bouyer Exp $ */
/* $NetBSD: st.c,v 1.110 1999/02/28 17:14:57 explorer Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -483,7 +483,8 @@ stattach(parent, self, aux)
st->buf_queue.b_actb = &st->buf_queue.b_actf;
#if NRND > 0
rnd_attach_source(&st->rnd_source, st->sc_dev.dv_xname, RND_TYPE_TAPE);
rnd_attach_source(&st->rnd_source, st->sc_dev.dv_xname,
RND_TYPE_TAPE, 0);
#endif
}