Security Scol plugin
rijndael.h
Go to the documentation of this file.
1// rijndael.h - originally written and placed in the public domain by Wei Dai
2
9
10#ifndef CRYPTOPP_RIJNDAEL_H
11#define CRYPTOPP_RIJNDAEL_H
12
13#include "seckey.h"
14#include "secblock.h"
15
16// Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler
17// error with .intel_syntax, http://llvm.org/bugs/show_bug.cgi?id=24232
18#if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_MIXED_ASM)
19# define CRYPTOPP_DISABLE_RIJNDAEL_ASM 1
20#endif
21
22#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_ARM32 || \
23 CRYPTOPP_BOOL_ARMV8 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64
24# define CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS 1
25#endif
26
27NAMESPACE_BEGIN(CryptoPP)
28
29
34struct Rijndael_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
35{
36 CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "AES";}
37};
38
45class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentation
46{
49 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
50 {
51 public:
52 void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs &params);
53 std::string AlgorithmProvider() const;
54 unsigned int OptimalDataAlignment() const;
55
56 protected:
57 static void FillEncTable();
58 static void FillDecTable();
59
60 // VS2005 workaround: have to put these on separate lines, or error C2487 is triggered in DLL build
61 static const byte Se[256];
62 static const byte Sd[256];
63
64 static const word32 rcon[];
65
66 unsigned int m_rounds;
68 mutable SecByteBlock m_aliasBlock;
69 };
70
76 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
77 {
78 public:
79 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
80#if CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS
81 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
82#endif
83 };
84
90 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
91 {
92 public:
93 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
94#if CRYPTOPP_RIJNDAEL_ADVANCED_PROCESS_BLOCKS
95 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
96#endif
97 };
98
99public:
102};
103
106
107NAMESPACE_END
108
109#endif
Provides class member functions to key a block cipher.
Definition seckey.h:318
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition seckey.h:306
Inherited by algorithms with fixed block size.
Definition seckey.h:41
Interface for retrieving values given their names.
Definition cryptlib.h:322
Rijndael block cipher.
Definition rijndael.h:46
Secure memory block with allocator and cleanup.
Definition secblock.h:731
Inherited by keyed algorithms with variable key length.
Definition seckey.h:166
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition seckey.h:399
Rijndael block cipher information.
Definition rijndael.h:35