[go: up one dir, main page]

|
|
Log in / Subscribe / Register

Entropy with NeuG

By Nathan Willis
June 10, 2015

LinuxCon Japan

At LinuxCon Japan 2015, Yutaka Niibe presented [PDF] his work on NeuG, a true random-number generator (TRNG) built entirely with free software and which can run on a variety of cheap hardware devices. There are several competing free-software TRNG options on the market these days; NeuG may not generate the fastest stream of random numbers, but it is notable for its flexible hardware support and its simplicity.

Niibe began the session with a brief autobiographical sketch. He has been a long-time GnuPG developer, with much of his work focusing on libgcrypt. Several years ago, he began working on a GnuPG smartcard implementation called Gnuk. The Gnuk project involved designing and building a secure hardware token that he dubbed the FST-01. Along the way, he said, he became convinced that users were in need of a hardware TRNG.

[Yutaka Niibe]

The issue, of course, is that cryptography requires good keys and generating good keys require random numbers. Interest in the subject is on the increase, he said, with projects like the Free Software Foundation's (FSF's) Email Self Defense and the Electronic Frontier Foundation's (EFF's) HTTPS Everywhere but, he reminded the audience, GnuPG is a fundamental part of free-software distribution, too, providing signatures for releases, commits, and packages.

Given the importance of the topic, hardware TRNGs are vital because users have to trust the hardware in order to trust their encryption keys. There may be backdoors in algorithms, he noted, but there may also be backdoors in hardware—as has been alleged about Intel's RDRAND instruction or in cryptographic chips. So he decided to buck the recent trend of building more powerful embedded devices, and set out to develop a TRNG that uses a cheap, general-purpose microcontroller rather than any specialty hardware.

NeuG is the result. The primary focus has been on implementing NeuG as an alternate firmware for the FST-01, he said, but it will run on several other devices. At the moment, there are five, all of which use the STM32F103 microcontroller found on the FST-01. The microcontroller features an ARM Cortex-M3 core running at 72MHz and has full-speed USB 2.0 connectivity. The various boards include between 20 and 64KiB of RAM and between 64 and 512KiB of flash ROM.

The cheapest option is the ST-Link debugger board that ships with ST's STM8S-DISCOVERY kit; it can be had online for less than ten dollars. The FST-01 remains the reference design, though. It includes 20KiB of RAM, 128KiB of ROM, a 12MHz crystal, a status LED, and some additional flash memory. The schematics and circuit-board designs are free as well.

When connected to a Linux PC, the FST-01 appears as /dev/ttyACM0 (or whatever /dev/ttyACM device is available) and also presents a small USB mass-storage device holding a copy of the GPLv3 license and a README file for using the software. The random-number generation works by sampling the microcontroller's two built-in analog-to-digital converters (ADCs). One ADC samples the microcontroller's reference voltage pin and built-in temperature sensor, while the other is tied to two of the microcontroller's analog input pins (both of which are pulled up to the power supply pin). These four signal sources are sampled in various combinations, passed through four rounds of CRC32, then passed through a SHA-256 conditioning function.

The output, Niibe said, is about 256 bits of entropy from every 280 bits sampled. The FST-01 produces around 80KB of entropy per second in this fashion. The NIST SP 800-90B standard defines the conditioning requirements needed to remove sampling bias, he said, and it defines three health checks that one can use to test the quality of the output. The NeuG software includes a Python program to test the device's output, he said, "but if you don't trust me, you can test it with external tools, too." He recommended TestU01 and PractRand, though he cautioned that they can require extremely large data sets for proper analysis.

Normally, he continued, the device is used with the kernel's rng-tools; the NeuG software bundle includes a udev rule and systemd service to feed output into the kernel's entropy pool. But it can be sampled directly, too, with raw samples, CRC32-filtered bits, and fully SHA-256–conditioned output all available. Altogether, the NeuG library is quite compact: the version that ships on the FST-01 is just 1,500 lines of code, including the USB stack, the USB communications device class (CDC) and mass-storage drivers, and a small thread library called Chopstx.

Regarding the performance of the TRNG design, Niibe admitted that many electrical engineers prefer to talk about other, more esoteric entropy sources like avalanche diodes, photon decay, and radio waves. They sound better, he said, but such exotic sources are not usually needed in practice. People also ask him whether NeuG offers any advantage over haveged, to which he replies that haveged may be good enough for many people on its own, but that it is always better to have multiple, independent entropy sources.

An audience member asked how much entropy a system needs. Niibe replied that some people go overboard, but in his opinion it is best to think of entropy like spice. "Don't drink your soy sauce," he said to a collective chuckle from the crowd, "just use a little wasabi if you want to enjoy your sushi."

