Crypto++  8.8
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();
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
Provides class member functions to key a block cipher.
Definition: seckey.h:318
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:306
Inherited by algorithms with fixed block size.
Definition: seckey.h:41
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:125
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:53
IDEA block cipher.
Definition: idea.h:25
Interface for retrieving values given their names.
Definition: cryptlib.h:327
word64 word
Full word used for multiprecision integer arithmetic.
Definition: config_int.h:192
unsigned short word16
16-bit unsigned datatype
Definition: config_int.h:69
word32 hword
Half word used for multiprecision integer arithmetic.
Definition: config_int.h:184
Crypto++ library namespace.
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition: seckey.h:399
IDEA block cipher information.
Definition: idea.h:17