private void ProcessWord(byte[] Input, int InOffset) { m_wordBuffer[m_wordOffset] = IntUtils.BytesToBe64(Input, InOffset); if (++m_wordOffset == 16) { ProcessBlock(); } }
/// <remarks> /// Convert to big endian integers, increment and convert back /// </remarks> private void Rotate(byte[] Counter) { // rotate the counter at 32 or 64 bit intervals if (RotationalAlignment == CounterAlignmentSizes.RAP32) { for (int i = 0; i < Counter.Length; i += 4) { IntUtils.Be32ToBytes(IntUtils.BytesToBe32(Counter, i) + 1, Counter, i); } } else { for (int i = 0; i < Counter.Length; i += 8) { IntUtils.Be64ToBytes(IntUtils.BytesToBe64(Counter, i) + 1, Counter, i); } } }
private void Compress(byte[] Block, int Offset) { _M[0] = IntUtils.BytesToBe64(Block, Offset); _M[1] = IntUtils.BytesToBe64(Block, Offset + 8); _M[2] = IntUtils.BytesToBe64(Block, Offset + 16); _M[3] = IntUtils.BytesToBe64(Block, Offset + 24); _M[4] = IntUtils.BytesToBe64(Block, Offset + 32); _M[5] = IntUtils.BytesToBe64(Block, Offset + 40); _M[6] = IntUtils.BytesToBe64(Block, Offset + 48); _M[7] = IntUtils.BytesToBe64(Block, Offset + 56); _M[8] = IntUtils.BytesToBe64(Block, Offset + 64); _M[9] = IntUtils.BytesToBe64(Block, Offset + 72); _M[10] = IntUtils.BytesToBe64(Block, Offset + 80); _M[11] = IntUtils.BytesToBe64(Block, Offset + 88); _M[12] = IntUtils.BytesToBe64(Block, Offset + 96); _M[13] = IntUtils.BytesToBe64(Block, Offset + 104); _M[14] = IntUtils.BytesToBe64(Block, Offset + 112); _M[15] = IntUtils.BytesToBe64(Block, Offset + 120); Array.Copy(_hashVal, _V, 8); _V[8] = _salt64[0] ^ 0x243F6A8885A308D3UL; _V[9] = _salt64[1] ^ 0x13198A2E03707344UL; _V[10] = _salt64[2] ^ 0xA4093822299F31D0UL; _V[11] = _salt64[3] ^ 0x082EFA98EC4E6C89UL; _V[12] = 0x452821E638D01377UL; _V[13] = 0xBE5466CF34E90C6CUL; _V[14] = 0xC0AC29B7C97C50DDUL; _V[15] = 0x3F84D5B5B5470917UL; if (!_isNullT) { _V[12] ^= _T; _V[13] ^= _T; } // do 16 rounds uint index = 0; do { MixBlock(index); index++; } while (index != ROUNDS); // finalization _hashVal[0] ^= _V[0]; _hashVal[1] ^= _V[1]; _hashVal[2] ^= _V[2]; _hashVal[3] ^= _V[3]; _hashVal[4] ^= _V[4]; _hashVal[5] ^= _V[5]; _hashVal[6] ^= _V[6]; _hashVal[7] ^= _V[7]; _hashVal[0] ^= _V[8]; _hashVal[1] ^= _V[9]; _hashVal[2] ^= _V[10]; _hashVal[3] ^= _V[11]; _hashVal[4] ^= _V[12]; _hashVal[5] ^= _V[13]; _hashVal[6] ^= _V[14]; _hashVal[7] ^= _V[15]; _hashVal[0] ^= _salt64[0]; _hashVal[1] ^= _salt64[1]; _hashVal[2] ^= _salt64[2]; _hashVal[3] ^= _salt64[3]; _hashVal[4] ^= _salt64[0]; _hashVal[5] ^= _salt64[1]; _hashVal[6] ^= _salt64[2]; _hashVal[7] ^= _salt64[3]; }