public HMACSHA256Cng(byte[] key, CngProvider algorithmProvider) { if (key == null) throw new ArgumentNullException("key"); if (algorithmProvider == null) throw new ArgumentNullException("algorithmProvider"); HashName = "SHA256"; m_hmac = new BCryptHMAC(CngAlgorithm.Sha256, algorithmProvider, HashName, BlockSize, key); }
/// <summary> /// Constructs a HMACSHA512Cng object using the given key, which will calculate the HMAC using the /// given algorithm provider and key. /// </summary> /// <param name="key">key to use when calculating the HMAC</param> /// <param name="algorithmProvider">algorithm provider to calculate the HMAC in</param> /// <exception cref="ArgumentNullException"> /// if <paramref name="key"/> or <paramref name="algorithmProvider"/> are null /// </exception> public HMACSHA512Cng(byte[] key, CngProvider algorithmProvider) { if (key == null) { throw new ArgumentNullException("key"); } if (algorithmProvider == null) { throw new ArgumentNullException("algorithmProvider"); } m_hmac = new BCryptHMAC(CngAlgorithm.Sha512, algorithmProvider, "SHA512", BlockSize, key); HashName = m_hmac.HashName; }
public HMACSHA384Cng(byte[] key, CngProvider algorithmProvider) { if (key == null) { throw new ArgumentNullException("key"); } if (algorithmProvider == null) { throw new ArgumentNullException("algorithmProvider"); } HashName = "SHA384"; m_hmac = new BCryptHMAC(CngAlgorithm.Sha384, algorithmProvider, HashName, BlockSize, key); }