コード例 #1
0
ファイル: HMACTests.cs プロジェクト: will14smith/Crypto
        public void GivesCorrectOutputWithBlankKeyAndInputSHA256()
        {
            var hmac = new HMAC(new SHA256Digest(), new byte[0]);

            var output = hmac.Digest();

            AssertOutput(32, "b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad", output);
        }
コード例 #2
0
ファイル: HMACTests.cs プロジェクト: will14smith/Crypto
        public void GivesCorrectOutputWithBlankKeyAndInputSHA1()
        {
            var hmac = new HMAC(new SHA1Digest(), new byte[0]);

            var output = hmac.Digest();

            AssertOutput(20, "fbdb1d1b18aa6c08324b7d64b71fb76370690e1d", output);
        }
コード例 #3
0
ファイル: HMACTests.cs プロジェクト: will14smith/Crypto
        public void GivesCorrectOutputSHA256LongKey()
        {
            var key = Encoding.UTF8.GetBytes("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World");
            var hmac = new HMAC(new SHA256Digest(), key);

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

            hmac.Update(message, 0, message.Length);
            var output = hmac.Digest();

            AssertOutput(32, "bcac0ae627a2be9e3ae2eb2ff367a54b15706af61f33aea3d6a0faa2ba68feef", output);
        }
コード例 #4
0
ファイル: HMACTests.cs プロジェクト: will14smith/Crypto
        public void GivesCorrectOutputSHA256()
        {
            var key = Encoding.UTF8.GetBytes("key");
            var hmac = new HMAC(new SHA256Digest(), key);

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

            hmac.Update(message, 0, message.Length);
            var output = hmac.Digest();

            AssertOutput(32, "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8", output);
        }
コード例 #5
0
ファイル: HMACTests.cs プロジェクト: will14smith/Crypto
        public void GivesCorrectOutputSHA1()
        {
            var key = Encoding.UTF8.GetBytes("key");
            var hmac = new HMAC(new SHA1Digest(), key);

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

            hmac.Update(message, 0, message.Length);
            var output = hmac.Digest();

            AssertOutput(20, "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9", output);
        }
コード例 #6
0
ファイル: PRF.cs プロジェクト: will14smith/Crypto
        private IEnumerable<byte> P_hash(byte[] secret, byte[] seed)
        {
            var hmac = new HMAC(digest, secret);

            var a = seed;

            while (true)
            {
                hmac.Reset();
                hmac.Update(a, 0, a.Length);
                a = hmac.Digest();

                hmac.Reset();
                hmac.Update(a, 0, a.Length);
                hmac.Update(seed, 0, seed.Length);

                var b = hmac.Digest();
                foreach (var x in b)
                {
                    yield return x;
                }
            }
        }