entropychecker

package module
v0.0.0-...-cdd1e35 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Entropy Checker

Build Status Build Status Go Report Card Coverage Status Scrutinizer Issues GoDoc

Entropy Checker is a golang package for Linux that will ensure you have sufficient entropy available before doing important cryptographic operations.

It only works on Linux. Mac, BSD and Windows lack the ability to check entropy levels.

usage example:

package main

import (
	"github.com/cryptoballot/entropychecker"
	"log"
)

func main() {
	// Wait for sufficient entropy to be available
	err := entropychecker.WaitForEntropy()
	if err != nil {
		log.Fatal(err)
	}

	// Now it's safe to do important cryptographic stuff
}

There are two configuration variables provided:


// By default we wait for 128 bits, but if you need more or less you can change it here
entropychecker.MinimumEntropy = 128

// By default we will wait 10 seconds before timing out, but we can set it differently.
// Set it to 0 to never time out
entropychecker.Timeout = 10 * time.Second

Documentation

Overview

Package entropychecker is a handy golang library for Linux that will ensure you have sufficient entropy available before doing important cryptographic operations.

It only works on Linux. Mac, BSD and Windows lack the ability to check entropy levels.

usage example:

package main

import (
	"github.com/cryptoballot/entropychecker"
	"log"
)

func main() {
	// Wait for sufficient entropy to be available
	err := entropychecker.WaitForEntropy()
	if err != nil {
		log.Fatal(err)
	}

	// Now it's safe to do important cryptographic stuff
}

There are two configuration variables provided:

// By default we wait for 128 bits, but if you need more or less you can change it here
entropychecker.MinimumEntropy = 128

// By default we will wait 10 seconds before timing out, but we can set it differently.
// Set it to 0 to never time out
entropychecker.Timeout = 10 * time.Second

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("entropychecker: Timed out waiting for sufficient entropy")

ErrTimeout is for when the system waits too long and gives up

View Source
var ErrUnsupportedOS = errors.New("entropychecker: Unsupported OS. Only Linux is supported")

ErrUnsupportedOS is for for an invalid OS that does not provide entropy estimates

View Source
var MinimumEntropy = 128

MinimumEntropy is the minimum amount of entropy that will be considered safe. Set this to what you consider to be a 'safe' minimum entropy amount (in bits)

View Source
var Timeout = time.Second * 10

Timeout sets the maximum amount of time to wait for entropy. Waiting for entropy will time out after this amount of time. Setting to zero will never time out.

Functions

func GetEntropy

func GetEntropy() (int, error)

GetEntropy gets the entropy estimate. Returns the estimated entropy in bits

func WaitForEntropy

func WaitForEntropy() error

WaitForEntropy blocks until sufficient entropy is available

Types

This section is empty.

Jump to

Keyboard shortcuts

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