My interest in random number generators didn’t just arise from yesterday’s post. I’ve had various circuits breadboarded for months gathering dust, so I thought I’d pull out the most successful one and photograph it. Hardware RNGs seem to be a popular hobby electronics obsession, and there are many designs out there in variable states of â€œworkingâ€ and/or â€œdocumentedâ€. I wanted one that could be powered from the 5V rail of an Arduino, and didn’t use too many expensive components. Rob’s RNG Version 2 circuit and code is the basis, but I replaced the 12V external supply with the MAX232 circuit he used in version 1.
Perhaps the reason that there are so many RNG projects out there in various states of abandonment is that making a good, reliable hardware RNG is hard. Just a few of the things you have to think about are:
- Analogue sources of noise can fade over time; power supplies droop as capacitors age, contacts can corrode, â€¦ How do you deal with this fade? If the output becomes so small, can you rely on those few bits from your Aâ†’D converter to be useful noise?
- Could someone try to attack your RNG so they can influence the results of your secure transactions? How would you detect it? How would you signal to the data user that something is amiss securely, such that an attacker couldn’t fake distress behaviour?
- What if the generator just stops? How do you flag that in a trusted â€œno really i mean it and it’s really me saying this not some attacker honest noâ€ way? There may still be a tiny bit of noise that your circuit picks up; are you sure it’s your kind of noise, or some attacker trying to inject noise into your system? Remember, testing for real noise is exceptionally hard, and you can’t guarantee that a hardware RNG that worked today will work properly tomorrow.
(I’d like to thank Peter Todd for providing most of those issues over a pint and a chat during from a keysigning event. Peter saved me from spending too many hours working on this by hinting that â€” just maybe â€” I didn’t actually know what I was doingâ€¦)
If you want to read more on how to build a proper hardware RNG, the article â€œUnderstanding Intel’s Ivy Bridge Random Number Generatorâ€ and its references make a good (if very technical in places) introduction. I’m nowhere near paranoid enough to experiment further with RNG design, although I do have all the components to build an LM393-based XR232USBâ€¦