Collecting entropy from device_attach() times.

Pawel Jakub Dawidek pjd at FreeBSD.org
Tue Sep 18 21:14:11 UTC 2012


Hi.

I experimented a bit with collecting entropy from the time it takes for
device_attach() to run (in CPU cycles). It seems that those times have
enough variation that we can use it for entropy harvesting. It happens
even before root is mounted, so pretty early.

On the machine I'm testing it, which has minimal kernel plus NIC driver
I see 75 device_attach() calls. I'm being very careful and advertising
to yarrow that each call has only 4 bits of entropy (most of the time
there is much more). This gives 300 bits of entropy on this machine
before we even start init.

For real hardware like sound card it takes between 34647162 and 35548675
cycles to run device_attach(), so the difference here is 901513. If all
the times are more or less equally probable in this range we have more
than 19 bits of entropy from this one call, but I reduced if to four
bits only, because there are devices that are much faster to attach.
We could make the code more complex by assuming 0.01% of the time
varies, which should still be safe and will allow to collect more
entropy from those long calls.

The patch is here:

	http://people.freebsd.org/~pjd/patches/harvest_device_attach.patch

Comments?

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://tupytaj.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-security/attachments/20120918/64884bfb/attachment.pgp


More information about the freebsd-security mailing list