Crypto++ 8.0 Free C++ class library of cryptographic schemes

idea.h
Go to the documentation of this file.
1 // idea.h - originally written and placed in the public domain by Wei Dai
2
3 /// \file idea.h
4 /// \brief Classes for the IDEA block cipher
5
6 #ifndef CRYPTOPP_IDEA_H
7 #define CRYPTOPP_IDEA_H
8
9 #include "seckey.h"
10 #include "secblock.h"
11
12 NAMESPACE_BEGIN(CryptoPP)
13
14 /// \brief IDEA block cipher information
15 /// \since Crypto++ 1.0
16 struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
17 {
18 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "IDEA";}
19 };
20
21 /// \brief IDEA block cipher
22 /// \sa <a href="http://www.cryptopp.com/wiki/IDEA">IDEA</a>
23 /// \since Crypto++ 1.0
24 class IDEA : public IDEA_Info, public BlockCipherDocumentation
25 {
26 public: // made public for internal purposes
27 #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
28 typedef word Word;
29 #else
30 typedef hword Word;
31 #endif
32
33 private:
34 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<IDEA_Info>
35 {
36 public:
37 unsigned int OptimalDataAlignment() const {return 2;}
38 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
39
40 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
41
42 private:
43 void EnKey(const byte *);
44 void DeKey();
45 FixedSizeSecBlock<Word, 6*ROUNDS+4> m_key;
46
47 #ifdef IDEA_LARGECACHE
48 static inline void LookupMUL(word &a, word b);
49 void LookupKeyLogs();
50 static void BuildLogTables();
51 static volatile bool tablesBuilt;
52 static word16 log[0x10000], antilog[0x10000];
53 #endif
54 };
55
56 public:
57 typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
58 typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
59 };
60
61 typedef IDEA::Encryption IDEAEncryption;
62 typedef IDEA::Decryption IDEADecryption;
63
64 NAMESPACE_END
65
66 #endif
IDEA
IDEA block cipher.
Definition: idea.h:24
FixedKeyLength
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:124
BlockCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:398
secblock.h
Classes and functions for secure memory allocations.
FixedBlockSize
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
seckey.h
Classes and functions for implementing secret key algorithms.
BlockCipherFinal
Provides class member functions to key a block cipher.
Definition: seckey.h:317
FixedSizeSecBlock< Word, 6 *ROUNDS+4 >
FixedRounds
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:52
BlockCipherImpl
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:305
CryptoPP
Crypto++ library namespace.
IDEA_Info
IDEA block cipher information.
Definition: idea.h:16
Word
Definition: integer.cpp:410
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:293