Crypto++  5.6.5
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 //! \since Crypto++ 1.0
17 struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
18 {
19  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "IDEA";}
20 };
21 
22 //! \class IDEA
23 //! \brief IDEA block cipher
24 //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#IDEA">IDEA</a>
25 //! \since Crypto++ 1.0
26 class IDEA : public IDEA_Info, public BlockCipherDocumentation
27 {
28 public: // made public for internal purposes
29 #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
30  typedef word Word;
31 #else
32  typedef hword Word;
33 #endif
34 
35 private:
36  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<IDEA_Info>
37  {
38  public:
39  unsigned int OptimalDataAlignment() const {return 2;}
40  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
41 
42  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
43 
44  private:
45  void EnKey(const byte *);
46  void DeKey();
48 
49  #ifdef IDEA_LARGECACHE
50  static inline void LookupMUL(word &a, word b);
51  void LookupKeyLogs();
52  static void BuildLogTables();
53  static volatile bool tablesBuilt;
54  static word16 log[0x10000], antilog[0x10000];
55  #endif
56  };
57 
58 public:
61 };
62 
65 
66 NAMESPACE_END
67 
68 #endif
IDEA block cipher.
Definition: idea.h:26
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:127
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:408
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
Classes and functions for implementing secret key algorithms.
Provides class member functions to key a block cipher.
Definition: seckey.h:324
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:53
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:311
Crypto++ library namespace.
IDEA block cipher information.
Definition: idea.h:17
Interface for retrieving values given their names.
Definition: cryptlib.h:279