summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-03-06 08:33:06 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-03-06 08:33:06 +0700
commit048cb1d82a831ab445cc37e64a948f3e0371cd1a (patch)
tree3eff7b5ec0423d5d705ce9ff401b9f88b2788cd7
parentImproved reduction (diff)
downloadBouncyCastle.NET-ed25519-048cb1d82a831ab445cc37e64a948f3e0371cd1a.tar.xz
Avoid redundant subtraction
-rw-r--r--crypto/src/crypto/generators/DHKeyGeneratorHelper.cs86
1 files changed, 43 insertions, 43 deletions
diff --git a/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs b/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs
index 756e8482a..d05c51e80 100644
--- a/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs
+++ b/crypto/src/crypto/generators/DHKeyGeneratorHelper.cs
@@ -7,47 +7,47 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Crypto.Generators
 {
-	class DHKeyGeneratorHelper
-	{
-		internal static readonly DHKeyGeneratorHelper Instance = new DHKeyGeneratorHelper();
-
-		private DHKeyGeneratorHelper()
-		{
-		}
-
-		internal BigInteger CalculatePrivate(
-			DHParameters	dhParams,
-			SecureRandom	random)
-		{
-			int limit = dhParams.L;
-
-			if (limit != 0)
-			{
-				return new BigInteger(limit, random).SetBit(limit - 1);
-			}
-
-			BigInteger min = BigInteger.Two;
-			int m = dhParams.M;
-			if (m != 0)
-			{
-				min = BigInteger.One.ShiftLeft(m - 1);
-			}
-
-			BigInteger max = dhParams.P.Subtract(BigInteger.Two);
-			BigInteger q = dhParams.Q;
-			if (q != null)
-			{
-				max = q.Subtract(BigInteger.Two);
-			}
-
-			return BigIntegers.CreateRandomInRange(min, max, random);
-		}
-
-		internal BigInteger CalculatePublic(
-			DHParameters	dhParams,
-			BigInteger		x)
-		{
-			return dhParams.G.ModPow(x, dhParams.P);
-		}
-	}
+    class DHKeyGeneratorHelper
+    {
+        internal static readonly DHKeyGeneratorHelper Instance = new DHKeyGeneratorHelper();
+
+        private DHKeyGeneratorHelper()
+        {
+        }
+
+        internal BigInteger CalculatePrivate(
+            DHParameters	dhParams,
+            SecureRandom	random)
+        {
+            int limit = dhParams.L;
+
+            if (limit != 0)
+            {
+                return new BigInteger(limit, random).SetBit(limit - 1);
+            }
+
+            BigInteger min = BigInteger.Two;
+            int m = dhParams.M;
+            if (m != 0)
+            {
+                min = BigInteger.One.ShiftLeft(m - 1);
+            }
+
+            BigInteger q = dhParams.Q;
+            if (q == null)
+            {
+                q = dhParams.P;
+            }
+            BigInteger max = q.Subtract(BigInteger.Two);
+
+            return BigIntegers.CreateRandomInRange(min, max, random);
+        }
+
+        internal BigInteger CalculatePublic(
+            DHParameters	dhParams,
+            BigInteger		x)
+        {
+            return dhParams.G.ModPow(x, dhParams.P);
+        }
+    }
 }