summary refs log tree commit diff
path: root/crypto/src/math/BigInteger.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-10-18 14:22:53 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-10-18 14:22:53 +0700
commit088e423b20074f3483b8c255ffcb724e3fdf4d6a (patch)
tree2cfc4ec51ced9f0807524b904803c2f4f7ffcbfd /crypto/src/math/BigInteger.cs
parenthttp://www.bouncycastle.org/jira/browse/BMA-113 (diff)
downloadBouncyCastle.NET-ed25519-088e423b20074f3483b8c255ffcb724e3fdf4d6a.tar.xz
http://www.bouncycastle.org/jira/browse/BMA-82
- use SecureRandom to generate "arbitrary" values
Diffstat (limited to 'crypto/src/math/BigInteger.cs')
-rw-r--r--crypto/src/math/BigInteger.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs
index f302f077e..f31e2d5f2 100644
--- a/crypto/src/math/BigInteger.cs
+++ b/crypto/src/math/BigInteger.cs
@@ -4,6 +4,7 @@ using System.Diagnostics;
 using System.Globalization;
 using System.Text;
 
+using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Math
@@ -179,7 +180,7 @@ namespace Org.BouncyCastle.Math
         private const int chunk2 = 1, chunk8 = 1, chunk10 = 19, chunk16 = 16;
         private static readonly BigInteger radix2, radix2E, radix8, radix8E, radix10, radix10E, radix16, radix16E;
 
-        private static readonly Random RandomSource = new Random();
+        private static readonly SecureRandom RandomSource = new SecureRandom();
 
         /*
          * These are the threshold bit-lengths (of an exponent) where we increase the window size.
@@ -246,6 +247,11 @@ namespace Org.BouncyCastle.Math
             return (nBits + BitsPerByte - 1) / BitsPerByte;
         }
 
+        internal static BigInteger Arbitrary(int sizeInBits)
+        {
+            return new BigInteger(sizeInBits, RandomSource);
+        }
+
         private BigInteger(
             int		signum,
             int[]	mag,