File indexing completed on 2025-01-18 09:55:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef CRYPTOPP_RIJNDAEL_H
0011 #define CRYPTOPP_RIJNDAEL_H
0012
0013 #include "seckey.h"
0014 #include "secblock.h"
0015
0016
0017
0018 #if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_MIXED_ASM)
0019 # define CRYPTOPP_DISABLE_RIJNDAEL_ASM 1
0020 #endif
0021
0022 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_ARM32 || \
0023 CRYPTOPP_BOOL_ARMV8 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64
0024 # define CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS 1
0025 #endif
0026
0027 NAMESPACE_BEGIN(CryptoPP)
0028
0029
0030
0031
0032
0033
0034 struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
0035 {
0036 CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "AES";}
0037 };
0038
0039
0040
0041
0042
0043
0044
0045 class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
0046 {
0047
0048
0049 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
0050 {
0051 public:
0052 void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs ¶ms);
0053 std::string AlgorithmProvider() const;
0054 unsigned int OptimalDataAlignment() const;
0055
0056 protected:
0057 static void FillEncTable();
0058 static void FillDecTable();
0059
0060
0061 static const byte Se[256];
0062 static const byte Sd[256];
0063
0064 static const word32 rcon[];
0065
0066 unsigned int m_rounds;
0067 SecBlock<word32, AllocatorWithCleanup<word32, true> > m_key;
0068 mutable SecByteBlock m_aliasBlock;
0069 };
0070
0071
0072
0073
0074
0075
0076 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
0077 {
0078 public:
0079 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0080 #if CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS
0081 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
0082 #endif
0083 };
0084
0085
0086
0087
0088
0089
0090 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
0091 {
0092 public:
0093 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0094 #if CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS
0095 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
0096 #endif
0097 };
0098
0099 public:
0100 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0101 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0102 };
0103
0104 typedef Rijndael::Encryption RijndaelEncryption;
0105 typedef Rijndael::Decryption RijndaelDecryption;
0106
0107 NAMESPACE_END
0108
0109 #endif