Le 29 juil. 2013 à 22:26, David E. O'Brien a écrit :

> Author: obrien
> Date: Mon Jul 29 20:26:27 2013
> New Revision: 253779
> URL: http://svnweb.freebsd.org/changeset/base/253779
> 
> Log:
>  Decouple yarrow from random(4) device.
> 
>  * Make Yarrow an optional kernel component -- enabled by "YARROW_RNG" option.
>    The files sha2.c, hash.c, randomdev_soft.c and yarrow.c comprise yarrow.
> 
>  * random(4) device doesn't really depend on rijndael-*.  Yarrow, however, 
> does.
> 
>  * Add random_adaptors.[ch] which is basically a store of random_adaptor's.
>    random_adaptor is basically an adapter that plugs in to random(4).
>    random_adaptor can only be plugged in to random(4) very early in bootup.
>    Unplugging random_adaptor from random(4) is not supported, and is probably 
> a
>    bad idea anyway, due to potential loss of entropy pools.
>    We currently have 3 random_adaptors:
>    + yarrow
>    + rdrand (ivy.c)
>    + nehemeiah
> 
>  * Remove platform dependent logic from probe.c, and move it into
>    corresponding registration routines of each random_adaptor provider.
>    probe.c doesn't do anything other than picking a specific random_adaptor
>    from a list of registered ones.
> 
>  * If the kernel doesn't have any random_adaptor adapters present then the
>    creation of /dev/random is postponed until next random_adaptor is 
> kldload'ed.
> 
>  * Fix randomdev_soft.c to refer to its own random_adaptor, instead of a
>    system wide one.
> 

We need to have very good random by default.
Even selecting HW random automatically is not very good. HW random is difficult 
to trust.

Why not having a good default software random seeded by automatically detected 
HW random ?
After that the user can choose to bypass the software random a feed directly by 
the HW random source.

