From 5cad605559f973f2ce7d5ede1e6b67151f8e1d51 Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 16 Apr 2007 00:21:07 +0000 Subject: optimizations --- seal.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'seal.cpp') diff --git a/seal.cpp b/seal.cpp index f240b50a..196965f8 100644 --- a/seal.cpp +++ b/seal.cpp @@ -71,7 +71,7 @@ void SEAL_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, template void SEAL_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV) { - m_outsideCounter = IV ? UnalignedGetWord(BIG_ENDIAN_ORDER, IV) : 0; + m_outsideCounter = IV ? GetWord(false, BIG_ENDIAN_ORDER, IV) : 0; m_startCount = m_outsideCounter; m_insideCounter = 0; } @@ -86,7 +86,6 @@ void SEAL_Policy::SeekToIteration(lword iterationCount) template void SEAL_Policy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) { - KeystreamOutput keystreamOutput(operation, output, input); word32 a, b, c, d, n1, n2, n3, n4; unsigned int p, q; @@ -175,10 +174,13 @@ void SEAL_Policy::OperateKeystream(KeystreamOperation operation, byte *output d = rotrFixed(d, 9U); a += Ttab(q); - keystreamOutput (b + m_S[4*i+0]) - (c ^ m_S[4*i+1]) - (d + m_S[4*i+2]) - (a ^ m_S[4*i+3]); +#define SEAL_OUTPUT(x) \ + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 0, b + m_S[4*i+0]);\ + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 1, c ^ m_S[4*i+1]);\ + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 2, d + m_S[4*i+2]);\ + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 3, a ^ m_S[4*i+3]); + + CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(SEAL_OUTPUT, 4*4); if (i & 1) { -- cgit v1.2.1