Exemplo n.º 1
0
        public void HMACSH384CngPropertyTest()
        {
            using (HMACSHA384 bclHmac = new HMACSHA384())
                using (HMACSHA384Cng cngHmac = new HMACSHA384Cng())
                {
                    Assert.AreEqual(typeof(SHA384Cng).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);
                }
        }
Exemplo n.º 2
0
        public void HMACSHA384CngTest()
        {
            using (RNGCng rng = new RNGCng())
            {
                byte[] key = new byte[128];
                rng.GetBytes(key);

                using (HMACSHA384 bclHmac = new HMACSHA384(key))
                    using (HMACSHA384Cng cngHmac = new HMACSHA384Cng(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));
                        }
                    }
            }
        }