Hasard project
Hasard is a pseudo-random number generator (PRNG) library. It includes multiple engines (algorithms): Park-Miller, Mersenne Twister, Linux device (/dev/urandom or /dev/random), ... It has simple API but with strong code, eg. PRNG seed can be generated using strong entropy (hardware random number generator like /dev/random on Linux).
The library is written in C and a Python binding is available. The library is distributed under BSD license.
''The word "hasard" is the french name of "randomness" or "chance".''
Features
- Simple functions to get integer, float or boolean with the best distribution
- Support many engines: Mersenne Twister, ISAAC, Arcfour, ... (full list)
- No need to feed the initial seed with poor entropy (eg. srand(time(0))
- Functions to control the seed: jumpahead, get/set seed, get/set state and reseed
- Informations about the PRNG: min/max period, does it support reseed, seed or state?
- BSD license for easy integration in other libraries and programs
- Quality tests: test entropy, compute PRNG period, unit tests
- Attack tests: programs to find collisions, break a LCG
- Tools: programs to create images to "view" the random, plain text file format used by most test programs
Download
Stable version:
- hasard-1.0.tar.bz2
- MD5: f78fb31cb122e13c1305acd0f15f6a63
- SHA-1: 7b90995df182abce0cbe94eadb865aba3837ab66
Download development version using Mercurial:
hg clone http://bitbucket.org/haypo/hasard/
You can also browse the source code.
News
- 2009-08-22: Hasard 1.0
- 2009-07-23: Hasard 0.9.7
- 2009-07-09: Hasard 0.9.6
- 2009-07-07: Hasard 0.9.5
- 2009-06-13: Hasard 0.9
- 2009-05-12: Hasard 0.8
Read also the ChangeLog.
Usage example
Compile it with "gcc example.c -o example -lhasard".
You don't have to initialize the random generator seed like the common srand(time(NULL)): this task is done by hasard_new().
Documentation
- README
- Hasard engine list (engine_list.rst)
- Hasard API (hasard_api.rst)
- Engine API (engine_api.rst)
Tests
- Test entropy: python/file_info.py
- Use ENT program: python/ent.py
- Benchmark: benchmark.c
- Manual visual check: python/gnuplot.py, python/draw_pil.py
Hardware entropy generators
Hardware:
- Sound: audio entropy daemon
- Video: video entropy daemon
- Lava Lamp! lavarnd.org
- True random numbers from Wi-Fi background noise
Daemons:
- EGD: Entropy Gathering Daemon
- PRNGD: Pseudo Random Number Generator Daemon
- aed: an "additional entropy" daemon for Linux
Other:
- Solaris /dev/random device (not maintained since 2002)
- Hurd /dev/random device
- rng-tools (part of gkernel project): inject entropy from hardware generator to /dev/random, but test also the entropy quality using FIPS 140-2
Download entropy from websites
- random.org
- HotBits: ''Genuine random numbers, generated by radioactive decay''
- Quantum Random Bit Generator Service
- EntropyPool and Entropy Filter
Test RNG quality
Programs:
- TUT01 by Pierre l'Écuyer and Richard Simard
- DieHarder (2007) by Robert G. Brown
- ENT
- Diehard, Battery of Tests of Randomness (1995) by George Marsaglia, dedicated to RNG using 32 bits unsigned integer
- rngtest from the rng-tools package FIPS 140-2 (2001-10-10)
Documents:
- NIST 800-90 (2007): Recommendation for Random Number Generation Using Deterministic Random Bit Generators
- Be careful with Dual_EC_DRBG: read The Strange Story of Dual_EC_DRBG by Bruce Schneier
- NIST 800-22 (2001): A statistical test suite for random and pseudorandom number generators for cryptographic applications
- Software Generation of Practically Strong Random Numbers (1998, updated in 2000) by Peter Gutmann
- RFC 1750: Randomness Recommendations for Security (1994) by D. Eastlake, S. Crocker and J. Schiller
- Testing random number generators (1992) by Pierre L’Ecuyer
Other:
- Random Number Generation Technical Working Group from the NIST
Similar projects
- OpenSSL includes PRNG
- libgcrypt includes PRNG
- Pseudo-Random Number Generator (PRNG) by Otmar Lendl and Josef Leydold
- Python language includes its own random library written in Python (random.py)
- GNU Scientific Library (GSL)
- Boost Random Number Library
- The Scalable Parallel Random Number Generators Library (SPRNG)
- pLab-package: The pLab-package includes portable high-performance implementations of the linear congruential, quadratic congruential, inversive congruential, and explicit inversive congruential random number generators (LCG, QCG, ICG, and EICG, respectively), which were designed and implemented by Otmar Lendl.
Random links
- The eSTREAM Project: portfolio of promising new stream ciphers
- Computer Random vs. True Random (PHP, Windows and random.org)
- PHP rand(0,1) on Windows < OpenSSL rand() on Debian
- (fr) Comment générer des nombres aléatoires avec un ordinateur (HSC)
- Hasard library on Freshmeat
- (fr) Sortie de la bibliothèque Hasard version 0.2 (may 2008) on linuxfr.org
- (fr) Des Trappes dans les Clés (2003) by Eric Wegrzynowski
- (fr) Développement de la bibliothèque Hasard (june 2008)
- Entropy and Random Numbers (''Henric Jungheim'')
- Random Number Results (''Bob Jenkins'')
- mt_srand and not so random numbers
- (fr) Cryptographie et reverse engineering en environnement Win32 by Kostya Kortchinsky: Weak cryptography because of weak PRNG (even of correct RSA implementation)
- Chapiter 6 by Peter Gutmann (2001)
- Cryptanalysis of the Random Number Generator of the Windows Operating System, Dorrendorf, Leo; Zvi Gutterman, Benny Pinkas
This revision is from 2009-08-22 02:38
