public static SecureRandom GetInstance(
string algorithm)
{
// TODO Compared to JDK, we don't auto-seed if the client forgets - problem?
// TODO Support all digests more generally, by stripping PRNG and calling DigestUtilities?
string drgName = Platform.ToUpperInvariant(algorithm);
IRandomGenerator drg = null;
if (drgName == "SHA1PRNG")
{
drg = sha1Generator;
}
else if (drgName == "SHA256PRNG")
{
drg = sha256Generator;
}
if (drg != null)
{
return new SecureRandom(drg);
}
throw new ArgumentException("Unrecognised PRNG algorithm: " + algorithm, "algorithm");
}