// iterative hash function
        private byte[] Func()
        {
            var intBlock = GetBigEndianBytes(_block);

            _hmacNotBuiltIn.Initialize();

            _hmacNotBuiltIn.TransformBytes(_salt, 0, _salt.Length);
            _hmacNotBuiltIn.TransformBytes(intBlock, 0, intBlock.Length);

            var temp   = _hmacNotBuiltIn.TransformFinal().GetBytes();
            var result = ArrayUtils.Clone(temp);

            uint i = 2;

            while (i <= _iterations)
            {
                temp = _hmacNotBuiltIn.ComputeBytes(temp).GetBytes();
                var j = 0;
                while (j < _blockSize)
                {
                    result[j] = (byte)(result[j] ^ temp[j]);
                    j++;
                }

                i++;
            }

            _block++;
            return(result);
        }
        } // end function Initialize

        // iterative hash function
        private byte[] Func()
        {
            byte[] INT_block = GetBigEndianBytes(Block);
            hmacNotBuiltIn.Initialize();

            hmacNotBuiltIn.TransformBytes(Salt, 0, Salt.Length);
            hmacNotBuiltIn.TransformBytes(INT_block, 0, INT_block.Length);

            byte[] temp   = hmacNotBuiltIn.TransformFinal().GetBytes();
            byte[] result = temp.DeepCopy();

            UInt32 i = 2;
            Int32  j = 0;

            while (i <= IterationCount)
            {
                temp = hmacNotBuiltIn.ComputeBytes(temp).GetBytes();
                j    = 0;
                while (j < BlockSize)
                {
                    result[j] = (byte)(result[j] ^ temp[j]);
                    j++;
                } // end while

                i++;
            } // end while

            Block++;

            return(result);
        } // end function Func
示例#3
0
        protected override void HashCore(byte[] array, int ibStart, int cbSize)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }
            Debug.Assert(cbSize >= 0);
            Debug.Assert(ibStart >= 0);
            Debug.Assert(ibStart + cbSize <= array.Length);

            _hmacNotBuiltIn.TransformBytes(array, ibStart, cbSize);
        }