Beispiel #1
0
        static void Main(string[] args)
        {
            ConsoleUtils.SizeConsole(80, 60);
            ConsoleUtils.CenterConsole();
            Console.Title = "Rainbow Test Suite";

            // header
            Console.WriteLine("**********************************************");
            Console.WriteLine("* Rainbow Sign in C# (RNBW Sharp)            *");
            Console.WriteLine("*                                            *");
            Console.WriteLine("* Release:   v1.0                            *");
            Console.WriteLine("* Date:      July 04, 2015                   *");
            Console.WriteLine("* Contact:   [email protected]               *");
            Console.WriteLine("**********************************************");
            Console.WriteLine("");
            Console.WriteLine("COMPILE as Any CPU | Release mode, RUN the .exe for real timings");
            Console.WriteLine("");

            if (Debugger.IsAttached)
            {
                Console.WriteLine("You are running in Debug mode! Compiled times will be much faster..");
                Console.WriteLine("");
            }

            Console.WriteLine(CON_TITLE + "Run Validation Tests? Press 'Y' to run, any other key to skip..");
            ConsoleKeyInfo keyInfo = Console.ReadKey();

            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                // serialization tests
                Console.WriteLine("******TESTING KEY SERIALIZATION******");
                RunTest(new RNBWKeyTest());
                Console.WriteLine("");/**/

                Console.WriteLine("******TESTING PARAMETERS******");
                RunTest(new RNBWParamTest());
                Console.WriteLine("");/**/

                // sign and verify
                Console.WriteLine("******TESTING SIGNING FUNCTIONS******");
                RunTest(new RNBWSignTest());
                Console.WriteLine("");/**/
            }

            Console.WriteLine("");
            Console.WriteLine(CON_TITLE + "Run Sign and Verify Speed Tests? Press 'Y' to run, all other keys close..");
            keyInfo = Console.ReadKey();
            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                Console.WriteLine("");
                Console.WriteLine("******Looping: Sign and Verify Test******");
                Console.WriteLine(string.Format("Testing {0} Full Cycles, throws on all failures..", CYCLE_COUNT));
                Console.WriteLine("");
                try
                {
                    Console.WriteLine("Test cycle using the N33L5 parameter set.");
                    SignSpeed(CYCLE_COUNT);
                    Console.WriteLine("");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Loop test failed! " + ex.Message);
                }
            }

            Console.WriteLine("");
            Console.WriteLine(CON_TITLE + "Run Key Creation Speed Tests? Press 'Y' to run, any other key to skip..");
            keyInfo = Console.ReadKey();
            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                KeyGenSpeed();
                Console.WriteLine("Speed Tests Completed!");
                Console.WriteLine("");
                Console.WriteLine(CON_TITLE + "All tests have completed, press any key to close..");
                Console.ReadKey();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ConsoleUtils.SizeConsole(80, 60);
            ConsoleUtils.CenterConsole();
            Console.Title = "RLWE Sharp Test Suite";

            // header
            Console.WriteLine("**********************************************");
            Console.WriteLine("* Ring-LWE Encrypt in C# (RLWE Sharp)        *");
            Console.WriteLine("*                                            *");
            Console.WriteLine("* Release:   v1.1                            *");
            Console.WriteLine("* Date:      June 8, 2015                    *");
            Console.WriteLine("* Contact:   [email protected]               *");
            Console.WriteLine("**********************************************");
            Console.WriteLine("");
            Console.WriteLine("COMPILE as Any CPU | Release mode, RUN the .exe for real timings");
            Console.WriteLine("");

            if (Debugger.IsAttached)
            {
                Console.WriteLine("You are running in Debug mode! Compiled times will be much faster..");
                Console.WriteLine("");
            }

            Console.WriteLine(CON_TITLE + "Run Validation Tests? Press 'Y' to run, any other key to skip..");
            ConsoleKeyInfo keyInfo = Console.ReadKey();

            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                // encrypt
                Console.WriteLine("******TESTING ENCRYPTION AND DECRYPTION******");
                RunTest(new RLWEEncryptionTest());
                Console.WriteLine("");/**/

                // serialization tests
                Console.WriteLine("******TESTING KEY SERIALIZATION******");
                RunTest(new RLWEKeyTest());
                Console.WriteLine("");/**/

                Console.WriteLine("******TESTING PARAMETERS******");
                RunTest(new RLWEParamTest());
                Console.WriteLine("");/**/

                // cca2 encryption
                Console.WriteLine("******TESTING SIGNING FUNCTIONS******");
                RunTest(new RLWESignTest());
                Console.WriteLine("");/**/
            }

            Console.WriteLine("");
            Console.WriteLine(CON_TITLE + "Run Speed Tests? Press 'Y' to run, any other key to skip..");
            keyInfo = Console.ReadKey();
            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                KeyGenSpeed(CYCLE_COUNT);
                EncryptionSpeed(CYCLE_COUNT);
                DecryptionSpeed(CYCLE_COUNT);
                Console.WriteLine("Speed Tests Completed!");
                Console.WriteLine("");
            }

            Console.WriteLine("");
            Console.WriteLine(CON_TITLE + "Run Looping Full-Cycle Tests? Press 'Y' to run, all other keys close..");
            keyInfo = Console.ReadKey();
            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                Console.WriteLine("");
                Console.WriteLine("******Looping: Key Generation/Encryption/Decryption and Verify Test******");
                Console.WriteLine(string.Format("Testing {0} Full Cycles, throws on all failures..", CYCLE_COUNT));
                Console.WriteLine("");
                try
                {
                    Console.WriteLine("Test cycle using the RLWEN256Q7681 parameter set.");
                    CycleTest(CYCLE_COUNT, RLWEParamSets.RLWEN256Q7681);
                    Console.WriteLine("");
                    Console.WriteLine("Test cycle using the RLWEN512Q12289 parameter set.");
                    CycleTest(CYCLE_COUNT, RLWEParamSets.RLWEN512Q12289);
                    Console.WriteLine("");
                    Console.WriteLine(CON_TITLE + "All tests have completed, press any key to close..");
                    Console.ReadKey();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Loop test failed! " + ex.Message);
                    Console.WriteLine(CON_TITLE + "Press any key to close");
                    Console.ReadKey();
                }
            }
            else
            {
                Environment.Exit(0);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            ConsoleUtils.SizeConsole(80, 60);
            ConsoleUtils.CenterConsole();
            Console.Title = "NTRU Sharp Test Suite";

            // header
            Console.WriteLine("**********************************************");
            Console.WriteLine("* NTRU Encrypt in C# (NTRU Sharp)            *");
            Console.WriteLine("*                                            *");
            Console.WriteLine("* Release:   v1.0                            *");
            Console.WriteLine("* Date:      April 05, 2015                  *");
            Console.WriteLine("* Contact:   [email protected]               *");
            Console.WriteLine("**********************************************");
            Console.WriteLine("");
            Console.WriteLine("COMPILE as Any CPU | Release mode, RUN the .exe for real timings");
            Console.WriteLine("");

            if (Debugger.IsAttached)
            {
                Console.WriteLine("You are running in Debug mode! Compiled times will be much faster..");
                Console.WriteLine("");
            }

            Console.WriteLine(CON_TITLE + "Run Validation Tests? Press 'Y' to run, any other key to skip..");
            ConsoleKeyInfo keyInfo = Console.ReadKey();

            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                // math
                Console.WriteLine("******TESTING BIGINTEGER MATH FUNCTIONS******");
                RunTest(new BigIntEuclideanTest());
                RunTest(new IntEuclideanTest());
                RunTest(new SchönhageStrassenTest());/**/

                // polynomials
                Console.WriteLine("******TESTING POLYNOMINAL FUNCTIONS******");
                RunTest(new BigDecimalPolynomialTest());
                RunTest(new BigIntPolynomialTest());
                RunTest(new DenseTernaryPolynomialTest());
                RunTest(new IntegerPolynomialTest());
                RunTest(new LongPolynomial2Test());
                RunTest(new LongPolynomial5Test());
                RunTest(new ProductFormPolynomialTest());
                RunTest(new SparseTernaryPolynomialTest());
                Console.WriteLine("");/**/

                // utils
                Console.WriteLine("******TESTING ARRAY ENCODERS******");
                RunTest(new ArrayEncoderTest());
                Console.WriteLine("");/**/

                // encrypt
                Console.WriteLine("******TESTING ENCRYPTION ENGINE******");
                RunTest(new BitStringTest());
                RunTest(new NtruKeyPairTest());
                RunTest(new NtruEncryptTest());
                RunTest(new NtruKeyTest());
                RunTest(new NtruParametersTest());
                RunTest(new IndexGeneratorTest());
                RunTest(new PBPRngTest());
                Console.WriteLine("");/**/

                Console.WriteLine("Validation Tests Completed!");
            }

            Console.WriteLine("");
            Console.WriteLine(CON_TITLE + "Run Speed Tests? Press 'Y' to run, any other key to skip..");
            keyInfo = Console.ReadKey();
            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                EncryptionSpeed(CYCLE_COUNT);
                DecryptionSpeed(CYCLE_COUNT);
                KeyGenSpeed(CYCLE_COUNT);
                Console.WriteLine("Speed Tests Completed!");
                Console.WriteLine("");
            }

            Console.WriteLine("");
            Console.WriteLine(CON_TITLE + "Run Looping Full-Cycle Tests? Press 'Y' to run, all other keys close..");
            keyInfo = Console.ReadKey();
            Console.WriteLine("");

            if (keyInfo.Key.Equals(ConsoleKey.Y))
            {
                Console.WriteLine("");
                Console.WriteLine("******Looping: Key Generation/Encryption/Decryption and Verify Test******");
                Console.WriteLine(string.Format("Testing {0} Full Cycles, throws on all failures..", CYCLE_COUNT));
                try
                {
                    CycleTest(CYCLE_COUNT);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("!Loop test failed! " + ex.Message);
                }
                Console.WriteLine("");
                Console.WriteLine(CON_TITLE + "All tests have completed, press any key to close..");
                Console.ReadKey();
            }
            else
            {
                Environment.Exit(0);
            }
        }