Beispiel #1
0
        private unsafe void _HashData(byte[] partIn, int ibStart, int cbSize)
        {
            int byteCount      = cbSize;
            int srcOffsetBytes = ibStart;
            int dstOffsetBytes = (int)(this._count & 63L);

            this._count = this._count + (long)byteCount;
            fixed(uint *state = this._stateSHA1)
            fixed(byte *block          = this._buffer)
            fixed(uint *expandedBuffer = this._expandedBuffer)
            {
                if (dstOffsetBytes > 0 && dstOffsetBytes + byteCount >= 64)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, dstOffsetBytes, 64 - dstOffsetBytes);
                    srcOffsetBytes += 64 - dstOffsetBytes;
                    byteCount      -= 64 - dstOffsetBytes;
                    SHA1Managed.SHATransform(expandedBuffer, state, block);
                    dstOffsetBytes = 0;
                }
                while (byteCount >= 64)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, 0, 64);
                    srcOffsetBytes += 64;
                    byteCount      -= 64;
                    SHA1Managed.SHATransform(expandedBuffer, state, block);
                }
                if (byteCount > 0)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, dstOffsetBytes, byteCount);
                }
            }
        }
        private unsafe void _HashData(byte[] partIn, int ibStart, int cbSize)
        {
            int i    = cbSize;
            int num  = ibStart;
            int num2 = (int)(this._count & 63L);

            this._count += (long)i;
            fixed(uint *stateSHA = this._stateSHA1)
            {
                fixed(byte *buffer = this._buffer)
                {
                    fixed(uint *expandedBuffer = this._expandedBuffer)
                    {
                        if (num2 > 0 && num2 + i >= 64)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, num2, 64 - num2);
                            num += 64 - num2;
                            i   -= 64 - num2;
                            SHA1Managed.SHATransform(expandedBuffer, stateSHA, buffer);
                            num2 = 0;
                        }
                        while (i >= 64)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, 0, 64);
                            num += 64;
                            i   -= 64;
                            SHA1Managed.SHATransform(expandedBuffer, stateSHA, buffer);
                        }
                        if (i > 0)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, num2, i);
                        }
                    }
                }
            }
        }