>  Submitted by: arthurm...@gmail.com, obrien
>  Obtained from: Juniper Networks
>  Reviewed by: obrien
> 
> Modified:
>  head/UPDATING
>  head/share/man/man4/random.4
>  head/sys/amd64/conf/GENERIC
>  head/sys/arm/conf/AC100
>  head/sys/arm/conf/ARMADAXP
>  head/sys/arm/conf/ARNDALE
>  head/sys/arm/conf/ATMEL
>  head/sys/arm/conf/AVILA
>  head/sys/arm/conf/BEAGLEBONE
>  head/sys/arm/conf/BWCT
>  head/sys/arm/conf/CAMBRIA
>  head/sys/arm/conf/CNS11XXNAS
>  head/sys/arm/conf/CRB
>  head/sys/arm/conf/CUBIEBOARD
>  head/sys/arm/conf/DB-78XXX
>  head/sys/arm/conf/DB-88F5XXX
>  head/sys/arm/conf/DB-88F6XXX
>  head/sys/arm/conf/DOCKSTAR
>  head/sys/arm/conf/DREAMPLUG-1001
>  head/sys/arm/conf/EA3250
>  head/sys/arm/conf/EB9200
>  head/sys/arm/conf/EFIKA_MX
>  head/sys/arm/conf/EP80219
>  head/sys/arm/conf/ETHERNUT5
>  head/sys/arm/conf/GUMSTIX
>  head/sys/arm/conf/HL200
>  head/sys/arm/conf/HL201
>  head/sys/arm/conf/IQ31244
>  head/sys/arm/conf/KB920X
>  head/sys/arm/conf/LN2410SBC
>  head/sys/arm/conf/NSLU
>  head/sys/arm/conf/PANDABOARD
>  head/sys/arm/conf/QILA9G20
>  head/sys/arm/conf/RPI-B
>  head/sys/arm/conf/SAM9260EK
>  head/sys/arm/conf/SAM9G20EK
>  head/sys/arm/conf/SAM9X25EK
>  head/sys/arm/conf/SHEEVAPLUG
>  head/sys/arm/conf/SN9G45
>  head/sys/arm/conf/TS7800
>  head/sys/arm/conf/VERSATILEPB
>  head/sys/arm/conf/ZEDBOARD
>  head/sys/conf/NOTES
>  head/sys/conf/files
>  head/sys/conf/options
>  head/sys/dev/random/ivy.c
>  head/sys/dev/random/nehemiah.c
>  head/sys/dev/random/probe.c
>  head/sys/dev/random/randomdev.c
>  head/sys/dev/random/randomdev.h
>  head/sys/dev/random/randomdev_soft.c
>  head/sys/dev/random/randomdev_soft.h
>  head/sys/dev/random/yarrow.c
>  head/sys/i386/conf/GENERIC
>  head/sys/i386/conf/XBOX
>  head/sys/i386/conf/XEN
>  head/sys/ia64/conf/GENERIC
>  head/sys/mips/conf/AR71XX_BASE
>  head/sys/mips/conf/AR724X_BASE
>  head/sys/mips/conf/AR91XX_BASE
>  head/sys/mips/conf/AR933X_BASE
>  head/sys/mips/conf/BERI_TEMPLATE
>  head/sys/mips/conf/DIR-825
>  head/sys/mips/conf/GXEMUL
>  head/sys/mips/conf/OCTEON1
>  head/sys/mips/conf/PB92
>  head/sys/mips/conf/RT305X
>  head/sys/mips/conf/XLR64
>  head/sys/mips/conf/XLRN32
>  head/sys/mips/conf/std.SWARM
>  head/sys/mips/conf/std.XLP
>  head/sys/modules/Makefile
>  head/sys/modules/random/Makefile
>  head/sys/pc98/conf/GENERIC
>  head/sys/powerpc/conf/GENERIC
>  head/sys/powerpc/conf/GENERIC64
>  head/sys/powerpc/conf/MPC85XX
>  head/sys/powerpc/conf/WII
>  head/sys/sparc64/conf/GENERIC
>  head/tools/tools/sysdoc/sysdoc.sh
>  head/tools/tools/sysdoc/tunables.mdoc
> 
> Modified: head/UPDATING
> ==============================================================================
> --- head/UPDATING     Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/UPDATING     Mon Jul 29 20:26:27 2013        (r253779)
> @@ -31,6 +31,19 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10
>       disable the most expensive debugging functionality run
>       "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
> 
> +20130729:
> +     random(4) and actual RNG implementations (aka, adaptors) have been
> +     further decoupled.  If you are running a custom kernel, you may
> +     need to explicitly enable at least one RNG adaptor in your kernel
> +     config.  For example, to use Yarrow, add "options YARROW_RNG" to
> +     your kernel config.  For hardware backed RNGs, use either
> +     "RDRAND_RNG" or "PADLOCK_RNG" options.
> +     If you use random.ko via 'random_load="YES"' in /boot/loader.conf
> +     instead of "device random", you will need to change that to
> +     'yarrow_rng_load="YES"', 'rdrand_rng_load="YES"', or
> +     'padlock_rng_load="YES"'.  random.ko will be loaded automatically
> +     as a dependency module.
> +
> 20130726:
>       Behavior of devfs rules path matching has been changed.
>       Pattern is now always matched against fully qualified devfs
> 
> Modified: head/share/man/man4/random.4
> ==============================================================================
> --- head/share/man/man4/random.4      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/share/man/man4/random.4      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -23,7 +23,7 @@
> .\"
> .\" $FreeBSD$
> .\"
> -.Dd September 7, 2012
> +.Dd July 29, 2013
> .Dt RANDOM 4
> .Os
> .Sh NAME
> @@ -43,6 +43,13 @@ The device will probe for
> certain hardware entropy sources,
> and use these in preference to the fallback,
> which is a generator implemented in software.
> +If the kernel environment MIB's
> +.Va hw.nehemiah_rng_enable
> +or
> +.Va hw.ivy_rng_enable
> +are set to
> +.Dq Li 0 ,
> +the associated hardware entropy source will be ignored.
> .Pp
> If the device is using
> the software generator,
> @@ -74,6 +81,7 @@ device, use the command line:
> .Pp
> which results in something like:
> .Bd -literal -offset indent
> +kern.random.adaptors:  yarrow
> kern.random.sys.seeded: 1
> kern.random.sys.harvest.ethernet: 1
> kern.random.sys.harvest.point_to_point: 1
> @@ -89,7 +97,9 @@ kern.random.yarrow.slowoverthresh: 2
> (These would not be seen if a
> hardware generator is present.)
> .Pp
> -All settings are read/write.
> +Other than
> +.Dl kern.random.adaptors
> +all settings are read/write.
> .Pp
> The
> .Va kern.random.sys.seeded
> 
> Modified: head/sys/amd64/conf/GENERIC
> ==============================================================================
> --- head/sys/amd64/conf/GENERIC       Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/amd64/conf/GENERIC       Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -295,6 +295,7 @@ device            loop            # Network loopback
> device                random          # Entropy device
> options       PADLOCK_RNG     # VIA Padlock RNG
> options       RDRAND_RNG      # Intel Bull Mountain RNG
> +options      YARROW_RNG      # Yarrow software RNG
> device                ether           # Ethernet support
> device                vlan            # 802.1Q VLAN support
> device                tun             # Packet tunnel.
> 
> Modified: head/sys/arm/conf/AC100
> ==============================================================================
> --- head/sys/arm/conf/AC100   Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/AC100   Mon Jul 29 20:26:27 2013        (r253779)
> @@ -61,6 +61,7 @@ options     MUTEX_DEBUG
> 
> # Pseudo devices
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                pty
> device                loop
> device                md
> 
> Modified: head/sys/arm/conf/ARMADAXP
> ==============================================================================
> --- head/sys/arm/conf/ARMADAXP        Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/ARMADAXP        Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -61,6 +61,7 @@ options     KDB_TRACE
> 
> # Pseudo devices
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                pty
> device                loop
> device                md
> 
> Modified: head/sys/arm/conf/ARNDALE
> ==============================================================================
> --- head/sys/arm/conf/ARNDALE Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/ARNDALE Mon Jul 29 20:26:27 2013        (r253779)
> @@ -88,6 +88,7 @@ options             ROOTDEVNAME=\"ufs:/dev/da0\"
> 
> device                loop
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                pty
> device                md
> device                gpio
> 
> Modified: head/sys/arm/conf/ATMEL
> ==============================================================================
> --- head/sys/arm/conf/ATMEL   Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/ATMEL   Mon Jul 29 20:26:27 2013        (r253779)
> @@ -134,6 +134,7 @@ device            geom_map        # GEOM partition mappin
> # Pseudo devices.
> device                loop            # Network loopback
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> device                ether           # Ethernet support
> device                vlan            # 802.1Q VLAN support
> device                tun             # Packet tunnel.
> 
> Modified: head/sys/arm/conf/AVILA
> ==============================================================================
> --- head/sys/arm/conf/AVILA   Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/AVILA   Mon Jul 29 20:26:27 2013        (r253779)
> @@ -107,6 +107,7 @@ device            if_bridge
> 
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> # Wireless NIC cards
> device                wlan            # 802.11 support
> 
> Modified: head/sys/arm/conf/BEAGLEBONE
> ==============================================================================
> --- head/sys/arm/conf/BEAGLEBONE      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/BEAGLEBONE      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -90,6 +90,7 @@ device              pty
> device                snp
> device                md
> device                random                  # Entropy device
> +options      YARROW_RNG              # Yarrow software RNG
> 
> # I2C support
> device                iicbus
> 
> Modified: head/sys/arm/conf/BWCT
> ==============================================================================
> --- head/sys/arm/conf/BWCT    Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/BWCT    Mon Jul 29 20:26:27 2013        (r253779)
> @@ -68,6 +68,7 @@ options     NO_FFS_SNAPSHOT
> options       NO_SWAPPING
> device                loop
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                ether
> device                vlan
> device                uart
> 
> Modified: head/sys/arm/conf/CAMBRIA
> ==============================================================================
> --- head/sys/arm/conf/CAMBRIA Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/CAMBRIA Mon Jul 29 20:26:27 2013        (r253779)
> @@ -110,6 +110,7 @@ device            if_bridge
> 
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> # Wireless NIC cards
> device                wlan            # 802.11 support
> 
> Modified: head/sys/arm/conf/CNS11XXNAS
> ==============================================================================
> --- head/sys/arm/conf/CNS11XXNAS      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/CNS11XXNAS      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -102,6 +102,7 @@ device            loop
> 
> device                md
> device          random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> #options      ARM_USE_SMALL_ALLOC
> 
> 
> Modified: head/sys/arm/conf/CRB
> ==============================================================================
> --- head/sys/arm/conf/CRB     Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/CRB     Mon Jul 29 20:26:27 2013        (r253779)
> @@ -105,6 +105,7 @@ options   DDB                     #Enable the kernel 
> debugg
> options       XSCALE_CACHE_READ_WRITE_ALLOCATE
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> device                iopwdog
> options       ARM_USE_SMALL_ALLOC
> 
> Modified: head/sys/arm/conf/CUBIEBOARD
> ==============================================================================
> --- head/sys/arm/conf/CUBIEBOARD      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/CUBIEBOARD      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -92,6 +92,7 @@ device              pty
> device                snp
> device                md
> device                random                  # Entropy device
> +options      YARROW_RNG              # Yarrow software RNG
> 
> # I2C support
> #device               iicbus
> @@ -130,4 +131,3 @@ device            miibus
> options               FDT
> options               FDT_DTB_STATIC
> makeoptions   FDT_DTS_FILE=cubieboard.dts
> -
> 
> Modified: head/sys/arm/conf/DB-78XXX
> ==============================================================================
> --- head/sys/arm/conf/DB-78XXX        Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/DB-78XXX        Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -55,6 +55,7 @@ device              pci
> device                loop
> device                md
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> 
> # Serial ports
> device                uart
> 
> Modified: head/sys/arm/conf/DB-88F5XXX
> ==============================================================================
> --- head/sys/arm/conf/DB-88F5XXX      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/DB-88F5XXX      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -54,6 +54,7 @@ device              pci
> device                md
> device                loop
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> 
> # Serial ports
> device                uart
> 
> Modified: head/sys/arm/conf/DB-88F6XXX
> ==============================================================================
> --- head/sys/arm/conf/DB-88F6XXX      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/DB-88F6XXX      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -55,6 +55,7 @@ device              pci
> device                loop
> device                md
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> 
> # Serial ports
> device                uart
> 
> Modified: head/sys/arm/conf/DOCKSTAR
> ==============================================================================
> --- head/sys/arm/conf/DOCKSTAR        Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/DOCKSTAR        Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -46,6 +46,7 @@ options     KDB
> # Pseudo devices
> device                md
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> 
> # Serial ports
> 
> Modified: head/sys/arm/conf/DREAMPLUG-1001
> ==============================================================================
> --- head/sys/arm/conf/DREAMPLUG-1001  Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/DREAMPLUG-1001  Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -62,6 +62,7 @@ device              loop                    #Network 
> loopback
> device        md                      #Memory/malloc disk
> device                pty                     #BSD-style compatibility pseudo 
> ttys
> device                random                  #Entropy device
> +options      YARROW_RNG              # Yarrow software RNG
> device        tun                     #Packet tunnel.
> device                ether                   #Required for all ethernet 
> devices
> device        vlan                    #802.1Q VLAN support
> 
> Modified: head/sys/arm/conf/EA3250
> ==============================================================================
> --- head/sys/arm/conf/EA3250  Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/EA3250  Mon Jul 29 20:26:27 2013        (r253779)
> @@ -54,6 +54,7 @@ device              loop
> device                md
> device                pty
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> 
> # Serial ports
> device                uart
> 
> Modified: head/sys/arm/conf/EB9200
> ==============================================================================
> --- head/sys/arm/conf/EB9200  Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/EB9200  Mon Jul 29 20:26:27 2013        (r253779)
> @@ -60,6 +60,7 @@ options     SX_NOINLINE
> options       NO_FFS_SNAPSHOT
> options       NO_SWAPPING
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> device                ether
> device                uart
> 
> Modified: head/sys/arm/conf/EFIKA_MX
> ==============================================================================
> --- head/sys/arm/conf/EFIKA_MX        Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/EFIKA_MX        Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -96,6 +96,7 @@ device              bpf             # Berkeley packet filter
> # Pseudo devices.
> device                loop            # Network loopback
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> device                ether           # Ethernet support
> #device               vlan            # 802.1Q VLAN support
> #device               tun             # Packet tunnel.
> 
> Modified: head/sys/arm/conf/EP80219
> ==============================================================================
> --- head/sys/arm/conf/EP80219 Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/EP80219 Mon Jul 29 20:26:27 2013        (r253779)
> @@ -101,6 +101,7 @@ options   DDB                     #Enable the kernel 
> debugg
> options       XSCALE_CACHE_READ_WRITE_ALLOCATE
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> options       ARM_USE_SMALL_ALLOC
> # Floppy drives
> 
> Modified: head/sys/arm/conf/ETHERNUT5
> ==============================================================================
> --- head/sys/arm/conf/ETHERNUT5       Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/ETHERNUT5       Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -126,6 +126,7 @@ device            geom_map        # GEOM partition mappin
> # Pseudo devices.
> device                loop            # Network loopback
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> device                ether           # Ethernet support
> #device               vlan            # 802.1Q VLAN support
> #device               tun             # Packet tunnel.
> 
> Modified: head/sys/arm/conf/GUMSTIX
> ==============================================================================
> --- head/sys/arm/conf/GUMSTIX Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/GUMSTIX Mon Jul 29 20:26:27 2013        (r253779)
> @@ -88,3 +88,4 @@ options     DDB                     #Enable the kernel 
> debugg
> 
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> Modified: head/sys/arm/conf/HL200
> ==============================================================================
> --- head/sys/arm/conf/HL200   Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/HL200   Mon Jul 29 20:26:27 2013        (r253779)
> @@ -65,6 +65,7 @@ options     RWLOCK_NOINLINE
> options       NO_FFS_SNAPSHOT
> options       NO_SWAPPING
> device                random
> +options      YARROW_RNG      # Yarrow software RNG
> device                loop
> device                ether
> device                uart
> 
> Modified: head/sys/arm/conf/HL201
> ==============================================================================
> --- head/sys/arm/conf/HL201   Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/HL201   Mon Jul 29 20:26:27 2013        (r253779)
> @@ -67,6 +67,7 @@ options     RWLOCK_NOINLINE
> options       NO_FFS_SNAPSHOT
> options       NO_SWAPPING
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> device                ether
> device                uart
> @@ -129,4 +130,3 @@ device            pass            # Passthrough device 
> (dire
> #device               wlan_tkip       # 802.11 TKIP support
> #device               wlan_amrr       # AMRR transmit rate control algorithm
> options       ROOTDEVNAME=\"ufs:da0s1a\"
> -
> 
> Modified: head/sys/arm/conf/IQ31244
> ==============================================================================
> --- head/sys/arm/conf/IQ31244 Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/IQ31244 Mon Jul 29 20:26:27 2013        (r253779)
> @@ -106,6 +106,7 @@ options   DDB                     #Enable the kernel 
> debugg
> options       XSCALE_CACHE_READ_WRITE_ALLOCATE
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> options       ARM_USE_SMALL_ALLOC
> # Floppy drives
> 
> Modified: head/sys/arm/conf/KB920X
> ==============================================================================
> --- head/sys/arm/conf/KB920X  Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/KB920X  Mon Jul 29 20:26:27 2013        (r253779)
> @@ -66,6 +66,7 @@ options     SX_NOINLINE
> options       NO_FFS_SNAPSHOT
> options       NO_SWAPPING
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> device                ether
> device                uart
> 
> Modified: head/sys/arm/conf/LN2410SBC
> ==============================================================================
> --- head/sys/arm/conf/LN2410SBC       Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/LN2410SBC       Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -62,6 +62,7 @@ options     SX_NOINLINE
> options       NO_FFS_SNAPSHOT
> options       NO_SWAPPING
> device                random
> +options      YARROW_RNG      # Yarrow software RNG
> 
> device                loop
> device                ether
> @@ -83,4 +84,3 @@ device              ohci
> device                umass
> device                scbus           # SCSI bus (required for da)
> device                da              # Direct Access (disks)
> -
> 
> Modified: head/sys/arm/conf/NSLU
> ==============================================================================
> --- head/sys/arm/conf/NSLU    Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/NSLU    Mon Jul 29 20:26:27 2013        (r253779)
> @@ -105,6 +105,7 @@ device            loop
> 
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> #options      ARM_USE_SMALL_ALLOC
> 
> 
> Modified: head/sys/arm/conf/PANDABOARD
> ==============================================================================
> --- head/sys/arm/conf/PANDABOARD      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/PANDABOARD      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -110,6 +110,7 @@ device            md
> #options      MD_ROOT_SIZE=7560
> 
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> # USB support
> device                usb
> 
> Modified: head/sys/arm/conf/QILA9G20
> ==============================================================================
> --- head/sys/arm/conf/QILA9G20        Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/QILA9G20        Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -77,6 +77,7 @@ options     NO_SWAPPING
> #options      DIAGNOSTIC
> 
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> device                bpf
> device                ether
> 
> Modified: head/sys/arm/conf/RPI-B
> ==============================================================================
> --- head/sys/arm/conf/RPI-B   Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/RPI-B   Mon Jul 29 20:26:27 2013        (r253779)
> @@ -86,6 +86,7 @@ options     INVARIANT_SUPPORT       #Extra sanity
> 
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> # USB support
> device                usb
> 
> Modified: head/sys/arm/conf/SAM9260EK
> ==============================================================================
> --- head/sys/arm/conf/SAM9260EK       Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/SAM9260EK       Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -134,6 +134,7 @@ device            mmcsd           # MMC/SD memory card
> # Pseudo devices.
> device                loop            # Network loopback
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> device                ether           # Ethernet support
> #device               vlan            # 802.1Q VLAN support
> #device               tun             # Packet tunnel.
> 
> Modified: head/sys/arm/conf/SAM9G20EK
> ==============================================================================
> --- head/sys/arm/conf/SAM9G20EK       Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/SAM9G20EK       Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -76,6 +76,7 @@ options     NO_SWAPPING
> #options      DIAGNOSTIC
> 
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> device                bpf
> device                ether
> 
> Modified: head/sys/arm/conf/SAM9X25EK
> ==============================================================================
> --- head/sys/arm/conf/SAM9X25EK       Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/SAM9X25EK       Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -77,6 +77,7 @@ options     NO_SWAPPING
> #options      DIAGNOSTIC
> 
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                pty
> device                loop
> device                bpf
> @@ -150,4 +151,3 @@ device            miibus
> #device               wlan_ccmp       # 802.11 CCMP support
> #device               wlan_tkip       # 802.11 TKIP support
> #device               wlan_amrr       # AMRR transmit rate control algorithm
> -
> 
> Modified: head/sys/arm/conf/SHEEVAPLUG
> ==============================================================================
> --- head/sys/arm/conf/SHEEVAPLUG      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/SHEEVAPLUG      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -45,6 +45,7 @@ options     KDB
> 
> # Pseudo devices
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> 
> # Serial ports
> 
> Modified: head/sys/arm/conf/SN9G45
> ==============================================================================
> --- head/sys/arm/conf/SN9G45  Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/SN9G45  Mon Jul 29 20:26:27 2013        (r253779)
> @@ -76,6 +76,7 @@ options     NO_SWAPPING
> #options      DIAGNOSTIC
> 
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                loop
> device                bpf
> device                ether
> 
> Modified: head/sys/arm/conf/TS7800
> ==============================================================================
> --- head/sys/arm/conf/TS7800  Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/arm/conf/TS7800  Mon Jul 29 20:26:27 2013        (r253779)
> @@ -48,6 +48,7 @@ device              pci
> device                md
> device                loop
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> 
> # Serial ports
> device                uart
> 
> Modified: head/sys/arm/conf/VERSATILEPB
> ==============================================================================
> --- head/sys/arm/conf/VERSATILEPB     Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/VERSATILEPB     Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -94,6 +94,7 @@ options     INVARIANT_SUPPORT       #Extra sanity
> 
> device                md
> device                random          # Entropy device
> +options      YARROW_RNG      # Yarrow software RNG
> 
> # Flattened Device Tree
> options         FDT
> 
> Modified: head/sys/arm/conf/ZEDBOARD
> ==============================================================================
> --- head/sys/arm/conf/ZEDBOARD        Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/arm/conf/ZEDBOARD        Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -66,6 +66,7 @@ options     KDB
> 
> device                loop
> device                random
> +options      YARROW_RNG              # Yarrow software RNG
> device                ether
> device                if_cgem                 # Zynq-7000 gig ethernet device
> device                mii
> 
> Modified: head/sys/conf/NOTES
> ==============================================================================
> --- head/sys/conf/NOTES       Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/conf/NOTES       Mon Jul 29 20:26:27 2013        (r253779)
> @@ -1132,6 +1132,9 @@ options         VFS_AIO
> # Cryptographically secure random number generator; /dev/random
> device                random
> 
> +# Yarrow software RNG adapter for random
> +options      YARROW_RNG
> +
> # The system memory devices; /dev/mem, /dev/kmem
> device                mem
> 
> 
> Modified: head/sys/conf/files
> ==============================================================================
> --- head/sys/conf/files       Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/conf/files       Mon Jul 29 20:26:27 2013        (r253779)
> @@ -540,8 +540,8 @@ crypto/des/des_ecb.c              optional crypto | 
> crypto/des/des_setkey.c               optional crypto | ipsec | netsmb
> crypto/rc4/rc4.c              optional netgraph_mppc_encryption | kgssapi
> crypto/rijndael/rijndael-alg-fst.c optional crypto | geom_bde | \
> -                                      ipsec | random | wlan_ccmp
> -crypto/rijndael/rijndael-api-fst.c optional geom_bde | random
> +                                      ipsec | yarrow_rng | wlan_ccmp
> +crypto/rijndael/rijndael-api-fst.c optional geom_bde | yarrow_rng
> crypto/rijndael/rijndael-api.c        optional crypto | ipsec | wlan_ccmp
> crypto/sha1.c                 optional carp | crypto | ipsec | \
>                                        netgraph_mppc_encryption | sctp
> @@ -2030,11 +2030,12 @@ rt2860.fw                     optional rt2860fw | 
> ralfw               \
>       no-obj no-implicit-rule                                         \
>       clean           "rt2860.fw"
> dev/random/harvest.c          standard
> -dev/random/hash.c            optional random
> +dev/random/hash.c            optional yarrow_rng
> dev/random/probe.c            optional random
> +dev/random/random_adaptors.c standard
> dev/random/randomdev.c                optional random
> -dev/random/randomdev_soft.c  optional random
> -dev/random/yarrow.c          optional random
> +dev/random/randomdev_soft.c  optional yarrow_rng
> +dev/random/yarrow.c          optional yarrow_rng
> dev/rc/rc.c                   optional rc
> dev/re/if_re.c                        optional re
> dev/rndtest/rndtest.c         optional rndtest
> 
> Modified: head/sys/conf/options
> ==============================================================================
> --- head/sys/conf/options     Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/conf/options     Mon Jul 29 20:26:27 2013        (r253779)
> @@ -905,3 +905,6 @@ RACCT             opt_global.h
> 
> # Resource Limits
> RCTL          opt_global.h
> +
> +# Software random number generators for random(4)
> +YARROW_RNG   opt_dontuse.h
> 
> Modified: head/sys/dev/random/ivy.c
> ==============================================================================
> --- head/sys/dev/random/ivy.c Mon Jul 29 19:50:30 2013        (r253778)
> +++ head/sys/dev/random/ivy.c Mon Jul 29 20:26:27 2013        (r253779)
> @@ -28,16 +28,19 @@
> #include <sys/cdefs.h>
> __FBSDID("$FreeBSD$");
> 
> -#include "opt_cpu.h"
> -
> -#ifdef RDRAND_RNG
> -
> #include <sys/param.h>
> #include <sys/time.h>
> +#include <sys/kernel.h>
> #include <sys/lock.h>
> +#include <sys/module.h>
> #include <sys/mutex.h>
> #include <sys/selinfo.h>
> #include <sys/systm.h>
> +
> +#include <machine/md_var.h>
> +#include <machine/specialreg.h>
> +
> +#include <dev/random/random_adaptors.h>
> #include <dev/random/randomdev.h>
> 
> #define       RETRY_COUNT     10
> @@ -46,7 +49,7 @@ static void random_ivy_init(void);
> static void random_ivy_deinit(void);
> static int random_ivy_read(void *, int);
> 
> -struct random_systat random_ivy = {
> +struct random_adaptor random_ivy = {
>       .ident = "Hardware, Intel IvyBridge+ RNG",
>       .init = random_ivy_init,
>       .deinit = random_ivy_deinit,
> @@ -114,4 +117,32 @@ random_ivy_read(void *buf, int c)
>       return (c - count);
> }
> 
> +static int
> +rdrand_modevent(module_t mod, int type, void *unused)
> +{
> +
> +     switch (type) {
> +     case MOD_LOAD:
> +             if (cpu_feature2 & CPUID2_RDRAND) {
> +                     random_adaptor_register("rdrand", &random_ivy);
> +                     EVENTHANDLER_INVOKE(random_adaptor_attach, &random_ivy);
> +                     return (0);
> +             } else {
> +#ifndef KLD_MODULE
> +                     if (bootverbose)
> #endif
> +                             printf(
> +                         "%s: RDRAND feature is not present on this CPU\n",
> +                                 random_ivy.ident);
> +#ifdef KLD_MODULE
> +                     return (ENXIO);
> +#else
> +                     return (0);
> +#endif
> +             }
> +     }
> +
> +     return (EINVAL);
> +}
> +
> +RANDOM_ADAPTOR_MODULE(random_rdrand, rdrand_modevent, 1);
> 
> Modified: head/sys/dev/random/nehemiah.c
> ==============================================================================
> --- head/sys/dev/random/nehemiah.c    Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/dev/random/nehemiah.c    Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -28,19 +28,20 @@
> #include <sys/cdefs.h>
> __FBSDID("$FreeBSD$");
> 
> -#include "opt_cpu.h"
> -
> -#ifdef PADLOCK_RNG
> -
> #include <sys/param.h>
> #include <sys/time.h>
> #include <sys/lock.h>
> #include <sys/mutex.h>
> +#include <sys/module.h>
> #include <sys/selinfo.h>
> #include <sys/systm.h>
> +#include <sys/kernel.h>
> 
> #include <machine/pcb.h>
> +#include <machine/md_var.h>
> +#include <machine/specialreg.h>
> 
> +#include <dev/random/random_adaptors.h>
> #include <dev/random/randomdev.h>
> 
> #define RANDOM_BLOCK_SIZE     256
> @@ -50,7 +51,7 @@ static void random_nehemiah_init(void);
> static void random_nehemiah_deinit(void);
> static int random_nehemiah_read(void *, int);
> 
> -struct random_systat random_nehemiah = {
> +struct random_adaptor random_nehemiah = {
>       .ident = "Hardware, VIA Nehemiah",
>       .init = random_nehemiah_init,
>       .deinit = random_nehemiah_deinit,
> @@ -208,4 +209,33 @@ random_nehemiah_read(void *buf, int c)
>       return (c);
> }
> 
> +static int
> +nehemiah_modevent(module_t mod, int type, void *unused)
> +{
> +
> +     switch (type) {
> +     case MOD_LOAD:
> +             if (via_feature_rng & VIA_HAS_RNG) {
> +                     random_adaptor_register("nehemiah", &random_nehemiah);
> +                     EVENTHANDLER_INVOKE(random_adaptor_attach,
> +                         &random_nehemiah);
> +                     return (0);
> +             } else {
> +#ifndef KLD_MODULE
> +                     if (bootverbose)
> #endif
> +                             printf(
> +                         "%s: VIA RNG feature is not present on this CPU\n",
> +                                 random_nehemiah.ident);
> +#ifdef KLD_MODULE
> +                     return (ENXIO);
> +#else
> +                     return (0);
> +#endif
> +             }
> +     }
> +
> +     return (EINVAL);
> +}
> +
> +RANDOM_ADAPTOR_MODULE(nehemiah, nehemiah_modevent, 1);
> 
> Modified: head/sys/dev/random/probe.c
> ==============================================================================
> --- head/sys/dev/random/probe.c       Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/dev/random/probe.c       Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -28,66 +28,35 @@
> #include <sys/cdefs.h>
> __FBSDID("$FreeBSD$");
> 
> -#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
> +#if defined(__amd64__) || defined(__i386__)
> #include "opt_cpu.h"
> #endif
> 
> -#include <sys/types.h>
> #include <sys/param.h>
> #include <sys/systm.h>
> #include <sys/kernel.h>
> -#include <sys/malloc.h>
> -#include <sys/random.h>
> #include <sys/selinfo.h>
> -#include <sys/sysctl.h>
> -
> -#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
> -#include <machine/cpufunc.h>
> -#include <machine/cputypes.h>
> -#include <machine/md_var.h>
> -#include <machine/specialreg.h>
> -#endif
> 
> +#include <dev/random/random_adaptors.h>
> #include <dev/random/randomdev.h>
> -#include <dev/random/randomdev_soft.h>
> -
> -#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
> -#ifdef PADLOCK_RNG
> -extern struct random_systat random_nehemiah;
> -#endif
> -#ifdef RDRAND_RNG
> -extern struct random_systat random_ivy;
> -#endif
> -#endif
> 
> void
> -random_ident_hardware(struct random_systat **systat)
> +random_ident_hardware(struct random_adaptor **adaptor)
> {
> +     struct random_adaptor *tmp;
> +     int enable;
> 
> -     /* Set default to software */
> -     *systat = &random_yarrow;
> +     /* Set default to software (yarrow) */
> +     *adaptor = random_adaptor_get("yarrow");
> 
>       /* Then go looking for hardware */
> -#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
> -#ifdef PADLOCK_RNG
> -     if (via_feature_rng & VIA_HAS_RNG) {
> -             int enable;
> -
> -             enable = 1;
> -             TUNABLE_INT_FETCH("hw.nehemiah_rng_enable", &enable);
> -             if (enable)
> -                     *systat = &random_nehemiah;
> -     }
> -#endif
> -#ifdef RDRAND_RNG
> -     if (cpu_feature2 & CPUID2_RDRAND) {
> -             int enable;
> -
> -             enable = 1;
> -             TUNABLE_INT_FETCH("hw.ivy_rng_enable", &enable);
> -             if (enable)
> -                     *systat = &random_ivy;
> -     }
> -#endif
> -#endif
> +     enable = 1;
> +     TUNABLE_INT_FETCH("hw.nehemiah_rng_enable", &enable);
> +     if (enable && (tmp = random_adaptor_get("nehemiah")))
> +             *adaptor = tmp;
> +
> +     enable = 1;
> +     TUNABLE_INT_FETCH("hw.ivy_rng_enable", &enable);
> +     if (enable && (tmp = random_adaptor_get("rdrand")))
> +             *adaptor = tmp;
> }
> 
> Modified: head/sys/dev/random/randomdev.c
> ==============================================================================
> --- head/sys/dev/random/randomdev.c   Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/dev/random/randomdev.c   Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -70,12 +70,15 @@ static struct cdevsw random_cdevsw = {
>       .d_name = "random",
> };
> 
> -struct random_systat *random_systat;
> +static struct random_adaptor *random_adaptor;
> +static eventhandler_tag attach_tag;
> +static int random_inited;
> +
> 
> /* For use with make_dev(9)/destroy_dev(9). */
> static struct cdev *random_dev;
> 
> -/* Used to fake out unused random calls in random_systat */
> +/* Used to fake out unused random calls in random_adaptor */
> void
> random_null_func(void)
> {
> @@ -88,8 +91,8 @@ random_close(struct cdev *dev __unused, 
> {
>       if ((flags & FWRITE) && (priv_check(td, PRIV_RANDOM_RESEED) == 0)
>           && (securelevel_gt(td->td_ucred, 0) == 0)) {
> -             (*random_systat->reseed)();
> -             random_systat->seeded = 1;
> +             (*random_adaptor->reseed)();
> +             random_adaptor->seeded = 1;
>               arc4rand(NULL, 0, 1);   /* Reseed arc4random as well. */
>       }
> 
> @@ -104,8 +107,8 @@ random_read(struct cdev *dev __unused, s
>       void *random_buf;
> 
>       /* Blocking logic */
> -     if (!random_systat->seeded)
> -             error = (*random_systat->block)(flag);
> +     if (!random_adaptor->seeded)
> +             error = (*random_adaptor->block)(flag);
> 
>       /* The actual read */
>       if (!error) {
> @@ -114,7 +117,7 @@ random_read(struct cdev *dev __unused, s
> 
>               while (uio->uio_resid > 0 && !error) {
>                       c = MIN(uio->uio_resid, PAGE_SIZE);
> -                     c = (*random_systat->read)(random_buf, c);
> +                     c = (*random_adaptor->read)(random_buf, c);
>                       error = uiomove(random_buf, c, uio);
>               }
> 
> @@ -139,7 +142,7 @@ random_write(struct cdev *dev __unused, 
>               error = uiomove(random_buf, c, uio);
>               if (error)
>                       break;
> -             (*random_systat->write)(random_buf, c);
> +             (*random_adaptor->write)(random_buf, c);
>       }
> 
>       free(random_buf, M_TEMP);
> @@ -172,14 +175,37 @@ random_poll(struct cdev *dev __unused, i
>       int revents = 0;
> 
>       if (events & (POLLIN | POLLRDNORM)) {
> -             if (random_systat->seeded)
> +             if (random_adaptor->seeded)
>                       revents = events & (POLLIN | POLLRDNORM);
>               else
> -                     revents = (*random_systat->poll) (events,td);
> +                     revents = (*random_adaptor->poll) (events,td);
>       }
>       return (revents);
> }
> 
> +static void
> +random_initialize(void *p, struct random_adaptor *s)
> +{
> +     if (random_inited) {
> +             printf("random: <%s> already initialized\n",
> +                 random_adaptor->ident);
> +             return;
> +     }
> +
> +     random_adaptor = s;
> +
> +     (s->init)();
> +
> +     printf("random: <%s> initialized\n", s->ident);
> +
> +     random_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &random_cdevsw,
> +         RANDOM_MINOR, NULL, UID_ROOT, GID_WHEEL, 0666, "random");
> +     make_dev_alias(random_dev, "urandom");  /* XXX Deprecated */
> +
> +     /* mark random(4) as initialized, to avoid being called again */
> +     random_inited = 1;
> +}
> +
> /* ARGSUSED */
> static int
> random_modevent(module_t mod __unused, int type, void *data __unused)
> @@ -188,23 +214,29 @@ random_modevent(module_t mod __unused, i
> 
>       switch (type) {
>       case MOD_LOAD:
> -             random_ident_hardware(&random_systat);
> -             (*random_systat->init)();
> +             random_ident_hardware(&random_adaptor);
> 
> -             if (bootverbose)
> -                     printf("random: <entropy source, %s>\n",
> -                         random_systat->ident);
> -
> -             random_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &random_cdevsw,
> -                 RANDOM_MINOR, NULL, UID_ROOT, GID_WHEEL, 0666, "random");
> -             make_dev_alias(random_dev, "urandom");  /* XXX Deprecated */
> +             if (random_adaptor == NULL) {
> +                     printf(
> +       "random: No random adaptor attached, postponing initialization\n");
> +                     attach_tag = 
> EVENTHANDLER_REGISTER(random_adaptor_attach,
> +                         random_initialize, NULL, EVENTHANDLER_PRI_ANY);
> +             } else {
> +                     random_initialize(NULL, random_adaptor);
> +             }
> 
>               break;
> 
>       case MOD_UNLOAD:
> -             (*random_systat->deinit)();
> -
> -             destroy_dev(random_dev);
> +             if (random_adaptor != NULL) {
> +                     (*random_adaptor->deinit)();
> +                     destroy_dev(random_dev);
> +             }
> +             /* Unregister the event handler */
> +             if (attach_tag != NULL) {
> +                     EVENTHANDLER_DEREGISTER(random_adaptor_attach,
> +                         attach_tag);
> +             }
> 
>               break;
> 
> 
> Modified: head/sys/dev/random/randomdev.h
> ==============================================================================
> --- head/sys/dev/random/randomdev.h   Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/dev/random/randomdev.h   Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -38,7 +38,7 @@ typedef void random_write_func_t(void *,
> typedef int random_poll_func_t(int, struct thread *);
> typedef void random_reseed_func_t(void);
> 
> -struct random_systat {
> +struct random_adaptor {
>       struct selinfo          rsel;
>       const char              *ident;
>       int                     seeded;
> @@ -51,7 +51,5 @@ struct random_systat {
>       random_reseed_func_t    *reseed;
> };
> 
> -extern struct random_systat *random_systat;
> -
> -extern void random_ident_hardware(struct random_systat **);
> +extern void random_ident_hardware(struct random_adaptor **);
> extern void random_null_func(void);
> 
> Modified: head/sys/dev/random/randomdev_soft.c
> ==============================================================================
> --- head/sys/dev/random/randomdev_soft.c      Mon Jul 29 19:50:30 2013        
> (r253778)
> +++ head/sys/dev/random/randomdev_soft.c      Mon Jul 29 20:26:27 2013        
> (r253779)
> @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
> #include <sys/kthread.h>
> #include <sys/lock.h>
> #include <sys/malloc.h>
> +#include <sys/module.h>
> #include <sys/mutex.h>
> #include <sys/poll.h>
> #include <sys/proc.h>
> @@ -50,6 +51,7 @@ __FBSDID("$FreeBSD$");
> #include <machine/bus.h>
> #include <machine/cpu.h>
> 
> +#include <dev/random/random_adaptors.h>
> #include <dev/random/randomdev.h>
> #include <dev/random/randomdev_soft.h>
> 
> @@ -63,7 +65,7 @@ static int random_yarrow_poll(int event,
> static int random_yarrow_block(int flag);
> static void random_yarrow_flush_reseed(void);
> 
> -struct random_systat random_yarrow = {
> +struct random_adaptor random_yarrow = {
>       .ident = "Software, Yarrow",
>       .init = random_yarrow_init,
>       .deinit = random_yarrow_deinit,
> @@ -103,7 +105,7 @@ static int random_kthread_control = 0;
> static struct proc *random_kthread_proc;
> 
> /* List for the dynamic sysctls */
> -struct sysctl_ctx_list random_clist;
> +static struct sysctl_ctx_list random_clist;
> 
> /* ARGSUSED */
> static int
> @@ -120,25 +122,20 @@ random_yarrow_init(void)
> {
>       int error, i;
>       struct harvest *np;
> -     struct sysctl_oid *random_o, *random_sys_o, *random_sys_harvest_o;
> +     struct sysctl_oid *random_sys_o, *random_sys_harvest_o;
>       enum esource e;
> 
> -     random_o = SYSCTL_ADD_NODE(&random_clist,
> -         SYSCTL_STATIC_CHILDREN(_kern),
> -         OID_AUTO, "random", CTLFLAG_RW, 0,
> -         "Software Random Number Generator");
> -
> -     random_yarrow_init_alg(&random_clist, random_o);
> +     random_yarrow_init_alg(&random_clist);
> 
>       random_sys_o = SYSCTL_ADD_NODE(&random_clist,
> -         SYSCTL_CHILDREN(random_o),
> +         SYSCTL_STATIC_CHILDREN(_kern_random),
>           OID_AUTO, "sys", CTLFLAG_RW, 0,
>           "Entropy Device Parameters");
> 
>       SYSCTL_ADD_PROC(&random_clist,
>           SYSCTL_CHILDREN(random_sys_o),
>           OID_AUTO, "seeded", CTLTYPE_INT | CTLFLAG_RW,
> -         &random_systat->seeded, 1, random_check_boolean, "I",
> +         &random_yarrow.seeded, 1, random_check_boolean, "I",
>           "Seeded State");
> 
>       random_sys_harvest_o = SYSCTL_ADD_NODE(&random_clist,
> @@ -362,10 +359,10 @@ random_yarrow_write(void *buf, int count
> void
> random_yarrow_unblock(void)
> {
> -     if (!random_systat->seeded) {
> -             random_systat->seeded = 1;
> -             selwakeuppri(&random_systat->rsel, PUSER);
> -             wakeup(random_systat);
> +     if (!random_yarrow.seeded) {
> +             random_yarrow.seeded = 1;
> +             selwakeuppri(&random_yarrow.rsel, PUSER);
> +             wakeup(&random_yarrow);
>       }
>       (void)atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_NONE,
>           ARC4_ENTR_HAVE);
> @@ -377,10 +374,10 @@ random_yarrow_poll(int events, struct th
> 
> *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to