示例#1
0
        private void PadAndSwitchToSqueezingPhase()
        {
            _dataQueue[_bitsInQueue >> 3] |= (byte)(1 << (_bitsInQueue & 7));

            if (++_bitsInQueue == _rate)
            {
                KeccakAbsorb(_dataQueue, 0);
            }
            else
            {
                int full = _bitsInQueue >> 6, partial = _bitsInQueue & 63;
                int off = 0;
                for (int i = 0; i < full; ++i)
                {
                    _state[i] ^= NativeFastShaUtils.LE_To_UInt64(_dataQueue, off);
                    off       += 8;
                }

                if (partial > 0)
                {
                    ulong mask = (1UL << partial) - 1UL;
                    _state[full] ^= NativeFastShaUtils.LE_To_UInt64(_dataQueue, off) & mask;
                }
            }

            _state[(_rate - 1) >> 6] ^= (1UL << 63);

            _bitsInQueue = 0;
            _squeezing   = true;
        }
示例#2
0
        private void KeccakAbsorb(byte[] data, int off)
        {
            int count = _rate >> 6;

            for (int i = 0; i < count; ++i)
            {
                _state[i] ^= NativeFastShaUtils.LE_To_UInt64(data, off);
                off       += 8;
            }

            KeccakPermutation();
        }