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 ¶
var ErrTimeout = errors.New("entropychecker: Timed out waiting for sufficient entropy")
ErrTimeout is for when the system waits too long and gives up
var ErrUnsupportedOS = errors.New("entropychecker: Unsupported OS. Only Linux is supported")
ErrUnsupportedOS is for for an invalid OS that does not provide entropy estimates
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)
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 ¶
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.