Increase use of ptrdiff_t when performing pointer math

pull/687/head
Jeffrey Walton 2018-07-10 17:41:23 -04:00
parent 1836a7feb4
commit bdac2de36e
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 6 additions and 3 deletions

View File

@ -65,8 +65,8 @@ void CFB_ModePolicy::TransformRegister()
const ptrdiff_t updateSize = BlockSize()-m_feedbackSize; const ptrdiff_t updateSize = BlockSize()-m_feedbackSize;
m_cipher->ProcessBlock(m_register, m_temp); m_cipher->ProcessBlock(m_register, m_temp);
memmove_s(m_register, m_register.size(), m_register+m_feedbackSize, updateSize); memmove_s(m_register, m_register.size(), PtrAdd(m_register.begin(),m_feedbackSize), updateSize);
memcpy_s(m_register+updateSize, m_register.size()-updateSize, m_temp, m_feedbackSize); memcpy_s(PtrAdd(m_register.begin(),updateSize), m_register.size()-updateSize, m_temp, m_feedbackSize);
} }
void CFB_ModePolicy::CipherResynchronize(const byte *iv, size_t length) void CFB_ModePolicy::CipherResynchronize(const byte *iv, size_t length)
@ -150,7 +150,7 @@ void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *ou
byte lsb = m_counterArray[s-1]; byte lsb = m_counterArray[s-1];
size_t blocks = UnsignedMin(iterationCount, 256U-lsb); size_t blocks = UnsignedMin(iterationCount, 256U-lsb);
m_cipher->AdvancedProcessBlocks(m_counterArray, input, output, blocks*s, BlockTransformation::BT_InBlockIsCounter|BlockTransformation::BT_AllowParallel); m_cipher->AdvancedProcessBlocks(m_counterArray, input, output, blocks*s, BlockTransformation::BT_InBlockIsCounter|BlockTransformation::BT_AllowParallel);
if ((m_counterArray[s-1] = static_cast<byte>(lsb + (blocks & 0xff))) == 0) if ((m_counterArray[s-1] = static_cast<byte>(lsb + blocks)) == 0)
IncrementCounterBy256(); IncrementCounterBy256();
output = PtrAdd(output, blocks*s); output = PtrAdd(output, blocks*s);

View File

@ -541,6 +541,9 @@ template <class BASE>
class CRYPTOPP_NO_VTABLE CFB_CipherTemplate : public BASE class CRYPTOPP_NO_VTABLE CFB_CipherTemplate : public BASE
{ {
public: public:
virtual ~CFB_CipherTemplate() {}
CFB_CipherTemplate() : m_leftOver(0) {}
/// \brief Apply keystream to data /// \brief Apply keystream to data
/// \param outString a buffer to write the transformed data /// \param outString a buffer to write the transformed data
/// \param inString a buffer to read the data /// \param inString a buffer to read the data