[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Math BigInteger.cs,1.2,1.3
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos G. Á. <car...@us...> - 2004-06-12 09:27:40
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1044 Modified Files: BigInteger.cs Log Message: Updated Mono.Security sources to mono Beta 2 Index: BigInteger.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Math/BigInteger.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BigInteger.cs 9 May 2004 11:58:48 -0000 1.2 --- BigInteger.cs 12 Jun 2004 09:27:31 -0000 1.3 *************** *** 835,843 **** public bool IsProbablePrime () { ! for (int p = 0; p < smallPrimes.Length; p++) { ! if (this == smallPrimes [p]) ! return true; ! if (this % smallPrimes [p] == 0) ! return false; } return PrimalityTests.RabinMillerTest (this, Prime.ConfidenceFactor.Medium); --- 835,849 ---- public bool IsProbablePrime () { ! if (this < smallPrimes [smallPrimes.Length - 1]) { ! for (int p = 0; p < smallPrimes.Length; p++) { ! if (this == smallPrimes [p]) ! return true; ! } ! } ! else { ! for (int p = 0; p < smallPrimes.Length; p++) { ! if (this % smallPrimes [p] == 0) ! return false; ! } } return PrimalityTests.RabinMillerTest (this, Prime.ConfidenceFactor.Medium); *************** *** 1096,1106 **** public BigInteger Pow (uint b, BigInteger exp) { ! if (b != 2) { ! if ((mod.data [0] & 1) == 1) return OddPow (b, exp); ! else return EvenPow (b, exp); } else { ! if ((mod.data [0] & 1) == 1) return OddModTwoPow (exp); ! else return EvenModTwoPow (exp); ! } } --- 1102,1117 ---- public BigInteger Pow (uint b, BigInteger exp) { ! // if (b != 2) { ! if ((mod.data [0] & 1) == 1) ! return OddPow (b, exp); ! else ! return EvenPow (b, exp); ! /* buggy in some cases (like the well tested primes) } else { ! if ((mod.data [0] & 1) == 1) ! return OddModTwoPow (exp); ! else ! return EvenModTwoPow (exp); ! }*/ } *************** *** 1166,1171 **** // We would rather have this estimate overshoot, // so we add one to the divisor ! uint divEstimate = (uint) ((((ulong)cc << 32) | (ulong) u [i -1]) / ! (mod.data [mod.length-1] + 1)); uint t; --- 1177,1190 ---- // We would rather have this estimate overshoot, // so we add one to the divisor ! uint divEstimate; ! if (mod.data [mod.length - 1] < UInt32.MaxValue) { ! divEstimate = (uint) ((((ulong)cc << 32) | (ulong) u [i -1]) / ! (mod.data [mod.length-1] + 1)); ! } ! else { ! // guess but don't divide by 0 ! divEstimate = (uint) ((((ulong)cc << 32) | (ulong) u [i -1]) / ! (mod.data [mod.length-1])); ! } uint t; *************** *** 1309,1312 **** --- 1328,1332 ---- } + /* known to be buggy in some cases private unsafe BigInteger EvenModTwoPow (BigInteger exp) { *************** *** 1441,1445 **** return resultNum; } ! #endregion } --- 1461,1465 ---- return resultNum; } ! */ #endregion } |