entropy: A platform independent entropy source

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

Warnings:

A mostly platform independent method to obtain cryptographically strong entropy (RDRAND, urandom, CryptAPI, and patches welcome) Users looking for cryptographically strong (number-theoretically sound) PRNGs should see the DRBG package too.


[Skip to ReadMe]

Properties

Versions0.1, 0.2, 0.2.1, 0.2.2, 0.2.2.1, 0.2.2.2, 0.2.2.3, 0.2.2.4, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.4.1, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.4, 0.4.1, 0.4.1.1, 0.4.1.2, 0.4.1.3, 0.4.1.4, 0.4.1.5, 0.4.1.5
Change logNone available
Dependenciesbase (>=4.8 && <5), bytestring, ghcjs-dom, jsaddle, unix, Win32 (>=2.5) [details]
LicenseBSD-3-Clause
CopyrightThomas DuBuisson <thomas.dubuisson@gmail.com>
AuthorThomas DuBuisson <thomas.dubuisson@gmail.com>
MaintainerThomas DuBuisson <thomas.dubuisson@gmail.com>
CategoryData, Cryptography
Home pagehttps://github.com/TomMD/entropy
Bug trackerhttps://github.com/TomMD/entropy/issues
Source repositoryhead: git clone https://github.com/TomMD/entropy
UploadedFri Sep 6 20:30:30 UTC 2019 by ThomasDuBuisson

Modules

[Index]

Flags

NameDescriptionDefaultType
halvm

Build for the HaLVM

DisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for entropy-0.4.1.5

[back to package description]

Introduction

This package allows Haskell users to easily acquire entropy for use in critical security applications by calling out to either windows crypto api, unix/linux's /dev/urandom. Hardware RNGs (currently RDRAND, patches welcome) are supported via the hardwareRNG function.

Quick Start

To simply get random bytes use getEntropy:

#!/usr/bin/env cabal
{- cabal:
    build-depends: base, entropy, bytestring
-}
import qualified Data.ByteString as BS
import           System.Entropy

main :: IO ()
main = print . BS.unpack =<< getEntropy 16
-- Example output: [241,191,215,193,225,27,121,244,16,155,252,41,131,38,6,100]

Faster Randoms from Hardware

Most x86 systems include a hardware random number generator. These can be faster but require more trust in the platform:

import qualified Data.ByteString as B
import           System.Entropy

eitherRNG :: Int -> IO B.ByteString
eitherRNG sz = maybe (getEntropy sz) pure =<< getHardwareEntropy sz

main :: IO ()
main = print . B.unpack =<< eitherRNG 32

This package supports Windows, {li,u}nix, QNX, and has preliminary support for HaLVM.

Typically tested on Linux and OSX - testers are as welcome as patches.

Build Status