コード例 #1
0
ファイル: FipsDsa.cs プロジェクト: NDWX/BouncyCastle.FIPS
 private bool IsProbablePrime(BigInteger x, int iterations)
 {
     /*
      * Primes class for FIPS 186-4 C.3 primality checking
      */
     return(!Primes.HasAnySmallFactors(x) && Primes.IsMRProbablePrime(x, random, iterations));
 }
コード例 #2
0
 protected bool isProbablePrime(BigInteger x)
 {
     /*
      * Primes class for FIPS 186-4 C.3 primality checking
      */
     return(!Primes.HasAnySmallFactors(x) && Primes.IsMRProbablePrime(x, param.Random, iterations));
 }
コード例 #3
0
ファイル: PrimesTest.cs プロジェクト: 894880010/MP
        public void TestHasAnySmallFactors()
        {
            for (int iterations = 0; iterations < ITERATIONS; ++iterations)
            {
                BigInteger prime = RandomPrime();
                Assert.False(Primes.HasAnySmallFactors(prime));

                // NOTE: Loop through ALL small values to be sure no small primes are missing
                for (int smallFactor = 2; smallFactor <= Primes.SmallFactorLimit; ++smallFactor)
                {
                    BigInteger nonPrimeWithSmallFactor = BigInteger.ValueOf(smallFactor).Multiply(prime);
                    Assert.True(Primes.HasAnySmallFactors(nonPrimeWithSmallFactor));
                }
            }
        }