Others in attendance asked about the use of the microcontroller at the core of the project. Could the code be ported to other microcontrollers, perhaps? And is there any protection against hardware trojans in the microcontroller itself? Niibe replied that the code is quite portable, and could probably be ported to a variety of other microcontrollers if someone is interested.

As for the possibility of hardware trojans, he said that the risk of compromised hardware was the reason he chose a modest, general-purpose part, adding "although now that I've given this talk, I guess the bad guys will start attacking it." But the STM32F103 has been around for eight years or so, he said, so if users are really paranoid, they should just go buy one now (or even try to find an old one) before the spies get to them. He is also occasionally asked why the NeuG uses a TTY with no encryption to deliver its data, he said. His response is that he could implement USB-channel encryption, but he does not think it makes sense to encrypt your USB bus. If the NSA is snooping your internal USB traffic, he said, "I think you're already finished."

Niibe ended the session with a few "further reading" recommendations for those interested in random-number generation. In summary, he said that free software is about controlling one's own computing. Where encryption is concerned, we need something at the center to serve as the anchor point. No one can control the random number sequence, he said, so he would like to see more people use hardware TRNGs, whether they buy one of his or another.

The most direct comparison to NeuG might be Moonbase Otago's OneRNG, which we looked at in January. Both are open hardware in addition to running free software. The OneRNG uses an avalanche diode as its entropy source and its bit rate is estimated at 350Kbps. So users have some decisions to make if they are interested in choosing one or the other—the NeuG may not produce as much entropy, but it may produce enough for daily usage. On the other hand, the OneRNG is a recent Kickstarter product: although shipments have begun, there is only one source for the hardware, as opposed to the five different boards supported by NeuG. Regardless of how those factors weigh out, however, it is good to have multiple options—and options that take substantially different approaches to the problem of random-number generation.

[The author would like to thank the Linux Foundation for travel assistance to attend LCJ 2015.]

Index entries for this article
SecurityRandom number generation
ConferenceLinuxCon Japan/2015


to post comments

Entropy with NeuG

Posted Jun 11, 2015 17:57 UTC (Thu) by rav (guest, #89256) [Link]

The article states that FST-01 produces "80KB of entropy per second", and OneRNG "350Kbps", which is supposedly more than the NeuG.

Do you mean 80 Kb (kilobits) per second rather than 80 KB (kilobytes) per second?

Maybe irrelevant

Posted Jun 11, 2015 18:31 UTC (Thu) by inganman (guest, #8234) [Link]

NeuG might be interesting from an engeneering point of view, but I consider it irrelvant.

I completely agree with D. J. Bernstein (http://blog.cr.yp.to/20140205-entropy.html). Current generators expand a 256-bit seed into billions of gigabytes of cyptographically secure pseudo random numbers. All that is needed is a good 256-bit seed value which is not a problem for a server or desktop system. On the other hand, embedded devices (without mouse, keyboard, hard disk timing etc) could benefit from a hardware entropy source, but the NeuG seems to be to expensive to be put in such types of devices.

Entropy with NeuG

Posted Jun 12, 2015 4:48 UTC (Fri) by josh (subscriber, #17465) [Link] (3 responses)

It's not at all obvious how this device is supposed to be more trustworthy than any other hardware random number generator. Unless you manufacture it yourself, or disassemble it and scrutinize it, how is this any more trustworthy than other, more widely available sources of hardware randomness?

Entropy with NeuG

Posted Jun 12, 2015 17:43 UTC (Fri) by felixfix (subscriber, #242) [Link] (2 responses)

Because it's an innocuous little chip, so boring and tedious that it is very doubtful any government has wasted their time getting a hardware backdoor built in.

Entropy with NeuG

Posted Jun 12, 2015 17:56 UTC (Fri) by josh (subscriber, #17465) [Link] (1 responses)

Security by obscurity? No thanks.

Entropy with NeuG

Posted Jun 13, 2015 10:40 UTC (Sat) by cladisch (✭ supporter ✭, #50193) [Link]

"Security by obscurity" would imply that there is some part of the algorithm or implementation that must not be known to the adversary.

However, this RNG does not rely on any such secret; everybody knows that this device uses the STM32F103's ADC.
And it is very unlikely that anybody could have predicted the choice of this microcontroller, because the same features are available in many similar chips from other vendors.

Entropy with NeuG

Posted Jun 15, 2015 5:46 UTC (Mon) by apollock (guest, #14629) [Link] (1 responses)

I just wish the Entropy Key was still in production... </wistful>

Entropy with NeuG

Posted Jun 16, 2015 10:49 UTC (Tue) by nix (subscriber, #2304) [Link]

Or at least, given that it seems to have died forever, that its schematics and firmware had been opened up so someone else could restart production.


Copyright © 2015, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds