2007-07-05 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 5 Jul 2007 15:44:01 +0000 (15:44 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Thu, 5 Jul 2007 15:44:01 +0000 (15:44 -0000)
* PrimalityTests.cs: Last attempt half-failed. For the time being we
need the initial workaround :(

svn path=/trunk/mcs/; revision=81406

mcs/class/Mono.Security/Mono.Math.Prime/ChangeLog
mcs/class/Mono.Security/Mono.Math.Prime/PrimalityTests.cs

index 7ac31c94324e7014c3ccd88a75d8c18522aadcb9..077d52ff5d674b2a721063864061a6f2645e19b4 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-05  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * PrimalityTests.cs: Last attempt half-failed. For the time being we
+       need the initial workaround :(
+
 2007-07-05  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * PrimalityTests.cs: Added Test method that select which algorithm, 
index d5bf8fa849a672dce86399ba41b2333a1608ca59..cd3953e9955aa5c68d01637761d46b69d576e12e 100644 (file)
@@ -95,7 +95,7 @@ namespace Mono.Math.Prime {
                public static bool Test (BigInteger n, ConfidenceFactor confidence)
                {
                        // Rabin-Miller fails with smaller primes (at least with our BigInteger code)
-                       if (n.BitCount () < 100)
+                       if (n.BitCount () < 33)
                                return SmallPrimeSppTest (n, confidence);
                        else
                                return RabinMillerTest (n, confidence);
@@ -137,7 +137,10 @@ namespace Mono.Math.Prime {
                        
                        // Applying optimization from HAC section 4.50 (base == 2)
                        // not a really random base but an interesting (and speedy) one
-                       BigInteger y = mr.Pow (2, r);
+                       BigInteger y = null;
+                       // FIXME - optimization disable for small primes due to bug #81857
+                       if (n.BitCount () > 100)
+                               y = mr.Pow (2, r);
 
                        // still here ? start at round 1 (round 0 was a == 2)
                        for (int round = 0; round < t; round++) {