GaloisInc/RSA — pull request #1 by TomMD (2012-04-03 17:33:37+00:00)
Title: Move to CryptoRandomGen from RandomGen

Move to CryptoRandomGen from RandomGen.

The tests were also updated and complete successfully on my machine.

This is a move to a class of generators intended for instantiation only
by cryptographically secure generators that allow for failure and reseed.
For RSA, failures are in the form of exceptions (of type GenError).

This patch has one semantic change besides the obvious
RandomGen->CryptoRandomGen replacement! The rsaes_oaep_encrypt function was
accepting an integer seed in the range of +/-2^29 (or whatever Int size is on
the host) and translating it to a bytestring in the range of [0..2^29]. Thus,
we were getting only 4 or 8 bytes of entropy (maximum) for a 32 byte long
bytestring (assuming a default of SHA256). It now accepts generators and will
generate random bytestrings of length equal to the size of the digest for the
provided hash algorithm.

I'm not sure what, if any, security implications this has - see RFC 3447 Sec
7.1.1 and see line 247 in RSA.hs (line 248 pre-patch, I think).