コード例 #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._stateSHA256)
            fixed(byte *block          = this._buffer)
            fixed(uint *expandedBuffer = this._W)
            {
                if (dstOffsetBytes > 0 && dstOffsetBytes + byteCount >= 64)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, dstOffsetBytes, 64 - dstOffsetBytes);
                    srcOffsetBytes += 64 - dstOffsetBytes;
                    byteCount      -= 64 - dstOffsetBytes;
                    SHA256Managed.SHATransform(expandedBuffer, state, block);
                    dstOffsetBytes = 0;
                }
                while (byteCount >= 64)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, 0, 64);
                    srcOffsetBytes += 64;
                    byteCount      -= 64;
                    SHA256Managed.SHATransform(expandedBuffer, state, block);
                }
                if (byteCount > 0)
                {
                    Buffer.InternalBlockCopy((Array)partIn, srcOffsetBytes, (Array)this._buffer, dstOffsetBytes, byteCount);
                }
            }
        }
コード例 #2
0
        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._stateSHA256)
            {
                fixed(byte *buffer = this._buffer)
                {
                    fixed(uint *w = this._W)
                    {
                        if (num2 > 0 && num2 + i >= 64)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, num2, 64 - num2);
                            num += 64 - num2;
                            i   -= 64 - num2;
                            SHA256Managed.SHATransform(w, stateSHA, buffer);
                            num2 = 0;
                        }
                        while (i >= 64)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, 0, 64);
                            num += 64;
                            i   -= 64;
                            SHA256Managed.SHATransform(w, stateSHA, buffer);
                        }
                        if (i > 0)
                        {
                            Buffer.InternalBlockCopy(partIn, num, this._buffer, num2, i);
                        }
                    }
                }
            }
        }