Fixing getrandom()
Fixing getrandom()
Posted Sep 30, 2019 8:26 UTC (Mon) by anton (subscriber, #25547)In reply to: Fixing getrandom() by ncm
Parent article: Fixing getrandom()
I do not know if a microphone or radio are good random sources, but a camera is. The resolution of camera sensors is high enough that the randomness of the photons coming in is reflected in the raw sensor output (and it is a lot for a (not too) bright picture). However, that means that the sensor must be on and receive significant light on booting, and you need a way to get the raw data (transformation into JPEG usually tries to get rid of the noise that we want for the RNG).
Posted Sep 30, 2019 11:59 UTC (Mon)
by excors (subscriber, #95769)
[Link] (1 responses)
> you need a way to get the raw data (transformation into JPEG usually tries to get rid of the noise that we want for the RNG)
It's not just the JPEG compression - the Android camera API is happy to give you uncompressed YUV but that still wouldn't be raw enough. You'd want the (typically) 10-bit Bayer data directly from the sensor, before the ISP has tried to make it look pretty (doing noise reduction, adjusting levels in a way that might saturate the noise out of existence, smoothing the image, etc). And you probably want to manually configure the sensor to maximise noise (long exposure, high gain, disable binning, etc). Android provides enough control to let applications request that, but I don't know how many of the camera drivers implement it fully, so it's probably not a very portable approach.
Posted Sep 30, 2019 12:49 UTC (Mon)
by anton (subscriber, #25547)
[Link]
Posted Oct 3, 2019 10:40 UTC (Thu)
by NRArnot (subscriber, #3033)
[Link]
Personally I'd go with a boot parameter "paranoia = n" (maybe the current and maximum value is 11, with a nod to Spinal Tap). 10 would allow use of the random number generator on the CPU chip if there is one, and thereby solve all the problems other than the possibility that (insert conspiracy theory here).
Fixing getrandom()
Thermal noise is relatively small compared to photon noise if the sensor receives significant photons, but may be enough for initializing the RNG. And of course you don't want to be have so much brightness and so much exposure that the sensor saturates, but you can recognize anything approaching saturation, and then use shorter exposure time, if too many pixels are saturated. Combining high gain with long exposure will give more thermal noise in darkness, but produce saturation if there is light.
Fixing getrandom()
Fixing getrandom()