public void GetRhos_Data() { // GetRhos is really producing outputs rho that are<N and have GCD(N, rho) = 1 int m2 = 10000; var keyPair = TestUtils.GeneratePrivate(Exp, keySize); var privKey = (RsaPrivateCrtKeyParameters)keyPair.Private; var pubKey = (RsaKeyParameters)keyPair.Public; var Modulus = pubKey.Modulus; // Generate list of rho values PermutationTest.GetRhos(m2, ps, pubKey, keySize, out byte[][] rhoValues); Console.WriteLine(String.Join(",", rhoValues.Select(a => new BigInteger(1, a)))); }
public void GetRhosTest() { // GetRhos is really producing outputs rho that are<N and have GCD(N, rho) = 1 int m2 = 11; var keyPair = TestUtils.GeneratePrivate(Exp, setup.KeySize); var privKey = (RsaPrivateCrtKeyParameters)keyPair.Private; var pubKey = (RsaKeyParameters)keyPair.Public; var Modulus = pubKey.Modulus; // Generate list of rho values PermutationTest.GetRhos(m2, ps, pubKey, setup.KeySize, out byte[][] rhoValues); for (int i = 0; i < rhoValues.Length; i++) { // Convert rho value to a number var num = Utils.OS2IP(rhoValues[i]); // Assert the number is less than N Assert.IsTrue(num.CompareTo(Modulus) < 0); // Assert GCD(rho, N) == 1 Assert.IsTrue(Modulus.Gcd(num).Equals(BigInteger.One)); } }