Crypto++  5.6.5
Free C++ class library of cryptographic schemes
rijndael.h
Go to the documentation of this file.
1 // rijndael.h - originally 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 /// \since Rijndael since Crypto++ 3.2, Intel AESNI since Crypto++ 5.6.1, ARMv8 AES since Crypto++ 6.0,
8 /// Power8 AES since Crypto++ 6.0
9 
10 #ifndef CRYPTOPP_RIJNDAEL_H
11 #define CRYPTOPP_RIJNDAEL_H
12 
13 #include "seckey.h"
14 #include "secblock.h"
15 
16 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_ARM32 || \
17  CRYPTOPP_BOOL_ARM64 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64
18 # define CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS 1
19 #endif
20 
21 NAMESPACE_BEGIN(CryptoPP)
22 
23 /// \brief Rijndael block cipher information
24 /// \details All key sizes are supported. The library only provides Rijndael with 128-bit blocks,
25 /// and not 192-bit or 256-bit blocks
26 /// \since Rijndael since Crypto++ 3.2, Intel AESNI since Crypto++ 5.6.1, ARMv8 AES since Crypto++ 6.0,
27 /// Power8 AES since Crypto++ 6.0
28 struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
29 {
30  CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return CRYPTOPP_RIJNDAEL_NAME;}
31 };
32 
33 /// \brief Rijndael block cipher
34 /// \details All key sizes are supported. The library only provides Rijndael with 128-bit blocks,
35 /// and not 192-bit or 256-bit blocks
36 /// \since Rijndael since Crypto++ 3.2, Intel AESNI since Crypto++ 5.6.1, ARMv8 AES since Crypto++ 6.0,
37 /// Power8 AES since Crypto++ 6.0
38 /// \sa <a href="http://www.cryptopp.com/wiki/Rijndael">Rijndael</a>
39 class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
40 {
41  /// \brief Rijndael block cipher transformation functions
42  /// \details Provides implementation common to encryption and decryption
43  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
44  {
45  public:
46  void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs &params);
47 
48  protected:
49  static void FillEncTable();
50  static void FillDecTable();
51 
52  // VS2005 workaround: have to put these on separate lines, or error C2487 is triggered in DLL build
53  static const byte Se[256];
54  static const byte Sd[256];
55 
56  static const word32 rcon[];
57 
58  unsigned int m_rounds;
60  mutable SecByteBlock m_aliasBlock;
61  };
62 
63  /// \brief Provides implementation for encryption transformation
64  /// \details Enc provides implementation for encryption transformation. All key sizes are supported.
65  /// The library only provides Rijndael with 128-bit blocks, and not 192-bit or 256-bit blocks
66  /// \since Rijndael since Crypto++ 3.2, Intel AESNI since Crypto++ 5.6.1, ARMv8 AES since Crypto++ 6.0,
67  /// Power8 AES since Crypto++ 6.0
68  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
69  {
70  public:
71  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
72 #if CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS
73  size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
74 #endif
75  };
76 
77  /// \brief Provides implementation for decryption transformation
78  /// \details Dec provides implementation for decryption transformation. All key sizes are supported.
79  /// The library only provides Rijndael with 128-bit blocks, and not 192-bit or 256-bit blocks
80  /// \since Rijndael since Crypto++ 3.2, Intel AESNI since Crypto++ 5.6.1, ARMv8 AES since Crypto++ 6.0,
81  /// Power8 AES since Crypto++ 6.0
82  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
83  {
84  public:
85  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
86 #if CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS
87  size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
88 #endif
89  };
90 
91 public:
94 };
95 
98 
99 NAMESPACE_END
100 
101 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:419
SecBlock<byte> typedef.
Definition: secblock.h:822
Rijndael block cipher.
Definition: rijndael.h:39
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:39
Classes and functions for implementing secret key algorithms.
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:187
Rijndael block cipher information.
Definition: rijndael.h:28
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:291