~ubuntu-branches/debian/squeeze/pycryptopp/squeeze

« back to all changes in this revision

Viewing changes to cryptopp/rijndael.h

  • Committer: Bazaar Package Importer
  • Author(s): Zooko O'Whielacronx
  • Date: 2009-06-22 22:20:50 UTC
  • Revision ID: james.westby@ubuntu.com-20090622222050-hbqmn50dt2kvoz5o
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef CRYPTOPP_RIJNDAEL_H
 
2
#define CRYPTOPP_RIJNDAEL_H
 
3
 
 
4
/** \file
 
5
*/
 
6
 
 
7
#include "seckey.h"
 
8
#include "secblock.h"
 
9
 
 
10
NAMESPACE_BEGIN(CryptoPP)
 
11
 
 
12
//! _
 
13
struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
 
14
{
 
15
        CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return CRYPTOPP_RIJNDAEL_NAME;}
 
16
};
 
17
 
 
18
/// <a href="http://www.weidai.com/scan-mirror/cs.html#Rijndael">Rijndael</a>
 
19
class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
 
20
{
 
21
        class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
 
22
        {
 
23
        public:
 
24
                void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
 
25
 
 
26
        protected:
 
27
                static void FillEncTable();
 
28
                static void FillDecTable();
 
29
 
 
30
                // VS2005 workaround: have to put these on seperate lines, or error C2487 is triggered in DLL build
 
31
                static const byte Se[256];
 
32
                static const byte Sd[256];
 
33
 
 
34
                static const word32 rcon[];
 
35
 
 
36
                unsigned int m_rounds;
 
37
                FixedSizeAlignedSecBlock<word32, 4*15> m_key;
 
38
        };
 
39
 
 
40
        class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
 
41
        {
 
42
        public:
 
43
                void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
 
44
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
 
45
                size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
 
46
#endif
 
47
        };
 
48
 
 
49
        class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
 
50
        {
 
51
        public:
 
52
                void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
 
53
        };
 
54
 
 
55
public:
 
56
        typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
 
57
        typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
 
58
};
 
59
 
 
60
typedef Rijndael::Encryption RijndaelEncryption;
 
61
typedef Rijndael::Decryption RijndaelDecryption;
 
62
 
 
63
NAMESPACE_END
 
64
 
 
65
#endif