xref: /aosp_15_r20/external/lzma/CPP/7zip/Crypto/RarAes.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // Crypto/RarAes.h
2 
3 #ifndef ZIP7_INC_CRYPTO_RAR_AES_H
4 #define ZIP7_INC_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 Z7_final:
20   public CAesCbcDecoder
21 {
22   Byte _salt[8];
23   bool _thereIsSalt;
24   bool _needCalc;
25   // bool _rar350Mode;
26 
27   CByteBuffer _password;
28 
29   Byte _key[kAesKeySize];
30   Byte _iv[AES_BLOCK_SIZE];
31 
32   void CalcKey();
33 public:
34   Z7_COM7F_IMP(Init())
35 
36   void SetPassword(const Byte *data, unsigned size);
37   HRESULT SetDecoderProperties2(const Byte *data, UInt32 size);
38 
39   CDecoder();
40 
~CDecoder()41   ~CDecoder() Z7_DESTRUCTOR_override { Wipe(); }
Wipe()42   void Wipe()
43   {
44     _password.Wipe();
45     Z7_memset_0_ARRAY(_salt);
46     Z7_memset_0_ARRAY(_key);
47     Z7_memset_0_ARRAY(_iv);
48   }
49   // void SetRar350Mode(bool rar350Mode) { _rar350Mode = rar350Mode; }
50 };
51 
52 }}
53 
54 #endif
55