Crypto++  5.6.3
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 #if CRYPTOPP_BOOL_X32
15 # define CRYPTOPP_DISABLE_RIJNDAEL_ASM
16 #endif
17 
18 NAMESPACE_BEGIN(CryptoPP)
19 
20 //! \brief Rijndael block cipher information
21 struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
22 {
23  CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return CRYPTOPP_RIJNDAEL_NAME;}
24 };
25 
26 //! \brief Rijndael block cipher implementation details
27 //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#Rijndael">Rijndael</a>
28 class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
29 {
30  //! \brief Rijndael block cipher data processing functionss
31  //! \details Provides implementation common to encryption and decryption
32  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
33  {
34  public:
35  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
36 
37  protected:
38  static void FillEncTable();
39  static void FillDecTable();
40 
41  // VS2005 workaround: have to put these on seperate lines, or error C2487 is triggered in DLL build
42  static const byte Se[256];
43  static const byte Sd[256];
44 
45  static const word32 rcon[];
46 
47  unsigned int m_rounds;
49  };
50 
51  //! \brief Rijndael block cipher data processing functions
52  //! \details Provides implementation for encryption transformation
53  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
54  {
55  public:
56  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
57 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
58  size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
59 #endif
60  };
61 
62  //! \brief Rijndael block cipher data processing functions
63  //! \details Provides implementation for decryption transformation
64  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
65  {
66  public:
67  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
68 #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
69  size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
70 #endif
71  };
72 
73 public:
76 };
77 
80 
81 NAMESPACE_END
82 
83 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:385
Rijndael block cipher implementation details.
Definition: rijndael.h:28
Classes and functions for secure memory allocations.
Inherited by block ciphers 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:152
Rijndael block cipher information.
Definition: rijndael.h:21
Provides class member functions to access BlockCipher constants.
Definition: seckey.h:292
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:261