Example #1
0
        private unsafe void _HashData(byte[] partIn, int ibStart, int cbSize)
        {
            int byteCount      = cbSize;
            int srcOffsetBytes = ibStart;
            int dstOffsetBytes = (int)((long)this._count & (long)sbyte.MaxValue);

            this._count = this._count + (ulong)byteCount;
            fixed(ulong *state = this._stateSHA384)
            fixed(byte *block           = this._buffer)
            fixed(ulong *expandedBuffer = this._W)
            {
                if (dstOffsetBytes > 0 && dstOffsetBytes + byteCount >= 128)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, dstOffsetBytes, 128 - dstOffsetBytes);
                    srcOffsetBytes += 128 - dstOffsetBytes;
                    byteCount      -= 128 - dstOffsetBytes;
                    SHA384Managed.SHATransform(expandedBuffer, state, block);
                    dstOffsetBytes = 0;
                }
                while (byteCount >= 128)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, 0, 128);
                    srcOffsetBytes += 128;
                    byteCount      -= 128;
                    SHA384Managed.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 & 127UL);

            this._count += (ulong)((long)i);
            fixed(ulong *stateSHA = this._stateSHA384)
            {
                fixed(byte *buffer = this._buffer)
                {
                    fixed(ulong *w = this._W)
                    {
                        if (num2 > 0 && num2 + i >= 128)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, num2, 128 - num2);
                            num += 128 - num2;
                            i   -= 128 - num2;
                            SHA384Managed.SHATransform(w, stateSHA, buffer);
                            num2 = 0;
                        }
                        while (i >= 128)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, 0, 128);
                            num += 128;
                            i   -= 128;
                            SHA384Managed.SHATransform(w, stateSHA, buffer);
                        }
                        if (i > 0)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, num2, i);
                        }
                    }
                }
            }
        }