trng

package module
v0.0.0-...-40578a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2016 License: BSD-2-Clause Imports: 2 Imported by: 0

README

trng

Adapted from www.kerrywong.com/2014/10/19/using-arduino-dues-true-random-number-generator/

trng is a small Go package that provides an io.ReadCloser of random entropy which can be used for cryptographic purposes.

The project is based on the work of Kerry D. Wong, who demonstrated how to extract the random data from the onboard TRNG generator on the SAM3X chip that powers the Arduino Due.

The major change from Wong's work is the raw 32bit output of the TRNG is transmitted to the host and can be directly used as a source of random entropy (Wong's work transmitted the data as string representation of a 32bit signed integer).

documentation

godoc.org/github.com/davecheney/trng

performance

The serial connection between the atmel and the host computer runs at 230,400 baud, which is slightly faster than the SAM3X can produce random data. In benchmarking entropy is produced at a rate of 18kB/sec.

% random-bits | dd of=/dev/null bs=1k count=1k iflag=fullblock
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 58.1198 s, 18.0 kB/s

usage

  1. Load the ardunio-due-trng sketch onto your Ardunio Due. It has to be a SAM3X powered device, older 8bit Atmega Arduinos do not have the hardware trng device.

  2. Either use this package, see the example in godoc, or use the supplied random-bits example program.

    % random-bits | dieharder -a -g 200

security

"Is this really secure? Can I trust you?"

No, this probably isn't secure. No, you shouldn't trust me, it's possible that i've screwed up and the random data isn't actually that random.

Documentation

Overview

Package trng contains a random number source using an Arduino Due connected via USB.

The sketch provided produces random bits, in the form of 32bit words, every microsecond and writes them to the serial interface at 230,400 baud.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(dev string) (io.ReadCloser, error)

Open opens a connection to the Arduino USB device. This device on linux systems is /dev/ttyACM0.

Example
package main

import (
	"crypto/tls"
	"net"

	"github.com/davecheney/trng"
)

func main() {
	// open random source
	rand, _ := trng.Open("/dev/ttyACM0")

	// make a tls Config using that source
	config := tls.Config{
		Rand: rand,
	}

	// dial some TLS site
	conn, _ := net.DialTCP("tcp", "www.google.com:443")

	// use our TLS config, with our random source
	// to do the handshake
	client, _ := tls.Client(conn, *config)

	client.Close()
}
Output:

Types

This section is empty.

Directories

Path Synopsis
example
random-bits
Provides a stream of random bits suitable for piping to other consumers of random data.
Provides a stream of random bits suitable for piping to other consumers of random data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL