예제 #1
0
        public void SHATestMethod()
        {
            var pluginInstance = TestHelpers.GetPluginInstance("SHA");
            var scenario1      = new PluginTestScenario(pluginInstance, new[] { "InputData", ".SHAFunction" }, new[] { "OutputDataStream" });
            var scenario2      = new PluginTestScenario(pluginInstance, new[] { "InputData", ".SHAFunction" }, new[] { "OutputData" });

            object[] output;

            foreach (TestVector vector in testvectors)
            {
                output = scenario1.GetOutputs(new object[] { vector.input.ToStream(), vector.mode });
                Assert.AreEqual(vector.output.ToUpper(), output[0].ToHex(), "Unexpected value in test #" + vector.n + ".");
                output = scenario2.GetOutputs(new object[] { vector.input.ToStream(), vector.mode });
                Assert.AreEqual(vector.output.ToUpper(), output[0].ToHex(), "Unexpected value in test #" + vector.n + ".");
            }

            foreach (TestVector vector in testvectors_loop)
            {
                ICryptoolStream input = vector.input.ToStream();
                for (int i = 0; i < 100000; i++)
                {
                    input = (ICryptoolStream)scenario1.GetOutputs(new object[] { input, vector.mode })[0];
                }
                Assert.AreEqual(vector.output.ToUpper(), input.ToHex(), "Unexpected value in iteration test #" + vector.n + ".");
            }
        }