Infnoise inspired serial TRNG implementation for NetHSM
- Download the firmware from the release page
- Download the dfu-upload.sh script and place it in the same folder
- Connect a device that you want to flash via USB
- Run
./dfu-upload.sh firmware
-
Install DFU-Programmer:
- Linux:
$ apt-get install -y dfu-programmer
- MacOS:
$ brew install dfu-programmer
- Linux:
Go to src directory:
$ cd src
$ make docker-build
- Get the Atmega16u2 into DFU-mode
$ make dfu
- Get the Atmega16u2 into DFU-mode
$ make
On some systems the make dfu
command needs sudo
privilege.
New (previously unflashed) Atmega16u2 always boot directly in DFU mode.
On development boards:
- permanently close JP1
- connect board over USB
- shortly close JP2
Linux:
$ stty 115200 raw cs8 -cstopb -parenb -F /dev/[serial device]
$ xxd /dev/[serial device]
MacOS:
$ (stty 115200 raw cs8 -cstopb -parenb; xxd) </dev/[serial device]
Serial device would be something like ttyS0
or cu.usbserial-XXX
.
With the ent
tool the entropy can be estimated:
Linux:
$ dd if=/dev/[serial device] iflag=fullblock bs=1K count=100 | ent
MacOS:
(stty 115200 raw cs8 -cstopb -parenb; dd iflag=fullblock bs=1K count=100) </dev/[serial device] | ent
This should result in output similar to:
100+0 records in
100+0 records out
102400 bytes transferred in 9.188599 secs (11144 bytes/sec)
Entropy = 7.998317 bits per byte.
Optimum compression would reduce the size
of this 102400 byte file by 0 percent.
Chi square distribution for 102400 samples is 238.57, and randomly
would exceed this value 76.25 percent of the times.
Arithmetic mean value of data bytes is 127.5779 (127.5 = random).
Monte Carlo value for Pi is 3.140982070 (error 0.02 percent).
Serial correlation coefficient is -0.000348 (totally uncorrelated = 0.0).
The schematic can be found insed the hardware repository.