~zooko/cryptopp/trunk

« back to all changes in this revision

Viewing changes to mdc.h

  • Committer: weidai
  • Date: 2003-07-29 01:18:33 UTC
  • Revision ID: svn-v4:57ff6487-cd31-0410-9ec3-f628ee90f5f0:trunk/c5:118
fix potential threading problem with initialization of static objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
NAMESPACE_BEGIN(CryptoPP)
13
13
 
14
 
//! _
15
14
template <class T>
16
15
struct MDC_Info : public FixedBlockSize<T::DIGESTSIZE>, public FixedKeyLength<T::BLOCKSIZE>
17
16
{
31
30
                void UncheckedSetKey(CipherDir direction, const byte *userKey, unsigned int length)
32
31
                {
33
32
                        assert(direction == ENCRYPTION);
34
 
                        this->AssertValidKeyLength(length);
35
 
                        memcpy_s(m_key, m_key.size(), userKey, this->KEYLENGTH);
36
 
                        T::CorrectEndianess(Key(), Key(), this->KEYLENGTH);
 
33
                        AssertValidKeyLength(length);
 
34
                        memcpy(Key(), userKey, KEYLENGTH);
 
35
                        T::CorrectEndianess(Key(), Key(), KEYLENGTH);
37
36
                }
38
37
 
39
38
                void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
40
39
                {
41
 
                        T::CorrectEndianess(Buffer(), (HashWordType *)inBlock, this->BLOCKSIZE);
 
40
                        T::CorrectEndianess(Buffer(), (HashWordType *)inBlock, BLOCKSIZE);
42
41
                        T::Transform(Buffer(), Key());
43
42
                        if (xorBlock)
44
43
                        {
45
 
                                T::CorrectEndianess(Buffer(), Buffer(), this->BLOCKSIZE);
46
 
                                xorbuf(outBlock, xorBlock, m_buffer, this->BLOCKSIZE);
 
44
                                T::CorrectEndianess(Buffer(), Buffer(), BLOCKSIZE);
 
45
                                xorbuf(outBlock, xorBlock, m_buffer, BLOCKSIZE);
47
46
                        }
48
47
                        else
49
 
                                T::CorrectEndianess((HashWordType *)outBlock, Buffer(), this->BLOCKSIZE);
 
48
                                T::CorrectEndianess((HashWordType *)outBlock, Buffer(), BLOCKSIZE);
50
49
                }
51
50
 
52
51
                bool IsPermutation() const {return false;}