Crypt-DRBG
==========

== Overview

Crypt-DRBG is a set of fast, cryptographically-secure PRNGs.  It can be used
either as a supplement to the system PRNG (e.g. /dev/random or /dev/urandom) or
where reproducible results are sometimes needed (e.g. in unit tests).
It also provides bias-free selection of bytes or array elements.

The algorithms implemented are the NIST HMAC_DRBG and Hash_DRBG.  Unit tests are
included to ensure conformance with the specification.
The HMAC implementation (`Crypt::DRBG::HMAC`)
is the preferred implementation for speed reasons.
Both algorithms are generally believed to be secure.

== Dependencies

Crypt::DRBG requires only core Perl on Unix systems with a random device.

Digest::SHA is required, so if you're using an older version of Perl where that
isn't included in core, you'll need to install it.

Performance of the Hash DRBG and unit tests will be improved if
Math::BigInt::GMP is available.

Finally, Crypt::URandom will be used if it's available; this is required for
Windows machines when not using Cygwin.

== Installation

To install this module, run the following commands:

	perl Makefile.PL
	make
	make test
	make install

== Basic Usage

[source,perl]
----
use Crypt::DRBG::HMAC;

# Non-deterministic, automatically seeded option.
my $drbg = Crypt::DRBG::HMAC->new(auto => 1);
my $data = $drbg->generate(42);
... # do something with your 42 bytes here

# Deterministic option
my $drbg2 = Crypt::DRBG::HMAC->new(seed => "my very secret seed");
my @randdigits = $drbg->randitems(20, [0..9]);
... # do something with your 20 random digits here
----

== License and Copyright

Copyright (C) 2015 brian m. carlson

This program is distributed under the MIT (X11) License:
http://www.opensource.org/licenses/mit-license.php

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

