void BlockOrientedCipherModeBase::ProcessData(byte *outString, const byte *inString, size_t length) { unsigned int s = BlockSize(); assert(length % s == 0); unsigned int alignment = m_cipher->BlockAlignment(); bool inputAlignmentOk = !RequireAlignedInput() || IsAlignedOn(inString, alignment); if (IsAlignedOn(outString, alignment)) { if (inputAlignmentOk) ProcessBlocks(outString, inString, length / s); else { memcpy(outString, inString, length); ProcessBlocks(outString, outString, length / s); } } else { while (length) { if (inputAlignmentOk) ProcessBlocks(m_buffer, inString, 1); else { memcpy(m_buffer, inString, s); ProcessBlocks(m_buffer, m_buffer, 1); } memcpy(outString, m_buffer, s); inString += s; outString += s; length -= s; } } }
void BlockOrientedCipherModeBase::ProcessData(byte *outString, const byte *inString, size_t length) { if (!length) return; unsigned int s = BlockSize(); assert(length % s == 0); if (!RequireAlignedInput() || IsAlignedOn(inString, m_cipher->BlockAlignment())) ProcessBlocks(outString, inString, length / s); else { do { memcpy(m_buffer, inString, s); ProcessBlocks(outString, m_buffer, 1); inString += s; outString += s; length -= s; } while (length > 0); } }