00001
00002
00003
00004
00005
00006
00007
00008 #ifndef CRYPTOPP_RIJNDAEL_H
00009 #define CRYPTOPP_RIJNDAEL_H
00010
00011 #include "seckey.h"
00012 #include "secblock.h"
00013
00014 #if CRYPTOPP_BOOL_X32
00015 # define CRYPTOPP_DISABLE_RIJNDAEL_ASM
00016 #endif
00017
00018 NAMESPACE_BEGIN(CryptoPP)
00019
00020
00021 struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
00022 {
00023 CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return CRYPTOPP_RIJNDAEL_NAME;}
00024 };
00025
00026
00027
00028 class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
00029 {
00030
00031
00032 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
00033 {
00034 public:
00035 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
00036
00037 protected:
00038 static void FillEncTable();
00039 static void FillDecTable();
00040
00041
00042 static const byte Se[256];
00043 static const byte Sd[256];
00044
00045 static const word32 rcon[];
00046
00047 unsigned int m_rounds;
00048 FixedSizeAlignedSecBlock<word32, 4*15> m_key;
00049 };
00050
00051
00052
00053 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
00054 {
00055 public:
00056 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00057 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
00058 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
00059 #endif
00060 };
00061
00062
00063
00064 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
00065 {
00066 public:
00067 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00068 #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
00069 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
00070 #endif
00071 };
00072
00073 public:
00074 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
00075 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
00076 };
00077
00078 typedef Rijndael::Encryption RijndaelEncryption;
00079 typedef Rijndael::Decryption RijndaelDecryption;
00080
00081 NAMESPACE_END
00082
00083 #endif