A .NET Standard library implementing the Fortuna PRNG as devised by Bruce Schneier and Niels Ferguson in 2003. Also implemented are reseeding improvements suggested by Dodis et al in "How to Eat Your Entropy and Have it Too".
How does this differ from existing Fortuna implementations?
- Reseeding is pseudo-random rather than cyclical (Dodis et al).
- Reading an entropy pool empties multiple pools (Dodis et al).
- Support for TwoFish, Serpent and BlowFish in addition to AES (default).
- Remote entropy sources (weather, radioactive decay, atmospheric noise) included apart from local.
For more info on the above as well as performance, testing and limitations, please see the wiki.
// seed stream
var stream = new FileStream("seed", FileMode.OpenOrCreate);
// instantiate and read seed
using (var prng = RNGVenturaServiceProviderFactory.Create(stream))
{
// get a random number from 0 to 10
int randomNumber = prng.Next(0, 10);
} // new seed will be written to stream.
Prints a random number from 1 to 10, reads/writes seed to seed.bin
dotnet Ventura.Cli.dll rn -s seed.bin -i 1 -x 10
Prints 100 random numbers from 1 to 10, reads/writes seed to seed.bin
dotnet Ventura.Cli.dll rns -s seed.bin -i 1 -x 10 -n 100
Docker
docker pull nickpatsaris/ventura.cli
docker run -ti 147dbbbb24da rn -s seed.bin -i 1 -x 10
docker run -ti 147dbbbb24da rns -s seed.bin -i 1 -x 10 -n 100
Bouncy Castle for ciphers. John Walker for ENT testing and HotBits radioactive decay entropy