<p dir="ltr"><br>
On Feb 5, 2016 6:39 PM, "Tyler Hicks" <<a href="mailto:tyhicks@canonical.com">tyhicks@canonical.com</a>> wrote:<br>
><br>
> I took a look at how we can improve entropy on devices such as the<br>
> BeagleBone Black and Raspberry Pi 2. Lucky for us, both of those pieces<br>
> of hardware include a hardware random number generator (hwrng) that can<br>
> be used to feed random data into the kernel's random number entropy pool<br>
> (which is what's behind /dev/random and /dev/urandom).<br>
><br>
> Shortly after booting the devices, I took a look at the bits of entropy<br>
> available on each device.<br>
><br>
> ubuntu@bbb:~$ cat /proc/sys/kernel/random/entropy_avail<br>
> 165<br>
><br>
> ubuntu@rpi2:~$ cat /proc/sys/kernel/random/entropy_avail<br>
> 528<br>
><br>
> Those are the bits of entropy available out of a total poolsize of 4096<br>
> bits. The BBB's number is very low while the RPI2 is only slightly<br>
> better. However, neither of them can generate an RSA-2048 bit GPG key<br>
> at this point due to /dev/random blocking. Keep in mind that this is<br>
> after the device is fully booted, connected to the network, and I've<br>
> ssh'ed in. The entropy levels are surely much lower before the network<br>
> is up.<br>
><br>
> We can improve things by leveraging the hwrng devices. We can see what<br>
> hwrng sources are available by reading<br>
> /sys/class/misc/hw_random/rng_available:<br>
><br>
> ubuntu@bbb:~$ cat /sys/class/misc/hw_random/rng_available<br>
> omap<br>
><br>
> The BBB image loads the omap-rng kernel module during boot. Unfortunately, the<br>
> RPI2 image doesn't load the necessary kernel module for its hwrng. We'll<br>
> load it and then make sure its available:<br>
><br>
> ubuntu@rpi2:~$ sudo modprobe bcm2708-rng<br>
> ubuntu@rpi2:~$ cat /sys/class/misc/hw_random/rng_available<br>
> bcm2708<br>
><br>
> Having a hwrng available doesn't mean that the kernel's random number<br>
> entropy pool is automatically fed. We need to use rngd, from rng-tools,<br>
> to read from /dev/hwrng and write to /dev/random.<br>
><br>
> ubuntu@bbb:~$ cat /proc/sys/kernel/random/entropy_avail<br>
> 180<br>
> ubuntu@bbb:~$ sudo ./rngd<br>
> ubuntu@bbb:~$ cat /proc/sys/kernel/random/entropy_avail<br>
> 3100<br>
><br>
> ubuntu@rpi2:~$ cat /proc/sys/kernel/random/entropy_avail<br>
> 544<br>
> ubuntu@rpi2:~$ sudo ./rngd<br>
> ubuntu@rpi2:~$ cat /proc/sys/kernel/random/entropy_avail<br>
> 3097<br>
><br>
> Now we can easily generate keys without GPG blocking while reading from<br>
> /dev/random. rngd continues to feed random data into the kernel's<br>
> entropy pool while things such as key gen operations deplete the pool.<br>
><br>
> rngd includes fitness tests to ensure that the numbers read from<br>
> /dev/hwrng look random, as defined by FIPS 140-2, before writing them to<br>
> /dev/random.<br>
><br>
> There are some things that need to be done to leverage the hwrng in<br>
> these devices:<br>
><br>
> 1) The RPI2 image needs to ensure that the bcm2708-rng kernel module is<br>
> loaded.<br>
> 2) We need to make rng-tools available. Would it be preferred that<br>
> rng-tools is seeded in core or should it be a snap that gadget<br>
> snaps, for devices that have a hwrng, can declare as a preinstall<br>
> dependency?</p>
<p dir="ltr">I'd recommend a combined approach of (a) seeding the prng well, and (b) strongly recommending (requiring?) that gadget snaps enable the HW rng whenever possible.</p>
<p dir="ltr">> Tyler<br>
><br>
> --<br>
> snappy-devel mailing list<br>
> <a href="mailto:snappy-devel@lists.ubuntu.com">snappy-devel@lists.ubuntu.com</a><br>
> Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/snappy-devel">https://lists.ubuntu.com/mailman/listinfo/snappy-devel</a><br>
><br>
</p>