1 // Crypto/RarAes.h
2 
3 #ifndef __CRYPTO_RAR_AES_H
4 #define __CRYPTO_RAR_AES_H
5 
6 #include "../../../C/Aes.h"
7 
8 #include "../../Common/MyBuffer.h"
9 
10 #include "../IPassword.h"
11 
12 #include "MyAes.h"
13 
14 namespace NCrypto {
15 namespace NRar3 {
16 
17 const unsigned kAesKeySize = 16;
18 
19 class CDecoder:
20   public CAesCbcDecoder
21   // public ICompressSetDecoderProperties2,
22   // public ICryptoSetPassword
23 {
24   Byte _salt[8];
25   bool _thereIsSalt;
26   bool _needCalc;
27   // bool _rar350Mode;
28 
29   CByteBuffer _password;
30 
31   Byte _key[kAesKeySize];
32   Byte _iv[AES_BLOCK_SIZE];
33 
34   void CalcKey();
35 public:
36   /*
37   MY_UNKNOWN_IMP1(
38     ICryptoSetPassword
39     // ICompressSetDecoderProperties2
40   */
41   STDMETHOD(Init)();
42 
43   void SetPassword(const Byte *data, unsigned size);
44   HRESULT SetDecoderProperties2(const Byte *data, UInt32 size);
45 
46   CDecoder();
47   // void SetRar350Mode(bool rar350Mode) { _rar350Mode = rar350Mode; }
48 };
49 
50 }}
51 
52 #endif
53