Ejemplo n.º 1
0
        public void Test_03_Performance()
        {
            byte[]   Data = new byte[80 * 1024 * 1024];
            SHAKE128 H    = new SHAKE128(1024);

            H.ComputeVariable(Data);
        }
Ejemplo n.º 2
0
        public void Test_02_1600_bits()
        {
            SHAKE128 H = new SHAKE128(4096);
            int      i = 0;

            H.NewState += (sender, e) =>
            {
                string Expected = States1600Bits[i++].Replace(" ", string.Empty);
                string Actual   = Hashes.BinaryToString(H.GetState()).ToUpper();
                Assert.AreEqual(Expected, Actual);
            };

            byte[] Input = new byte[200];
            int    j;

            for (j = 0; j < 200; j++)
            {
                Input[j] = 0xa3;
            }

            byte[] Digest = H.ComputeVariable(Input);
            string s      = Hashes.BinaryToString(Digest);

            Assert.AreEqual("131ab8d2b594946b9c81333f9bb6e0ce75c3b93104fa3469d3917457385da037cf232ef7164a6d1eb448c8908186ad852d3f85a5cf28da1ab6fe3438171978467f1c05d58c7ef38c284c41f6c2221a76f12ab1c04082660250802294fb87180213fdef5b0ecb7df50ca1f8555be14d32e10f6edcde892c09424b29f597afc270c904556bfcb47a7d40778d390923642b3cbd0579e60908d5a000c1d08b98ef933f806445bf87f8b009ba9e94f7266122ed7ac24e5e266c42a82fa1bbefb7b8db0066e16a85e0493f07df4809aec084a593748ac3dde5a6d7aae1e8b6e5352b2d71efbb47d4caeed5e6d633805d2d323e6fd81b4684b93a2677d45e7421c2c6aea259b855a698fd7d13477a1fe53e5a4a6197dbec5ce95f505b520bcd9570c4a8265a7e01f89c0c002c59bfec6cd4a5c109258953ee5ee70cd577ee217af21fa70178f0946c9bf6ca8751793479f6b537737e40b6ed28511d8a2d7e73eb75f8daac912ff906e0ab955b083bac45a8e5e9b744c8506f37e9b4e749a184b30f43eb188d855f1b70d71ff3e50c537ac1b0f8974f0fe1a6ad295ba42f6aec74d123a7abedde6e2c0711cab36be5acb1a5a11a4b1db08ba6982efccd716929a7741cfc63aa4435e0b69a9063e880795c3dc5ef3272e11c497a91acf699fefee206227a44c9fb359fd56ac0a9a75a743cff6862f17d7259ab075216c0699511643b6439", s);
            Assert.AreEqual(States1600Bits.Length, i);
        }
Ejemplo n.º 3
0
        public void Test_08_SHAKE128_3()
        {
            SHAKE128 H = new SHAKE128(256);

            byte[] Digest = H.ComputeVariable(new MemoryStream(Encoding.ASCII.GetBytes("The quick brown fox jumps over the lazy dof")));
            string s      = Hashes.BinaryToString(Digest);

            Assert.AreEqual("853f4538be0db9621a6cea659a06c1107b1f83f02b13d18297bd39d7411cf10c", s);
        }
Ejemplo n.º 4
0
        public void Test_07_SHAKE128_2()
        {
            SHAKE128 H = new SHAKE128(256);

            byte[] Digest = H.ComputeVariable(new MemoryStream(Encoding.ASCII.GetBytes("The quick brown fox jumps over the lazy dog")));
            string s      = Hashes.BinaryToString(Digest);

            Assert.AreEqual("f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e", s);
        }
Ejemplo n.º 5
0
        public void Test_05_SHAKE128()
        {
            SHAKE128 H = new SHAKE128(256);

            byte[] Digest = H.ComputeVariable(new MemoryStream(new byte[0]));
            string s      = Hashes.BinaryToString(Digest);

            Assert.AreEqual("7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26", s);
        }
