summary refs log tree commit diff
path: root/crypto/src/security/SecureRandom.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/security/SecureRandom.cs')
-rw-r--r--crypto/src/security/SecureRandom.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crypto/src/security/SecureRandom.cs b/crypto/src/security/SecureRandom.cs
index eb5d69618..e8cac56f5 100644
--- a/crypto/src/security/SecureRandom.cs
+++ b/crypto/src/security/SecureRandom.cs
@@ -62,15 +62,16 @@ namespace Org.BouncyCastle.Security
         /// <param name="autoSeed">If true, the instance will be auto-seeded.</param>
         public static SecureRandom GetInstance(string algorithm, bool autoSeed)
         {
-            string upper = Platform.ToUpperInvariant(algorithm);
-            if (Platform.EndsWith(upper, "PRNG"))
+            if (algorithm == null)
+                throw new ArgumentNullException(nameof(algorithm));
+
+            if (algorithm.EndsWith("PRNG", StringComparison.OrdinalIgnoreCase))
             {
-                string digestName = upper.Substring(0, upper.Length - "PRNG".Length);
+                string digestName = algorithm.Substring(0, algorithm.Length - "PRNG".Length);
+
                 DigestRandomGenerator prng = CreatePrng(digestName, autoSeed);
                 if (prng != null)
-                {
                     return new SecureRandom(prng);
-                }
             }
 
             throw new ArgumentException("Unrecognised PRNG algorithm: " + algorithm, "algorithm");