From d855d26b56f5651e16ccb3be5d84810628fd2798 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 11 Apr 2020 11:40:37 -0400 Subject: Cleanup XTS mode --- xts.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'xts.cpp') diff --git a/xts.cpp b/xts.cpp index 8addd5fd..d123a745 100644 --- a/xts.cpp +++ b/xts.cpp @@ -63,7 +63,7 @@ inline void XorBuffer(byte *output, const byte *input, const byte *mask, size_t CRYPTOPP_ASSERT(count >= 16 && (count % 16 == 0)); #if defined(CRYPTOPP_DISABLE_ASM) - xorbuf(output, input, mask, count); + xorbuf(output, input, mask, count); #elif defined(__SSE2__) || defined(_M_X64) for (size_t i=0; i= parallelSize) { // If this fires the GF_Double'ing below is not in sync CRYPTOPP_ASSERT(ParallelBlocks == 4); @@ -261,29 +260,37 @@ void XTS_ModeBase::ProcessData(byte *outString, const byte *inString, size_t len GF_Double(m_xregister+3*blockSize, m_xregister+2*blockSize, blockSize); // merge the tweak into the input block - XorBuffer(m_xworkspace, inString+i, m_xregister, parallelSize); + XorBuffer(m_xworkspace, inString, m_xregister, parallelSize); // encrypt one block, merge the tweak into the output block - GetBlockCipher().AdvancedProcessBlocks(m_xworkspace, m_xregister, outString+i, parallelSize, BlockTransformation::BT_AllowParallel); + GetBlockCipher().AdvancedProcessBlocks(m_xworkspace, m_xregister, outString, parallelSize, BlockTransformation::BT_AllowParallel); // m_xregister[0] always points to the next tweak. - GF_Double(m_xregister+0, m_xregister+(ParallelBlocks-1)*blockSize, blockSize); + GF_Double(m_xregister+0, m_xregister+3*blockSize, blockSize); + + inString += parallelSize; + outString += parallelSize; + length -= parallelSize; } // encrypt the data unit, blocksize at a time - for ( ; i