public void CheckAlphaNTest0() { // Sanity check var keyPair = TestUtils.GeneratePrivate(Exp, setup.KeySize); var pubKey = (RsaKeyParameters)keyPair.Public; var Modulus = pubKey.Modulus; // Assert CheckAlphaN returns True Assert.IsTrue(PermutationTest.CheckAlphaN(alpha, Modulus)); }
public void _CheckAlphaN(BigInteger Exp, int keySize, int alpha, out double alphaTime) { var keyPair = TestUtils.GeneratePrivate(Exp, keySize); var pubKey = (RsaKeyParameters)keyPair.Public; var Modulus = pubKey.Modulus; sw.Restart(); //Check AlphaN start var output = PermutationTest.CheckAlphaN(alpha, Modulus); sw.Stop(); //Check AlphaN ends Assert.IsTrue(output); alphaTime = sw.Elapsed.TotalMilliseconds; }
public void CheckAlphaNTest3() { // CheckAlphaN outputs fail if N is even (2 * alpha). BigInteger p, q; // p is Two (Even) p = BigInteger.Two; // Generate q to fill N q = BigInteger.ValueOf(alpha); var Modulus = p.Multiply(q); // Assert CheckAlphaN returns False Assert.IsFalse(PermutationTest.CheckAlphaN(alpha, Modulus)); }
public void CheckAlphaNTest2() { // CheckAlphaN outputs fail if N is even. // Sanity check var keyPair = TestUtils.GeneratePrivate(Exp, setup.KeySize); var privKey = (RsaPrivateCrtKeyParameters)keyPair.Private; var pubKey = (RsaKeyParameters)keyPair.Public; var Modulus = pubKey.Modulus; var ModBytes = Modulus.ToByteArrayUnsigned(); // Make the LSB a zero to make it even. ModBytes[ModBytes.Length - 1] &= (byte)0xfe; Modulus = new BigInteger(1, ModBytes); // Assert CheckAlphaN returns False Assert.IsFalse(PermutationTest.CheckAlphaN(alpha, Modulus)); }
public void CheckAlphaNTest1() { // CheckAlphaN outputs fail if N has some prime number p < alpha as a factor. BigInteger p, q; // prime that comes immediately before alpha var primeN = Utils.Primes(alpha - 1).Last(); p = BigInteger.ValueOf(primeN); int pbitlength = p.BitLength; int qbitlength = (setup.KeySize - pbitlength); // Generate q q = TestUtils.GenQ(p, qbitlength, setup.KeySize, Exp); var Modulus = p.Multiply(q); // Assert CheckAlphaN returns False Assert.IsFalse(PermutationTest.CheckAlphaN(alpha, Modulus)); }