ATtiny based USB TRNG dongle

Keep a log of a project build here. Be sure to include pictures and as much documentation as possible.

ATtiny based USB TRNG dongle

Postby TinyNoob » February 9th, 2014, 10:53 am

** ATtiny USB TRNG **

I was searching for a simple and good quality hardware RNG. Some of the projects either require expensive parts (geiger tube), are
quite big (lava lamp), or are not random enough. Also most of the projects require some soldering experience, which can be
a problem for newbies. I was not happy with the options I found. Luckily I stumbled upon the Entropy library for AVR's.
I checked the results from authors's web site. I also did a few tests on my own by creating a 1mb sample of random data.
I was pleased with the quality of the random numbers.
You can found the description of the library and the results here: ... AVRentropy
Some examples how to measure the quality of the random numbers can be found here:

The idea for my 1st ATiny project was to create a simple, small USB version of a TRNG with help
of the great Entropy library.
I was interested to keep my 1st project as simple as possible. Therfore
a cheap china ebay USB/Serial converter does the communication job.
The software based V-USB seems to be another good solution, although it
is more labour intensive.
Because the TRNG only sends data to the host, the TinyDebugSerial library is more then enough for this project.
A good description of the com software and the wiring can be found here:
Parts used in the project are:

- ATTiny45 (or other entropy-lib compatible AVR)
- usb/serial converter (ebay,china)
- 3 wires
- DIP socket


The sketch is also a very simple one :

Code: Select all
#include <Entropy.h>
#include <TinyDebugSerial.h>

TinyDebugSerial mySerial = TinyDebugSerial();
uint8_t payload[] = {
uint32_t randomVal;

void setup()

Code: Select all
void loop()
  randomVal = Entropy.random();
  payload[0] = (uint8_t)randomVal;
  payload[1] = (uint8_t)(randomVal >> 8);
  payload[2] = (uint8_t)(randomVal >> 16);
  payload[3] = (uint8_t)(randomVal >> 24);

Once the dongle was soldered and assembled, I quickly created a custom case for it. You can see it here:

The drawbacks. Yes, there is one. Nothing is for free I guess :-) The TRNG dongle is quite slow when it comes to
generation of random numbers. The Entropy.random() call waits for some time till enough entropy is gathered.
It will produce around two 32bit random numbers a second. It is not much but it is enough for my needs.
If you are looking for a quite inexpensive but much more performant solution, check the NeuG dongle based on
a STM32
Posts: 1
Joined: February 9th, 2014, 9:30 am

Return to Project Logs

Who is online

Users browsing this forum: No registered users and 1 guest