summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Security/Cryptography/HMACSHA256.cs
blob: e3d62df95a86e0b38b74db6f6a74e458308d6dc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace System.Security.Cryptography {
    [System.Runtime.InteropServices.ComVisible(true)]
    public class HMACSHA256 : HMAC {
        //
        // public constructors
        //

        public HMACSHA256 () : this (Utils.GenerateRandom(64)) {}

        public HMACSHA256 (byte[] key) {
            m_hashName = "SHA256";

#if FEATURE_CRYPTO
            m_hash1 = GetHashAlgorithmWithFipsFallback(() => new SHA256Managed(), () => HashAlgorithm.Create("System.Security.Cryptography.SHA256CryptoServiceProvider"));
            m_hash2 = GetHashAlgorithmWithFipsFallback(() => new SHA256Managed(), () => HashAlgorithm.Create("System.Security.Cryptography.SHA256CryptoServiceProvider"));
#else
            m_hash1 = new SHA256Managed();
            m_hash2 = new SHA256Managed();
#endif // FEATURE_CRYPTO

            HashSizeValue = 256;
            base.InitializeKey(key);
        }
    }
}