~zooko/cryptopp/trunk

« back to all changes in this revision

Viewing changes to wake.cpp

  • Committer: weidai
  • Date: 2007-05-04 15:04:58 UTC
  • Revision ID: svn-v4:57ff6487-cd31-0410-9ec3-f628ee90f5f0:trunk/c5:328
reduce risk of random number reuse after VM rollback

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include "pch.h"
4
4
#include "wake.h"
5
5
 
6
 
#include "strciphr.cpp"
7
 
 
8
6
NAMESPACE_BEGIN(CryptoPP)
9
7
 
10
8
void WAKE_TestInstantiations()
11
9
{
12
 
        WAKE_CFB<>::Encryption x1;
13
 
        WAKE_CFB<>::Decryption x3;
 
10
        Weak::WAKE_CFB<>::Encryption x1;
 
11
        Weak::WAKE_CFB<>::Decryption x3;
14
12
        WAKE_OFB<>::Encryption x2;
15
13
        WAKE_OFB<>::Decryption x4;
16
14
}
87
85
template <class B>
88
86
void WAKE_Policy<B>::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
89
87
{
90
 
        KeystreamOutput<B> keystreamOperation(operation, output, input);
 
88
#define WAKE_OUTPUT(x)\
 
89
        while (iterationCount--)\
 
90
        {\
 
91
                CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 0, r6);\
 
92
                r3 = M(r3, r6);\
 
93
                r4 = M(r4, r3);\
 
94
                r5 = M(r5, r4);\
 
95
                r6 = M(r6, r5);\
 
96
                output += 4;\
 
97
                if (x == XOR_KEYSTREAM)\
 
98
                        input += 4;\
 
99
        }
91
100
 
92
 
        while (iterationCount--)
93
 
        {
94
 
                keystreamOperation(r6);
95
 
                r3 = M(r3, r6);
96
 
                r4 = M(r4, r3);
97
 
                r5 = M(r5, r4);
98
 
                r6 = M(r6, r5);
99
 
        }
 
101
        typedef word32 WordType;
 
102
        CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(WAKE_OUTPUT, 0);
100
103
}
101
104
/*
102
105
template <class B>