Crypto++  5.6.4
Free C++ class library of cryptographic schemes
rijndael.h
Go to the documentation of this file.
1 // rijndael.h - written and placed in the public domain by Wei Dai
2 
3 //! \file rijndael.h
4 //! \brief Classes for Rijndael encryption algorithm
5 //! \details All key sizes are supported. The library only provides Rijndael with 128-bit blocks,
6 //! and not 192-bit or 256-bit blocks
7 
8 #ifndef CRYPTOPP_RIJNDAEL_H
9 #define CRYPTOPP_RIJNDAEL_H
10 
11 #include "seckey.h"
12 #include "secblock.h"
13 
14 // Clang 3.3 integrated assembler crash on Linux
15 #if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400))
16 # define CRYPTOPP_DISABLE_RIJNDAEL_ASM
17 #endif
18 
19 NAMESPACE_BEGIN(CryptoPP)
20 
21 //! \brief Rijndael block cipher information
22 struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
23 {
24  CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return CRYPTOPP_RIJNDAEL_NAME;}
25 };
26 
27 //! \brief Rijndael block cipher implementation details
28 //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#Rijndael">Rijndael</a>
29 class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
30 {
31  //! \brief Rijndael block cipher data processing functionss
32  //! \details Provides implementation common to encryption and decryption
33  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
34  {
35  public:
36  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
37 
38  protected:
39  static void FillEncTable();
40  static void FillDecTable();
41 
42  // VS2005 workaround: have to put these on seperate lines, or error C2487 is triggered in DLL build
43  static const byte Se[256];
44  static const byte Sd[256];
45 
46  static const word32 rcon[];
47 
48  unsigned int m_rounds;
50  };
51 
52  //! \brief Rijndael block cipher data processing functions
53  //! \details Provides implementation for encryption transformation
54  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
55  {
56  public:
57  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
58 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
59  size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
60 #endif
61  };
62 
63  //! \brief Rijndael block cipher data processing functions
64  //! \details Provides implementation for decryption transformation
65  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
66  {
67  public:
68  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
69 #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
70  size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
71 #endif
72  };
73 
74 public:
77 };
78 
81 
82 NAMESPACE_END
83 
84 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:423
Rijndael block cipher implementation details.
Definition: rijndael.h:29
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.
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:177
Rijndael block cipher information.
Definition: rijndael.h:22
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:326
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:282