Git Product home page Git Product logo

nitrokey-trng-rs232-firmware's Introduction

Nitrokey TRNG RS232 Firmware

Infnoise inspired serial TRNG implementation for NetHSM

Production

  • 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

Getting Started

  • Install Docker

  • Install DFU-Programmer:

    • Linux: $ apt-get install -y dfu-programmer
    • MacOS: $ brew install dfu-programmer

Build & Upload

Go to src directory:

$ cd src

Build:

$ make docker-build

Flash:

  1. Get the Atmega16u2 into DFU-mode
  2. $ make dfu

Build & Flash:

  1. Get the Atmega16u2 into DFU-mode
  2. $ make

On some systems the make dfu command needs sudo privilege.

DFU mode:

New (previously unflashed) Atmega16u2 always boot directly in DFU mode.

On development boards:

  1. permanently close JP1
  2. connect board over USB
  3. shortly close JP2

Monitor random data output

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.

Check entropy

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).

Hardware

The schematic can be found insed the hardware repository.

Pinout top view

NK TRNG-Serial Hardware

License

nitrokey-trng-rs232-firmware's People

Contributors

ansiwen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

zerovectorti

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.