Esempio n. 1
0
 protected override void HashCore(byte[] array, int ibStart, int cbSize)
 {
     if (!hashing)
     {
         hashing = true;
     }
     md5.TransformBlock(array, ibStart, cbSize, array, ibStart);
     sha.TransformBlock(array, ibStart, cbSize, array, ibStart);
 }
        protected override byte[] HashFinal()
        {
            if (!hashing)
            {
                hash.TransformBlock(innerPad, 0, innerPad.Length, innerPad, 0);
                hashing = true;
            }
            // Finalize the original hash
            hash.TransformFinalBlock(new byte[0], 0, 0);

            byte[] firstResult = hash.Hash;

            hash.Initialize();
            hash.TransformBlock(outerPad, 0, outerPad.Length, outerPad, 0);
            hash.TransformFinalBlock(firstResult, 0, firstResult.Length);

            Initialize();

            return(hash.Hash);
        }
        public byte[] Final()
        {
            block.Final();
            byte[] intermediate = algo.Hash;

            byte[] buf = KeySetup(key, 0x5C);
            algo.Initialize();
            algo.TransformBlock(buf, 0, buf.Length, buf, 0);
            algo.TransformFinalBlock(intermediate, 0, intermediate.Length);
            hash = algo.Hash;
            algo.Clear();
            // zeroize sensitive data
            Array.Clear(buf, 0, buf.Length);
            Array.Clear(intermediate, 0, intermediate.Length);
            return(hash);
        }