diff options
37 files changed, 106 insertions, 168 deletions
diff --git a/share/man/man4/acpihve.4 b/share/man/man4/acpihve.4 index 5cbdedd713c..d251e212dcb 100644 --- a/share/man/man4/acpihve.4 +++ b/share/man/man4/acpihve.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: acpihve.4,v 1.1 2017/01/10 08:54:14 jsg Exp $ +.\" $OpenBSD: acpihve.4,v 1.2 2018/04/28 15:44:59 jasper Exp $ .\" .\" Copyright (c) 2017 Jonathan Gray <jsg@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 10 2017 $ +.Dd $Mdocdate: April 28 2018 $ .Dt ACPIHVE 4 .Os .Sh NAME @@ -29,7 +29,7 @@ The driver feeds this entropy into the kernel's entropy pool. .Sh SEE ALSO .Xr acpi 4 , -.Xr add_true_randomness 9 +.Xr enqueue_randomness 9 .Sh HISTORY The .Nm diff --git a/share/man/man4/man4.octeon/octrng.4 b/share/man/man4/man4.octeon/octrng.4 index fcc9eec758f..02d99a18b03 100644 --- a/share/man/man4/man4.octeon/octrng.4 +++ b/share/man/man4/man4.octeon/octrng.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: octrng.4,v 1.3 2015/10/22 11:01:49 sobrado Exp $ +.\" $OpenBSD: octrng.4,v 1.4 2018/04/28 15:44:59 jasper Exp $ .\" .\" Copyright (c) 2013 Paul Irofti <pirofti@openbsd.org> .\" @@ -15,7 +15,7 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .\" -.Dd $Mdocdate: October 22 2015 $ +.Dd $Mdocdate: April 28 2018 $ .Dt OCTRNG 4 octeon .Os .Sh NAME @@ -32,7 +32,7 @@ After the 5 seconds it takes for the device to be initialized, the .Nm driver feeds the random subsystem's entropy pool 32 bits of data every 10 milliseconds through the -.Xr add_true_randomness 9 +.Xr enqueue_randomness 9 API. .Sh SEE ALSO .Xr intro 4 , diff --git a/share/man/man4/uonerng.4 b/share/man/man4/uonerng.4 index 6f3baf7897e..b1fd07aeef6 100644 --- a/share/man/man4/uonerng.4 +++ b/share/man/man4/uonerng.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: uonerng.4,v 1.2 2016/01/08 10:20:05 jmc Exp $ +.\" $OpenBSD: uonerng.4,v 1.3 2018/04/28 15:44:59 jasper Exp $ .\" .\" Copyright (c) 2015 Devin Reade <gdr@gno.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 8 2016 $ +.Dd $Mdocdate: April 28 2018 $ .Dt ONERNG 4 .Os .Sh NAME @@ -29,7 +29,7 @@ driver provides support for the Moonbase Otago OneRNG, a USB true random number generator (TRNG). .Nm reads raw entropy from the OneRNG and uses -.Xr add_true_randomness 9 +.Xr enqueue_randomness 9 to add it to the system entropy pool. .Pp The OneRNG is capable of operating in one of several modes, some of @@ -44,7 +44,7 @@ which is also the manufacturer's default mode. .Sh SEE ALSO .Xr intro 4 , .Xr usb 4 , -.Xr add_true_randomness 9 +.Xr enqueue_randomness 9 .Pp Moonbase Otago: .Lk http://onerng.info/onerng diff --git a/share/man/man4/urng.4 b/share/man/man4/urng.4 index b7cf11f98d5..7a65ae50376 100644 --- a/share/man/man4/urng.4 +++ b/share/man/man4/urng.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: urng.4,v 1.4 2017/09/25 18:47:53 jasper Exp $ +.\" $OpenBSD: urng.4,v 1.5 2018/04/28 15:44:59 jasper Exp $ .\" .\" Copyright (c) 2015 Sean Levy <attila@stalphonsos.com> .\" Copyright (c) 2017 Jasper Lievisse Adriaanse <jasper@openbsd.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 25 2017 $ +.Dd $Mdocdate: April 28 2018 $ .Dt URNG 4 .Os .Sh NAME @@ -31,7 +31,7 @@ driver provides support for various true random number generator .Nm reads raw entropy from the device at a (hardware dependent) interval and stirs it into the system entropy pool with -.Xr add_true_randomness 9 . +.Xr enqueue_randomness 9 . .Sh HARDWARE The following devices are supported by this driver: .Bl -tag -width "Altus Metrum" @@ -43,7 +43,7 @@ This device is capable of providing entropy at 10Mbit/s. .Sh SEE ALSO .Xr intro 4 , .Xr usb 4 , -.Xr add_true_randomness 9 +.Xr enqueue_randomness 9 .Sh HISTORY The .Nm diff --git a/share/man/man9/arc4random.9 b/share/man/man9/arc4random.9 index 13759d53c65..e7197195a75 100644 --- a/share/man/man9/arc4random.9 +++ b/share/man/man9/arc4random.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: arc4random.9,v 1.12 2015/11/23 17:53:57 jmc Exp $ +.\" $OpenBSD: arc4random.9,v 1.13 2018/04/28 15:44:59 jasper Exp $ .\" .\" Copyright (c) 1996,2000 Michael Shalayeff .\" All rights reserved. @@ -23,20 +23,14 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: November 23 2015 $ +.Dd $Mdocdate: April 28 2018 $ .Dt ARC4RANDOM 9 .Os .Sh NAME .Nm arc4random , .Nm arc4random_buf , .Nm arc4random_uniform , -.Nm add_true_randomness , -.Nm add_timer_randomness , -.Nm add_mouse_randomness , -.Nm add_tty_randomness , -.Nm add_net_randomness , -.Nm add_disk_randomness , -.Nm add_audio_randomness +.Nm enqueue_randomness , .Nd kernel random subsystem .Sh SYNOPSIS .In sys/systm.h @@ -48,19 +42,7 @@ .Fn arc4random_uniform "u_int32_t upper_bound" .In dev/rndvar.h .Ft void -.Fn add_true_randomness "int" -.Ft void -.Fn add_timer_randomness "int" -.Ft void -.Fn add_mouse_randomness "int" -.Ft void -.Fn add_tty_randomness "int" -.Ft void -.Fn add_net_randomness "int" -.Ft void -.Fn add_disk_randomness "int" -.Ft void -.Fn add_audio_randomness "int" +.Fn enqueue_randomness "int" .Sh DESCRIPTION The .Fn add_random @@ -69,28 +51,10 @@ to create a key for the ChaCha stream cipher used in the .Fn arc4random series of functions. .Pp -The -.Fn add_mouse_randomness , -.Fn add_tty_randomness , -.Fn add_net_randomness , -.Fn add_disk_randomness -and -.Fn add_audio_randomness -routines are used to -supply data for the random data source device for further processing. -The processing involves calculating inter-event timedelta and inserting -it into a pool which is cryptographically mixed multiple times. -.Pp -.Fn add_true_randomness -does not involve the usual timing calculations, -and causes the supplied data argument to be added to the entropy pool, +.Fn enqueue_randomness +causes the supplied data argument to be added to the entropy pool, increasing the entropy counter by 32 bits. .Pp -.Fn add_timer_randomness -will not cause the entropy counter to rise. -It is used to change the state of the pool periodically, -mostly by means of timing the random driver's operations. -.Pp .Fn arc4random and .Fn arc4random_buf diff --git a/sys/arch/amd64/amd64/bios.c b/sys/arch/amd64/amd64/bios.c index 337262fc35e..7132d5bb57c 100644 --- a/sys/arch/amd64/amd64/bios.c +++ b/sys/arch/amd64/amd64/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.35 2017/10/14 04:44:43 jsg Exp $ */ +/* $OpenBSD: bios.c,v 1.36 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * @@ -437,7 +437,7 @@ smbios_info(char * str) if (sminfop) { infolen = strlen(sminfop) + 1; for (i = 0; i < infolen - 1; i++) - add_timer_randomness(sminfop[i]); + enqueue_randomness(sminfop[i]); hw_serial = malloc(infolen, M_DEVBUF, M_NOWAIT); if (hw_serial) strlcpy(hw_serial, sminfop, infolen); @@ -462,7 +462,7 @@ smbios_info(char * str) hw_uuid = "Not Set"; else { for (i = 0; i < sizeof(sys->uuid); i++) - add_timer_randomness(sys->uuid[i]); + enqueue_randomness(sys->uuid[i]); hw_uuid = malloc(SMBIOS_UUID_REPLEN, M_DEVBUF, M_NOWAIT); if (hw_uuid) { diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c index bd5f24bf488..6a0ac50aa21 100644 --- a/sys/arch/amd64/amd64/cpu.c +++ b/sys/arch/amd64/amd64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.116 2018/04/24 15:32:28 mlarkin Exp $ */ +/* $OpenBSD: cpu.c,v 1.117 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -929,8 +929,8 @@ rdrand(void *v) if (valid) t.u64 ^= r.u64; - add_true_randomness(t.u32[0]); - add_true_randomness(t.u32[1]); + enqueue_randomness(t.u32[0]); + enqueue_randomness(t.u32[1]); if (tmo) timeout_add_msec(tmo, 10); diff --git a/sys/arch/amd64/amd64/via.c b/sys/arch/amd64/amd64/via.c index 5c102b67a7b..284649cf675 100644 --- a/sys/arch/amd64/amd64/via.c +++ b/sys/arch/amd64/amd64/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.28 2018/02/21 21:09:57 mikeb Exp $ */ +/* $OpenBSD: via.c,v 1.29 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -535,7 +535,7 @@ viac3_rnd(void *v) #endif for (i = 0, p = buffer; i < VIAC3_RNG_BUFSIZ; i++, p++) - add_true_randomness(*p); + enqueue_randomness(*p); timeout_add_msec(tmo, 10); } diff --git a/sys/arch/amd64/pci/pchb.c b/sys/arch/amd64/pci/pchb.c index 591523e4b45..6e599d7be4a 100644 --- a/sys/arch/amd64/pci/pchb.c +++ b/sys/arch/amd64/pci/pchb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pchb.c,v 1.42 2017/10/14 04:44:43 jsg Exp $ */ +/* $OpenBSD: pchb.c,v 1.43 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: pchb.c,v 1.1 2003/04/26 18:39:50 fvdl Exp $ */ /* * Copyright (c) 2000 Michael Shalayeff @@ -328,7 +328,7 @@ pchb_rnd(void *v) if (!sc->sc_rng_i--) { sc->sc_rng_i = 4; - add_true_randomness(sc->sc_rng_ax); + enqueue_randomness(sc->sc_rng_ax); } } diff --git a/sys/arch/hppa/gsc/harmony.c b/sys/arch/hppa/gsc/harmony.c index b63c6a757d0..24c52d0e3f6 100644 --- a/sys/arch/hppa/gsc/harmony.c +++ b/sys/arch/hppa/gsc/harmony.c @@ -1,4 +1,4 @@ -/* $OpenBSD: harmony.c,v 1.33 2016/09/19 06:46:43 ratchov Exp $ */ +/* $OpenBSD: harmony.c,v 1.34 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2003 Jason L. Wright (jason@thought.net) @@ -117,7 +117,7 @@ void harmony_acc_tmo(void *); (sc)->sc_acc <<= 1; \ (sc)->sc_acc |= READ_REG((sc), HARMONY_DIAG) & DIAG_CO; \ if ((sc)->sc_acc_cnt++ && !((sc)->sc_acc_cnt % 32)) \ - add_true_randomness((sc)->sc_acc_num ^= (sc)->sc_acc); \ + enqueue_randomness((sc)->sc_acc_num ^= (sc)->sc_acc); \ } while(0) int diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c index 7e303d15aaa..a6c3752fd0e 100644 --- a/sys/arch/i386/i386/bios.c +++ b/sys/arch/i386/i386/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.117 2018/04/11 15:44:08 bluhm Exp $ */ +/* $OpenBSD: bios.c,v 1.118 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 1997-2001 Michael Shalayeff @@ -1008,7 +1008,7 @@ smbios_info(char * str) if (sminfop) { infolen = strlen(sminfop) + 1; for (i = 0; i < infolen - 1; i++) - add_timer_randomness(sminfop[i]); + enqueue_randomness(sminfop[i]); hw_serial = malloc(infolen, M_DEVBUF, M_NOWAIT); if (hw_serial) strlcpy(hw_serial, sminfop, infolen); @@ -1033,7 +1033,7 @@ smbios_info(char * str) hw_uuid = "Not Set"; else { for (i = 0; i < sizeof(sys->uuid); i++) - add_timer_randomness(sys->uuid[i]); + enqueue_randomness(sys->uuid[i]); hw_uuid = malloc(SMBIOS_UUID_REPLEN, M_DEVBUF, M_NOWAIT); if (hw_uuid) { diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c index 48527ddd8a3..cf3f9e12205 100644 --- a/sys/arch/i386/i386/cpu.c +++ b/sys/arch/i386/i386/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.90 2018/04/20 07:27:54 mlarkin Exp $ */ +/* $OpenBSD: cpu.c,v 1.91 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: cpu.c,v 1.1.2.7 2000/06/26 02:04:05 sommerfeld Exp $ */ /*- @@ -530,7 +530,7 @@ rdrand(void *v) "setc %1\n" : "=r" (r), "=qm" (valid) ); if (valid) - add_true_randomness(r); + enqueue_randomness(r); } if (tmo) diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index ddfcafb1f38..827cd227812 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.42 2018/02/21 21:09:57 mikeb Exp $ */ +/* $OpenBSD: via.c,v 1.43 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -536,7 +536,7 @@ viac3_rnd(void *v) #endif for (i = 0, p = buffer; i < VIAC3_RNG_BUFSIZ; i++, p++) - add_true_randomness(*p); + enqueue_randomness(*p); timeout_add_msec(tmo, 10); } diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c index 1f47db76948..a359b99bb6e 100644 --- a/sys/arch/i386/pci/glxsb.c +++ b/sys/arch/i386/pci/glxsb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glxsb.c,v 1.34 2017/12/27 15:10:16 fcambus Exp $ */ +/* $OpenBSD: glxsb.c,v 1.35 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org> @@ -314,7 +314,7 @@ glxsb_rnd(void *v) status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SB_RANDOM_NUM_STATUS); if (status & SB_RNS_TRNG_VALID) { value = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SB_RANDOM_NUM); - add_true_randomness(value); + enqueue_randomness(value); } timeout_add_msec(&sc->sc_to, 10); diff --git a/sys/arch/i386/pci/pchb.c b/sys/arch/i386/pci/pchb.c index 6d2b1e54d8a..11e78f855db 100644 --- a/sys/arch/i386/pci/pchb.c +++ b/sys/arch/i386/pci/pchb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pchb.c,v 1.89 2014/03/26 14:41:41 mpi Exp $ */ +/* $OpenBSD: pchb.c,v 1.90 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: pchb.c,v 1.65 2007/08/15 02:26:13 markd Exp $ */ /* @@ -473,7 +473,7 @@ pchb_rnd(void *v) if (!sc->sc_rng_i--) { sc->sc_rng_i = 4; - add_true_randomness(sc->sc_rng_ax); + enqueue_randomness(sc->sc_rng_ax); } } diff --git a/sys/arch/octeon/dev/octrng.c b/sys/arch/octeon/dev/octrng.c index 9b34e02aae2..3d65f79ebc8 100644 --- a/sys/arch/octeon/dev/octrng.c +++ b/sys/arch/octeon/dev/octrng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octrng.c,v 1.6 2015/07/19 21:11:47 jasper Exp $ */ +/* $OpenBSD: octrng.c,v 1.7 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2013 Paul Irofti <pirofti@openbsd.org> * @@ -118,6 +118,6 @@ octrng_rnd(void *arg) DPRINTF(("%#llX ", value)); /* WARNING: very verbose */ - add_true_randomness(value); + enqueue_randomness(value); timeout_add_msec(&sc->sc_to, 10); } diff --git a/sys/arch/sparc64/dev/vrng.c b/sys/arch/sparc64/dev/vrng.c index 6e225b36fc9..bc374a36939 100644 --- a/sys/arch/sparc64/dev/vrng.c +++ b/sys/arch/sparc64/dev/vrng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vrng.c,v 1.4 2010/08/07 03:50:01 krw Exp $ */ +/* $OpenBSD: vrng.c,v 1.5 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2008 Mark Kettenis * @@ -149,8 +149,8 @@ vrng_rnd(void *v) if ((sc->sc_count++ % 100) == 0) printf("vrng: %lx\n", rnd); #endif - add_true_randomness(rnd); - add_true_randomness(rnd >> 32); + enqueue_randomness(rnd); + enqueue_randomness(rnd >> 32); } if (err != H_EOK && err != H_EWOULDBLOCK) printf("vrng_rnd: err = %d\n", err); diff --git a/sys/dev/acpi/acpihve.c b/sys/dev/acpi/acpihve.c index 6b573a837e6..037e82a35e3 100644 --- a/sys/dev/acpi/acpihve.c +++ b/sys/dev/acpi/acpihve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpihve.c,v 1.1 2017/01/10 08:54:14 jsg Exp $ */ +/* $OpenBSD: acpihve.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2017 Jonathan Gray <jsg@openbsd.org> @@ -83,7 +83,7 @@ acpihve_attach(struct device *parent, struct device *self, void *aux) /* 64 bytes of entropy from OEM0 table */ for (i = 0; i < nitems(oem0->entropy); i++) - add_true_randomness(oem0->entropy[i]); + enqueue_randomness(oem0->entropy[i]); printf("\n"); } diff --git a/sys/dev/fdt/bcm2835_rng.c b/sys/dev/fdt/bcm2835_rng.c index 4712e835375..91305fe7a53 100644 --- a/sys/dev/fdt/bcm2835_rng.c +++ b/sys/dev/fdt/bcm2835_rng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcm2835_rng.c,v 1.1 2018/02/24 13:46:22 kettenis Exp $ */ +/* $OpenBSD: bcm2835_rng.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org> * @@ -107,7 +107,7 @@ bcmrng_rnd(void *arg) count = MIN(4, RNG_STATUS_COUNT(status)); for (i = 0; i < count; i++) { data = HREAD4(sc, RNG_DATA); - add_true_randomness(data); + enqueue_randomness(data); } timeout_add_sec(&sc->sc_to, 1); diff --git a/sys/dev/fdt/mvrng.c b/sys/dev/fdt/mvrng.c index 9b12e65b824..2169c0a9c23 100644 --- a/sys/dev/fdt/mvrng.c +++ b/sys/dev/fdt/mvrng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mvrng.c,v 1.1 2018/04/02 21:40:59 kettenis Exp $ */ +/* $OpenBSD: mvrng.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org> * @@ -136,10 +136,10 @@ mvrng_rnd(void *arg) HWRITE4(sc, RNG_STATUS, RNG_STATUS_SHUTDOWN); } if (status & RNG_STATUS_READY) { - add_true_randomness(HREAD4(sc, RNG_OUTPUT0)); - add_true_randomness(HREAD4(sc, RNG_OUTPUT1)); - add_true_randomness(HREAD4(sc, RNG_OUTPUT2)); - add_true_randomness(HREAD4(sc, RNG_OUTPUT3)); + enqueue_randomness(HREAD4(sc, RNG_OUTPUT0)); + enqueue_randomness(HREAD4(sc, RNG_OUTPUT1)); + enqueue_randomness(HREAD4(sc, RNG_OUTPUT2)); + enqueue_randomness(HREAD4(sc, RNG_OUTPUT3)); HWRITE4(sc, RNG_STATUS, RNG_STATUS_READY); } diff --git a/sys/dev/ic/ccp.c b/sys/dev/ic/ccp.c index 76bce67d254..360e24938f4 100644 --- a/sys/dev/ic/ccp.c +++ b/sys/dev/ic/ccp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ccp.c,v 1.1 2018/04/20 04:37:21 dlg Exp $ */ +/* $OpenBSD: ccp.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2018 David Gwynne <dlg@openbsd.org> @@ -57,7 +57,7 @@ ccp_rng(void *arg) trng = bus_space_read_4(sc->sc_iot, sc->sc_ioh, CCP_REG_TRNG); if (trng != 0) - add_true_randomness(trng); + enqueue_randomness(trng); timeout_add_msec(&sc->sc_tick, 100); } diff --git a/sys/dev/pci/amdpm.c b/sys/dev/pci/amdpm.c index 310a719f2af..7a0cff54547 100644 --- a/sys/dev/pci/amdpm.c +++ b/sys/dev/pci/amdpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amdpm.c,v 1.32 2013/12/06 21:03:03 deraadt Exp $ */ +/* $OpenBSD: amdpm.c,v 1.33 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> @@ -344,7 +344,7 @@ amdpm_rnd_callout(void *v) if ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, AMDPM_RNGSTAT) & AMDPM_RNGDONE) != 0) { reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, AMDPM_RNGDATA); - add_true_randomness(reg); + enqueue_randomness(reg); } timeout_add(&sc->sc_rnd_ch, 1); } diff --git a/sys/dev/pci/bktr/bktr_core.c b/sys/dev/pci/bktr/bktr_core.c index 40f3359e336..130f83448b9 100644 --- a/sys/dev/pci/bktr/bktr_core.c +++ b/sys/dev/pci/bktr/bktr_core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_core.c,v 1.38 2016/03/14 23:08:06 krw Exp $ */ +/* $OpenBSD: bktr_core.c,v 1.39 2018/04/28 15:44:59 jasper Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_core.c,v 1.114 2000/10/31 13:09:56 roger Exp $ */ /* @@ -608,7 +608,7 @@ common_bktr_intr( void *arg ) OUTB(bktr, BKTR_CAP_CTL, bktr->bktr_cap_ctl); - add_video_randomness(tdec_save); + enqueue_randomness(tdec_save); return 1; } @@ -622,7 +622,7 @@ common_bktr_intr( void *arg ) bktr_status, dstatus, INL(bktr, BKTR_RISC_COUNT) ); */ - add_video_randomness(INL(bktr, BKTR_RISC_COUNT)); + enqueue_randomness(INL(bktr, BKTR_RISC_COUNT)); /* * Disable future interrupts if a capture mode is not selected. diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c index 6f55e6783e5..4712a678dc0 100644 --- a/sys/dev/pci/hifn7751.c +++ b/sys/dev/pci/hifn7751.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hifn7751.c,v 1.177 2017/02/07 17:25:46 patrick Exp $ */ +/* $OpenBSD: hifn7751.c,v 1.178 2018/04/28 15:44:59 jasper Exp $ */ /* * Invertex AEON / Hifn 7751 driver @@ -420,8 +420,8 @@ hifn_rng(void *vsc) if (sc->sc_rngfirst) sc->sc_rngfirst = 0; else { - add_true_randomness(num1); - add_true_randomness(num2); + enqueue_randomness(num1); + enqueue_randomness(num2); } } } else { @@ -430,7 +430,7 @@ hifn_rng(void *vsc) if (sc->sc_rngfirst) sc->sc_rngfirst = 0; else - add_true_randomness(num1); + enqueue_randomness(num1); } timeout_add(&sc->sc_rngto, sc->sc_rnghz); diff --git a/sys/dev/pci/safe.c b/sys/dev/pci/safe.c index 0a4c0de75a5..801e982455f 100644 --- a/sys/dev/pci/safe.c +++ b/sys/dev/pci/safe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safe.c,v 1.42 2017/02/07 17:25:46 patrick Exp $ */ +/* $OpenBSD: safe.c,v 1.43 2018/04/28 15:44:59 jasper Exp $ */ /*- * Copyright (c) 2003 Sam Leffler, Errno Consulting @@ -1236,7 +1236,7 @@ retry: WRITE_REG(sc, SAFE_RNG_ALM_CNT, 0); for (i = 0; i < maxwords; i++) - add_true_randomness(buf[i]); + enqueue_randomness(buf[i]); timeout_add_sec(&sc->sc_rngto, safe_rnginterval); } diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c index 70517670e7b..b7015fd33c5 100644 --- a/sys/dev/pci/ubsec.c +++ b/sys/dev/pci/ubsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ubsec.c,v 1.163 2017/02/07 17:25:46 patrick Exp $ */ +/* $OpenBSD: ubsec.c,v 1.164 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -1453,7 +1453,7 @@ ubsec_callback2(struct ubsec_softc *sc, struct ubsec_q2 *q) rng->rng_buf.dma_map->dm_mapsize, BUS_DMASYNC_POSTREAD); p = (u_int32_t *)rng->rng_buf.dma_vaddr; for (i = 0; i < UBSEC_RNG_BUFSIZ; p++, i++) - add_true_randomness(*p); + enqueue_randomness(*p); rng->rng_used = 0; timeout_add(&sc->sc_rngto, sc->sc_rnghz); break; diff --git a/sys/dev/pv/viornd.c b/sys/dev/pv/viornd.c index dc0a43738b7..9d1e8c60938 100644 --- a/sys/dev/pv/viornd.c +++ b/sys/dev/pv/viornd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viornd.c,v 1.1 2017/01/21 11:22:48 reyk Exp $ */ +/* $OpenBSD: viornd.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2014 Stefan Fritsch <sf@sfritsch.de> @@ -172,7 +172,7 @@ viornd_vq_done(struct virtqueue *vq) printf("%s: got %d bytes of entropy\n", __func__, len); #endif for (i = 0; (i + 1) * sizeof(int) <= len; i++) - add_true_randomness(sc->sc_buf[i]); + enqueue_randomness(sc->sc_buf[i]); if (sc->sc_interval) timeout_add_sec(&sc->sc_tick, sc->sc_interval); diff --git a/sys/dev/pv/vmt.c b/sys/dev/pv/vmt.c index 6e74ad65a97..179136a3ba2 100644 --- a/sys/dev/pv/vmt.c +++ b/sys/dev/pv/vmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmt.c,v 1.14 2018/03/08 05:33:56 jmatthew Exp $ */ +/* $OpenBSD: vmt.c,v 1.15 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2007 David Crawshaw <david@zentus.com> @@ -479,10 +479,10 @@ vmt_resume(void) vm_cmd(&frame); rdrand(NULL); - add_true_randomness(frame.eax.word); - add_true_randomness(frame.esi.word); - add_true_randomness(frame.edx.word); - add_true_randomness(frame.ebx.word); + enqueue_randomness(frame.eax.word); + enqueue_randomness(frame.esi.word); + enqueue_randomness(frame.edx.word); + enqueue_randomness(frame.ebx.word); resume_randomness(NULL, 0); } diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index e33cb5fd7c0..1ed87557db3 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.198 2018/02/09 03:01:24 deraadt Exp $ */ +/* $OpenBSD: rnd.c,v 1.199 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2011 Theo de Raadt. @@ -199,7 +199,7 @@ /* * Raw entropy collection from device drivers; at interrupt context or not. - * add_*_randomness() provide data which is put into the entropy queue. + * enqueue_randomness() provide data which is put into the entropy queue. */ #define QEVLEN 128 /* must be a power of 2 */ @@ -284,22 +284,15 @@ rnd_qlen(void) * are for keyboard scan codes, 256 and upwards - for interrupts. */ void -enqueue_randomness(u_int state, u_int val) +enqueue_randomness(u_int val) { struct rand_event *rep; struct timespec ts; u_int qlen; -#ifdef DIAGNOSTIC - if (state >= RND_SRC_NUM) - return; -#endif - if (timeout_initialized(&rnd_timeout)) nanotime(&ts); - val += state << 13; - mtx_enter(&rnd_enqlck); rep = rnd_put(); rep->re_time += ts.tv_nsec ^ (ts.tv_sec << 20); @@ -417,7 +410,7 @@ extract_entropy(u_int8_t *buf) memcpy(buf, digest, EBUFSIZE); /* Modify pool so next hash will produce different results */ - add_timer_randomness(EBUFSIZE); + enqueue_randomness(EBUFSIZE); dequeue_randomness(NULL); /* Wipe data from memory */ @@ -447,8 +440,8 @@ suspend_randomness(void) struct timespec ts; getnanotime(&ts); - add_true_randomness(ts.tv_sec); - add_true_randomness(ts.tv_nsec); + enqueue_randomness(ts.tv_sec); + enqueue_randomness(ts.tv_nsec); dequeue_randomness(NULL); rs_count = 0; @@ -463,8 +456,8 @@ resume_randomness(char *buf, size_t buflen) if (buf && buflen) _rs_seed(buf, buflen); getnanotime(&ts); - add_true_randomness(ts.tv_sec); - add_true_randomness(ts.tv_nsec); + enqueue_randomness(ts.tv_sec); + enqueue_randomness(ts.tv_nsec); dequeue_randomness(NULL); rs_count = 0; diff --git a/sys/dev/rndvar.h b/sys/dev/rndvar.h index 98b70e8919a..e5cc8c16117 100644 --- a/sys/dev/rndvar.h +++ b/sys/dev/rndvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rndvar.h,v 1.38 2016/05/23 15:48:59 deraadt Exp $ */ +/* $OpenBSD: rndvar.h,v 1.39 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 1996,2000 Michael Shalayeff. @@ -31,29 +31,10 @@ #ifndef __RNDVAR_H__ #define __RNDVAR_H__ -#define RND_SRC_TRUE 0 -#define RND_SRC_TIMER 1 -#define RND_SRC_MOUSE 2 -#define RND_SRC_TTY 3 -#define RND_SRC_DISK 4 -#define RND_SRC_NET 5 -#define RND_SRC_AUDIO 6 -#define RND_SRC_VIDEO 7 -#define RND_SRC_NUM 8 - #ifdef _KERNEL -#define add_true_randomness(d) enqueue_randomness(RND_SRC_TRUE, (int)(d)) -#define add_timer_randomness(d) enqueue_randomness(RND_SRC_TIMER, (int)(d)) -#define add_mouse_randomness(d) enqueue_randomness(RND_SRC_MOUSE, (int)(d)) -#define add_tty_randomness(d) enqueue_randomness(RND_SRC_TTY, (int)(d)) -#define add_disk_randomness(d) enqueue_randomness(RND_SRC_DISK, (int)(d)) -#define add_net_randomness(d) enqueue_randomness(RND_SRC_NET, (int)(d)) -#define add_audio_randomness(d) enqueue_randomness(RND_SRC_AUDIO, (int)(d)) -#define add_video_randomness(d) enqueue_randomness(RND_SRC_VIDEO, (int)(d)) - void random_start(void); -void enqueue_randomness(unsigned int, unsigned int); +void enqueue_randomness(unsigned int); void suspend_randomness(void); void resume_randomness(char *, size_t); diff --git a/sys/dev/usb/uonerng.c b/sys/dev/usb/uonerng.c index a9f81810b73..9e59988a187 100644 --- a/sys/dev/usb/uonerng.c +++ b/sys/dev/usb/uonerng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uonerng.c,v 1.2 2016/09/02 09:14:59 mpi Exp $ */ +/* $OpenBSD: uonerng.c,v 1.3 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (C) 2015 Devin Reade <gdr@gno.org> * Copyright (C) 2015 Sean Levy <attila@stalphonsos.com> @@ -424,7 +424,7 @@ uonerng_task(void *arg) int_count = len / sizeof(int); for (i = 0; i < int_count; i++) { - add_true_randomness(sc->sc_buf[i]); + enqueue_randomness(sc->sc_buf[i]); } bail: diff --git a/sys/dev/usb/urng.c b/sys/dev/usb/urng.c index 81403da7774..a221c978fab 100644 --- a/sys/dev/usb/urng.c +++ b/sys/dev/usb/urng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: urng.c,v 1.7 2017/09/12 19:14:35 jasper Exp $ */ +/* $OpenBSD: urng.c,v 1.8 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2017 Jasper Lievisse Adriaanse <jasper@openbsd.org> @@ -280,7 +280,7 @@ urng_task(void *arg) len /= sizeof(int); for (i = 0; i < len; i++) { - add_true_randomness(sc->sc_buf[i]); + enqueue_randomness(sc->sc_buf[i]); } bail: #ifdef URNG_MEASURE_RATE diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c index 78ad9e110d4..0b0f654c395 100644 --- a/sys/dev/wscons/wsmouse.c +++ b/sys/dev/wscons/wsmouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouse.c,v 1.43 2018/01/13 11:54:01 bru Exp $ */ +/* $OpenBSD: wsmouse.c,v 1.44 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */ /* @@ -1106,7 +1106,7 @@ wsmouse_input_sync(struct device *sc) evq.result = EVQ_RESULT_NONE; getnanotime(&evq.ts); - add_mouse_randomness(input->btn.buttons + enqueue_randomness(input->btn.buttons ^ input->motion.dx ^ input->motion.dy ^ input->motion.pos.x ^ input->motion.pos.y ^ input->motion.dz ^ input->motion.dw); diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index ab12daba7e6..2f3f92249ca 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_tc.c,v 1.31 2017/03/07 20:22:37 dhill Exp $ */ +/* $OpenBSD: kern_tc.c,v 1.32 2018/04/28 15:44:59 jasper Exp $ */ /* * Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org> @@ -278,7 +278,7 @@ tc_init(struct timecounter *tc) tc->tc_frequency < timecounter->tc_frequency) return; (void)tc->tc_get_timecount(tc); - add_timer_randomness(tc->tc_get_timecount(tc)); + enqueue_randomness(tc->tc_get_timecount(tc)); timecounter = tc; } @@ -308,7 +308,7 @@ tc_setrealtimeclock(struct timespec *ts) bintime_add(&bt2, &boottimebin); boottimebin = bt; bintime2timespec(&bt, &boottime); - add_timer_randomness(ts->tv_sec); + enqueue_randomness(ts->tv_sec); /* XXX fiddle all the little crinkly bits around the fiords... */ tc_windup(); @@ -343,7 +343,7 @@ tc_setclock(struct timespec *ts) return; } - add_timer_randomness(ts->tv_sec); + enqueue_randomness(ts->tv_sec); timespec2bintime(ts, &bt); bintime_sub(&bt, &boottimebin); diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index f9a8d97cc85..7bb2c0d9af3 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.233 2018/03/05 03:31:39 jsg Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.234 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -1128,7 +1128,7 @@ disk_attach_callback(void *xdat) /* Read disklabel. */ if (disk_readlabel(&dl, dk->dk_devno, errbuf, sizeof(errbuf)) == NULL) { - add_timer_randomness(dl.d_checksum); + enqueue_randomness(dl.d_checksum); dk->dk_flags |= DKF_LABELVALID; } @@ -1270,7 +1270,7 @@ disk_unbusy(struct disk *diskp, long bcount, daddr_t blkno, int read) mtx_leave(&diskp->dk_mtx); - add_disk_randomness(bcount ^ diff_time.tv_usec ^ + enqueue_randomness(bcount ^ diff_time.tv_usec ^ (blkno >> 32) ^ (blkno & 0xffffffff)); } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 1a562b50f99..f030029cc05 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.138 2018/04/28 03:13:04 visa Exp $ */ +/* $OpenBSD: tty.c,v 1.139 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -237,7 +237,7 @@ ttyinput(int c, struct tty *tp) int i, error; int s; - add_tty_randomness(tp->t_dev << 8 | c); + enqueue_randomness(tp->t_dev << 8 | c); /* * If receiver is not enabled, drop it. */ diff --git a/sys/net/if.c b/sys/net/if.c index d8eb308f899..b031e1dff47 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.550 2018/04/24 15:40:55 pirofti Exp $ */ +/* $OpenBSD: if.c,v 1.551 2018/04/28 15:44:59 jasper Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -881,7 +881,7 @@ if_input_process(struct ifnet *ifp, struct mbuf_list *ml) return; if (!ISSET(ifp->if_xflags, IFXF_CLONED)) - add_net_randomness(ml_len(ml)); + enqueue_randomness(ml_len(ml)); /* * We grab the NET_LOCK() before processing any packet to |