2 using System.Security.Cryptography;
4 namespace Hammock.Security.Cryptography
6 public abstract class KeyedHashAlgorithm : HashAlgorithm
8 protected byte[] KeyValue;
10 public virtual byte[] Key
14 return (byte[])this.KeyValue.Clone();
20 throw new CryptographicException("Key can't be changed at this state.");
24 this.KeyValue = (byte[])value.Clone();
33 protected override void Dispose(bool disposing)
36 base.Dispose(disposing);
39 private void ZeroizeKey()
41 if (this.KeyValue != null)
42 Array.Clear(this.KeyValue, 0, this.KeyValue.Length);
45 public static new KeyedHashAlgorithm Create()
47 return Create("System.Security.Cryptography.KeyedHashAlgorithm");
50 public static new KeyedHashAlgorithm Create(string algName)
52 return (KeyedHashAlgorithm)CryptoConfig.CreateFromName(algName);