[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Math.Prime ConfidenceFactor.c
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos Guzm?n ?l. <car...@us...> - 2004-05-09 11:59:25
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Math.Prime In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28920 Modified Files: ConfidenceFactor.cs PrimalityTests.cs Log Message: Sync Mono.Security stuff wit Mono Beta 1 sources Index: ConfidenceFactor.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Math.Prime/ConfidenceFactor.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConfidenceFactor.cs 10 Feb 2004 09:41:23 -0000 1.1 --- ConfidenceFactor.cs 9 May 2004 11:59:12 -0000 1.2 *************** *** 14,18 **** /// A factor of confidence. /// </summary> ! internal enum ConfidenceFactor { /// <summary> /// Only suitable for development use, probability of failure may be greater than 1/2^20. --- 14,23 ---- /// A factor of confidence. /// </summary> ! #if INSIDE_CORLIB ! internal ! #else ! public ! #endif ! enum ConfidenceFactor { /// <summary> /// Only suitable for development use, probability of failure may be greater than 1/2^20. Index: PrimalityTests.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Math.Prime/PrimalityTests.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrimalityTests.cs 10 Feb 2004 09:41:23 -0000 1.1 --- PrimalityTests.cs 9 May 2004 11:59:12 -0000 1.2 *************** *** 9,21 **** using System; - using System.Security.Cryptography; namespace Mono.Math.Prime { ! [CLSCompliant(false)] ! internal delegate bool PrimalityTest (BigInteger bi, ConfidenceFactor confidence); ! [CLSCompliant(false)] ! internal sealed class PrimalityTests { #region SPP Test --- 9,32 ---- using System; namespace Mono.Math.Prime { ! #if INSIDE_CORLIB ! internal ! #else ! public ! #endif ! delegate bool PrimalityTest (BigInteger bi, ConfidenceFactor confidence); ! #if INSIDE_CORLIB ! internal ! #else ! public ! #endif ! sealed class PrimalityTests { ! ! private PrimalityTests () ! { ! } #region SPP Test *************** *** 23,27 **** private static int GetSPPRounds (BigInteger bi, ConfidenceFactor confidence) { ! int bc = bi.bitCount(); int Rounds; --- 34,38 ---- private static int GetSPPRounds (BigInteger bi, ConfidenceFactor confidence) { ! int bc = bi.BitCount(); int Rounds; *************** *** 93,104 **** BigInteger t = p_sub1 >> s; ! int bits = bi.bitCount (); BigInteger a = null; - RandomNumberGenerator rng = RandomNumberGenerator.Create (); BigInteger.ModulusRing mr = new BigInteger.ModulusRing (bi); for (int round = 0; round < Rounds; round++) { while (true) { // generate a < n ! a = BigInteger.genRandom (bits, rng); // make sure "a" is not 0 --- 104,114 ---- BigInteger t = p_sub1 >> s; ! int bits = bi.BitCount (); BigInteger a = null; BigInteger.ModulusRing mr = new BigInteger.ModulusRing (bi); for (int round = 0; round < Rounds; round++) { while (true) { // generate a < n ! a = BigInteger.GenerateRandom (bits); // make sure "a" is not 0 *************** *** 107,111 **** } ! if (a.gcd (bi) != 1) return false; BigInteger b = mr.Pow (a, t); --- 117,121 ---- } ! if (a.GCD (bi) != 1) return false; BigInteger b = mr.Pow (a, t); *************** *** 169,173 **** #endregion - // TODO: Implement the Lucus test // TODO: Implement other new primality tests --- 179,182 ---- |