"Fossies" - the Fresh Open Source Software Archive 
Member "unrar/rijndael.hpp" (4 May 2022, 1309 Bytes) of package /linux/misc/unrarsrc-6.1.7.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "rijndael.hpp" see the
Fossies "Dox" file reference documentation.
1 #ifndef _RIJNDAEL_H_
2 #define _RIJNDAEL_H_
3
4 /**************************************************************************
5 * This code is based on Szymon Stefanek public domain AES implementation *
6 **************************************************************************/
7
8 #define _MAX_KEY_COLUMNS (256/32)
9 #define _MAX_ROUNDS 14
10 #define MAX_IV_SIZE 16
11
12 class Rijndael
13 {
14 private:
15 #ifdef USE_SSE
16 void blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffer);
17 void blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer);
18
19 bool AES_NI;
20 #endif
21 void keySched(byte key[_MAX_KEY_COLUMNS][4]);
22 void keyEncToDec();
23 void GenerateTables();
24
25 // RAR always uses CBC, but we may need to turn it off when calling
26 // this code from other archive formats with CTR and other modes.
27 bool CBCMode;
28
29 int m_uRounds;
30 byte m_initVector[MAX_IV_SIZE];
31 byte m_expandedKey[_MAX_ROUNDS+1][4][4];
32 public:
33 Rijndael();
34 void Init(bool Encrypt,const byte *key,uint keyLen,const byte *initVector);
35 void blockEncrypt(const byte *input, size_t inputLen, byte *outBuffer);
36 void blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer);
37 void SetCBCMode(bool Mode) {CBCMode=Mode;}
38 };
39
40 #endif // _RIJNDAEL_H_