1#ifndef CRYPTOPP_RIJNDAEL_H 2#define CRYPTOPP_RIJNDAEL_H 3 4/** \file 5*/ 6 7#include "seckey.h" 8#include "secblock.h" 9 10NAMESPACE_BEGIN(CryptoPP) 11 12//! _ 13struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8> 14{ 15 CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return CRYPTOPP_RIJNDAEL_NAME;} 16}; 17 18/// <a href="http://www.weidai.com/scan-mirror/cs.html#Rijndael">Rijndael</a> 19class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation 20{ 21 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info> 22 { 23 public: 24 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); 25 26 protected: 27 static void FillEncTable(); 28 static void FillDecTable(); 29 30 // VS2005 workaround: have to put these on seperate lines, or error C2487 is triggered in DLL build 31 static const byte Se[256]; 32 static const byte Sd[256]; 33 34 static const word32 rcon[]; 35 36 unsigned int m_rounds; 37 FixedSizeAlignedSecBlock<word32, 4*15> m_key; 38 }; 39 40 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base 41 { 42 public: 43 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; 44#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) 45 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const; 46#endif 47 }; 48 49 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base 50 { 51 public: 52 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; 53 }; 54 55public: 56 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption; 57 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption; 58}; 59 60typedef Rijndael::Encryption RijndaelEncryption; 61typedef Rijndael::Decryption RijndaelDecryption; 62 63NAMESPACE_END 64 65#endif 66