Crypto++
rijndael.h
Go to the documentation of this file.
00001 #ifndef CRYPTOPP_RIJNDAEL_H
00002 #define CRYPTOPP_RIJNDAEL_H
00003 
00004 /** \file
00005 */
00006 
00007 #include "seckey.h"
00008 #include "secblock.h"
00009 
00010 NAMESPACE_BEGIN(CryptoPP)
00011 
00012 //! _
00013 struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
00014 {
00015     CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return CRYPTOPP_RIJNDAEL_NAME;}
00016 };
00017 
00018 /// <a href="http://www.weidai.com/scan-mirror/cs.html#Rijndael">Rijndael</a>
00019 class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
00020 {
00021     class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
00022     {
00023     public:
00024         void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
00025 
00026     protected:
00027         static void FillEncTable();
00028         static void FillDecTable();
00029 
00030         // VS2005 workaround: have to put these on seperate lines, or error C2487 is triggered in DLL build
00031         static const byte Se[256];
00032         static const byte Sd[256];
00033 
00034         static const word32 rcon[];
00035 
00036         unsigned int m_rounds;
00037         FixedSizeAlignedSecBlock<word32, 4*15> m_key;
00038     };
00039 
00040     class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
00041     {
00042     public:
00043         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00044 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86
00045         size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
00046 #endif
00047     };
00048 
00049     class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
00050     {
00051     public:
00052         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00053 #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
00054         size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
00055 #endif
00056     };
00057 
00058 public:
00059     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
00060     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
00061 };
00062 
00063 typedef Rijndael::Encryption RijndaelEncryption;
00064 typedef Rijndael::Decryption RijndaelDecryption;
00065 
00066 NAMESPACE_END
00067 
00068 #endif