Crypto++  5.6.3
Free C++ class library of cryptographic schemes
idea.h
Go to the documentation of this file.
1 // idea.h - 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 //! \class IDEA_Info
15 //! \brief IDEA block cipher information
16 struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
17 {
18  static const char *StaticAlgorithmName() {return "IDEA";}
19 };
20 
21 //! \class IDEA
22 //! \brief IDEA block cipher
23 //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#IDEA">IDEA</a>
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();
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:
59 };
60 
63 
64 NAMESPACE_END
65 
66 #endif
IDEA block cipher.
Definition: idea.h:24
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:117
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:396
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:34
Classes and functions for implementing secret key algorithms.
Provides class member functions to key a block cipher.
Definition: seckey.h:316
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:47
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:303
Crypto++ library namespace.
IDEA block cipher information.
Definition: idea.h:16
Interface for retrieving values given their names.
Definition: cryptlib.h:277