public void HMACSH512CngPropertyTest() { using (HMACSHA512 bclHmac = new HMACSHA512()) using (HMACSHA512Cng cngHmac = new HMACSHA512Cng()) { Assert.AreEqual(typeof(SHA512Cng).AssemblyQualifiedName, cngHmac.HashName); Assert.AreEqual(bclHmac.HashSize, cngHmac.HashSize); Assert.AreEqual(bclHmac.InputBlockSize, cngHmac.InputBlockSize); Assert.AreEqual(bclHmac.OutputBlockSize, cngHmac.OutputBlockSize); Assert.AreEqual(CngProvider2.MicrosoftPrimitiveAlgorithmProvider, cngHmac.Provider); } }
public void HMACSHA512CngTest() { using (RNGCng rng = new RNGCng()) { byte[] key = new byte[128]; rng.GetBytes(key); using (HMACSHA512 bclHmac = new HMACSHA512(key)) using (HMACSHA512Cng cngHmac = new HMACSHA512Cng(key)) { for (int i = 0; i < 10; ++i) { byte[] data = new byte[2048]; rng.GetBytes(data); byte[] bcl = bclHmac.ComputeHash(data); byte[] cng = cngHmac.ComputeHash(data); Assert.IsTrue(Util.CompareBytes(bcl, cng)); } } } }