~zooko/cryptopp/trunk

« back to all changes in this revision

Viewing changes to seal.cpp

  • Committer: weidai
  • Date: 2007-08-13 23:48:17 UTC
  • Revision ID: svn-v4:57ff6487-cd31-0410-9ec3-f628ee90f5f0:trunk/c5:383
fixed Salsa20 initialization crash on non-SSE2 machines

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// updated to SEAL 3.0 by Leonard Janke
3
3
 
4
4
#include "pch.h"
 
5
 
 
6
// prevent Sun's CC compiler from including this file automatically
 
7
#if !(defined(__SUNPRO_CC) && defined(CRYPTOPP_ITERHASH_H))
 
8
 
5
9
#include "seal.h"
6
10
#include "sha.h"
7
11
#include "misc.h"
8
12
 
9
 
#include "strciphr.cpp"
10
 
 
11
13
NAMESPACE_BEGIN(CryptoPP)
12
14
 
13
15
void SEAL_TestInstantiations()
69
71
template <class B>
70
72
void SEAL_Policy<B>::CipherResynchronize(byte *keystreamBuffer, const byte *IV)
71
73
{
72
 
        m_outsideCounter = IV ? UnalignedGetWord<word32>(BIG_ENDIAN_ORDER, IV) : 0;
 
74
        m_outsideCounter = IV ? GetWord<word32>(false, BIG_ENDIAN_ORDER, IV) : 0;
73
75
        m_startCount = m_outsideCounter;
74
76
        m_insideCounter = 0;
75
77
}
84
86
template <class B>
85
87
void SEAL_Policy<B>::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
86
88
{
87
 
        KeystreamOutput<B> keystreamOutput(operation, output, input);
88
89
        word32 a, b, c, d, n1, n2, n3, n4;
89
90
        unsigned int p, q;
90
91
 
173
174
                        d = rotrFixed(d, 9U);
174
175
                        a += Ttab(q);
175
176
 
176
 
                        keystreamOutput (b + m_S[4*i+0])
177
 
                                                        (c ^ m_S[4*i+1])
178
 
                                                        (d + m_S[4*i+2])
179
 
                                                        (a ^ m_S[4*i+3]);
 
177
#define SEAL_OUTPUT(x)  \
 
178
        CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 0, b + m_S[4*i+0]);\
 
179
        CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 1, c ^ m_S[4*i+1]);\
 
180
        CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 2, d + m_S[4*i+2]);\
 
181
        CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 3, a ^ m_S[4*i+3]);
 
182
 
 
183
                        CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(SEAL_OUTPUT, 4*4);
180
184
 
181
185
                        if (i & 1)
182
186
                        {
209
213
template class SEAL_Policy<LittleEndian>;
210
214
 
211
215
NAMESPACE_END
 
216
 
 
217
#endif