Ejemplo n.º 6
0
        public void Test_01_0_bits()
        {
            SHAKE128 H = new SHAKE128(4096);
            int      i = 0;

            H.NewState += (sender, e) =>
            {
                string Expected = States0Bits[i++].Replace(" ", string.Empty);
                string Actual   = Hashes.BinaryToString(H.GetState()).ToUpper();
                Assert.AreEqual(Expected, Actual);
            };

            byte[] Digest = H.ComputeVariable(new byte[0]);
            string s      = Hashes.BinaryToString(Digest);

            Assert.AreEqual("7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef263cb1eea988004b93103cfb0aeefd2a686e01fa4a58e8a3639ca8a1e3f9ae57e235b8cc873c23dc62b8d260169afa2f75ab916a58d974918835d25e6a435085b2badfd6dfaac359a5efbb7bcc4b59d538df9a04302e10c8bc1cbf1a0b3a5120ea17cda7cfad765f5623474d368ccca8af0007cd9f5e4c849f167a580b14aabdefaee7eef47cb0fca9767be1fda69419dfb927e9df07348b196691abaeb580b32def58538b8d23f87732ea63b02b4fa0f4873360e2841928cd60dd4cee8cc0d4c922a96188d032675c8ac850933c7aff1533b94c834adbb69c6115bad4692d8619f90b0cdf8a7b9c264029ac185b70b83f2801f2f4b3f70c593ea3aeeb613a7f1b1de33fd75081f592305f2e4526edc09631b10958f464d889f31ba010250fda7f1368ec2967fc84ef2ae9aff268e0b1700affc6820b523a3d917135f2dff2ee06bfe72b3124721d4a26c04e53a75e30e73a7a9c4a95d91c55d495e9f51dd0b5e9d83c6d5e8ce803aa62b8d654db53d09b8dcff273cdfeb573fad8bcd45578bec2e770d01efde86e721a3f7c6cce275dabe6e2143f1af18da7efddc4c7b70b5e345db93cc936bea323491ccb38a388f546a9ff00dd4e1300b9b2153d2041d205b443e41b45a653f2a5c4492c1add544512dda2529833462b71a41a45be97290b6f", s);
            Assert.AreEqual(States0Bits.Length, i);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            TestCases tc = new TestCases();

            for (int i = 0; i < 2; i++)
            {
                byte[] result = SHA3_224.ComputeHash(tc.SHA3_224[i].Input);
                if (CompareArrays(result, tc.SHA3_224[i].Result))
                {
                    Console.WriteLine("SHA3_224 TEST " + i + "           -PASS-");
                }
                else
                {
                    Console.WriteLine("SHA3_224 TEST " + i + "           *FAIL!*");
                }
                result = SHA3_256.ComputeHash(tc.SHA3_256[i].Input);
                if (CompareArrays(result, tc.SHA3_256[i].Result))
                {
                    Console.WriteLine("SHA3_256 TEST " + i + "           -PASS-");
                }
                else
                {
                    Console.WriteLine("SHA3_256 TEST " + i + "           *FAIL!*");
                }
                result = SHA3_384.ComputeHash(tc.SHA3_384[i].Input);
                if (CompareArrays(result, tc.SHA3_384[i].Result))
                {
                    Console.WriteLine("SHA3_384 TEST " + i + "           -PASS-");
                }
                else
                {
                    Console.WriteLine("SHA3_384 TEST " + i + "           *FAIL!*");
                }
                result = SHA3_512.ComputeHash(tc.SHA3_512[i].Input);
                if (CompareArrays(result, tc.SHA3_512[i].Result))
                {
                    Console.WriteLine("SHA3_512 TEST " + i + "           -PASS-");
                }
                else
                {
                    Console.WriteLine("SHA3_512 TEST " + i + "           *FAIL!*");
                }
                result = SHAKE128.ComputeHash(tc.SHAKE128[i].Input, tc.SHAKE128[i].Result.Length);
                if (CompareArrays(result, tc.SHAKE128[i].Result))
                {
                    Console.WriteLine("SHAKE128 TEST " + i + "           -PASS-");
                }
                else
                {
                    Console.WriteLine("SHAKE128 TEST " + i + "           *FAIL!*");
                }
                result = SHAKE256.ComputeHash(tc.SHAKE256[i].Input, tc.SHAKE256[i].Result.Length);
                if (CompareArrays(result, tc.SHAKE256[i].Result))
                {
                    Console.WriteLine("SHAKE256 TEST " + i + "           -PASS-");
                }
                else
                {
                    Console.WriteLine("SHAKE256 TEST " + i + "           *FAIL!*");
                }
            }

            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();
        }