Пример #1
0
        public void String_CorrectOutput()
        {
            var digest = new SHA512Digest(SHA512Digest.Mode.SHA384);

            var buffer = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog");

            digest.Update(buffer);

            var result = digest.DigestBuffer();

            AssertSHA384("ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1", result);
        }
Пример #2
0
        public void SimpleString_CorrectOutput()
        {
            var digest = new SHA512Digest(SHA512Digest.Mode.SHA384);

            var buffer = new byte[] { 0x24 };

            digest.Update(buffer);

            var result = digest.DigestBuffer();

            AssertSHA384("b1583f4b2e1bf53fc31e9dfb8e8d945a62955da709f280a9066aa8f31ef688d65e0e9816a5f1f11363b3898820bd1576", result);
        }
Пример #3
0
        public void String_CorrectOutput()
        {
            var digest = new SHA512Digest(SHA512Digest.Mode.SHA512);

            var buffer = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog");

            digest.Update(buffer);

            var result = digest.DigestBuffer();

            AssertSHA512("07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6", result);
        }
Пример #4
0
        public void SimpleString_CorrectOutput()
        {
            var digest = new SHA512Digest(SHA512Digest.Mode.SHA512);

            var buffer = new byte[] { 0x24 };

            digest.Update(buffer);

            var result = digest.DigestBuffer();

            AssertSHA512("840cfc6285878464c36c9aa819d8373729eda14c3e701fd37afec1d5baa2893944c696fc4017a520abfbb1347b62e6b858211d3ea7c7dd26319601fde119c3b4", result);
        }
Пример #5
0
        private void RunNIST(string file)
        {
            var lines = File.ReadAllLines("TestVectors/" + file);

            for (var i = 0; i < lines.Length; i += 4)
            {
                var digest = new SHA512Digest(SHA512Digest.Mode.SHA384);

                var len          = int.Parse(lines[i].Substring(6)) / 8;
                var msg          = HexConverter.FromHex(lines[i + 1].Substring(6));
                var expectedHash = lines[i + 2].Substring(5);

                digest.Update(msg.AsSpan(0, len));
                var hash = digest.DigestBuffer();

                AssertSHA384(expectedHash, hash);
            }
        }
Пример #6
0
        public void Clone_SeperateStateFromOriginal()
        {
            var digest = new SHA512Digest(SHA512Digest.Mode.SHA384);
            var buffer = Encoding.UTF8.GetBytes("The quick brown fox jumps");

            digest.Update(buffer);

            var digest2 = digest.Clone();

            buffer = Encoding.UTF8.GetBytes(" over the lazy dog");
            digest2.Update(buffer);

            var result1 = digest.DigestBuffer();
            var result2 = digest2.DigestBuffer();

            AssertSHA384("17ab2a4374f66611b44d072223392aac47619917f67c563be63506a2445438dac1f08aff2289b6306c63015e17f6d756", result1);
            AssertSHA384("ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1", result2);
        }
Пример #7
0
        public void Clone_SeperateStateFromOriginal()
        {
            var digest = new SHA512Digest(SHA512Digest.Mode.SHA512);
            var buffer = Encoding.UTF8.GetBytes("The quick brown fox jumps");

            digest.Update(buffer);

            var digest2 = digest.Clone();

            buffer = Encoding.UTF8.GetBytes(" over the lazy dog");
            digest2.Update(buffer);

            var result1 = digest.DigestBuffer();
            var result2 = digest2.DigestBuffer();

            AssertSHA512("4b4c254dd0bc5c4a1a70900bc9eea84c852e11ac3d16f87f1d3aaff0478e46ee58c264d4aea58d2ce1b08e84bd7bbbf032e99521f60fcec637abdb243977dd7c", result1);
            AssertSHA512("07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6", result2);
        }