summaryrefslogtreecommitdiff
path: root/modes.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-08-12 04:06:06 -0400
committerJeffrey Walton <noloader@gmail.com>2018-08-12 04:06:06 -0400
commitdd4f87fa118ddcb9a4d583fc68596eae32b75fed (patch)
treeab393c104733b35958d1ada41002908645337252 /modes.cpp
parentafe72c50f094b1bd34b8e8bb1ce9ab3798ca5ee2 (diff)
downloadcryptopp-git-dd4f87fa118ddcb9a4d583fc68596eae32b75fed.tar.gz
Clear IBM XLC warnings on PowerPC
Diffstat (limited to 'modes.cpp')
-rw-r--r--modes.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/modes.cpp b/modes.cpp
index b88208f9..9ff761ca 100644
--- a/modes.cpp
+++ b/modes.cpp
@@ -125,8 +125,8 @@ void CTR_ModePolicy::SeekToIteration(lword iterationCount)
int carry=0;
for (int i=BlockSize()-1; i>=0; i--)
{
- unsigned int sum = m_register[i] + byte(iterationCount) + carry;
- m_counterArray[i] = static_cast<byte>(sum);
+ unsigned int sum = m_register[i] + (iterationCount & 0xff) + carry;
+ m_counterArray[i] = byte(sum & 0xff);
carry = sum >> 8;
iterationCount >>= 8;
}
@@ -147,14 +147,15 @@ void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *ou
while (iterationCount)
{
- byte lsb = m_counterArray[s-1];
- size_t blocks = UnsignedMin(iterationCount, 256U-lsb);
+ const byte lsb = m_counterArray[s-1];
+ const size_t blocks = UnsignedMin(iterationCount, 256U-lsb);
+
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)) == 0)
+ if ((m_counterArray[s-1] = byte(lsb + blocks)) == 0)
IncrementCounterBy256();
output = PtrAdd(output, blocks*s);
- input = PtrAdd(input, blocks*inputIncrement);
+ input = PtrAdd(input, blocks*inputIncrement);
iterationCount -= blocks;
}
}
@@ -166,7 +167,7 @@ void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv,
CRYPTOPP_ASSERT(length == BlockSize());
CopyOrZero(m_register, m_register.size(), iv, length);
- m_counterArray = m_register;
+ m_counterArray.Assign(m_register.begin(), m_register.size());
}
void BlockOrientedCipherModeBase::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)