Imported Upstream version 9.20
[platform/upstream/7zip.git] / CPP / 7zip / Crypto / ZipStrong.h
1 // Crypto/ZipStrong.h\r
2 \r
3 #ifndef __CRYPTO_ZIP_STRONG_H\r
4 #define __CRYPTO_ZIP_STRONG_H\r
5 \r
6 #include "Common/Buffer.h"\r
7 \r
8 #include "../IPassword.h"\r
9 \r
10 #include "MyAes.h"\r
11 \r
12 namespace NCrypto {\r
13 namespace NZipStrong {\r
14 \r
15 struct CKeyInfo\r
16 {\r
17   Byte MasterKey[32];\r
18   UInt32 KeySize;\r
19   void SetPassword(const Byte *data, UInt32 size);\r
20 };\r
21 \r
22 class CBaseCoder:\r
23   public CAesCbcDecoder,\r
24   public ICryptoSetPassword\r
25 {\r
26 protected:\r
27   CKeyInfo _key;\r
28   CByteBuffer _buf;\r
29   Byte *_bufAligned;\r
30 public:\r
31   STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);\r
32 };\r
33 \r
34 class CDecoder: public CBaseCoder\r
35 {\r
36   UInt32 _ivSize;\r
37   Byte _iv[16];\r
38   UInt32 _remSize;\r
39 public:\r
40   MY_UNKNOWN_IMP1(ICryptoSetPassword)\r
41   HRESULT ReadHeader(ISequentialInStream *inStream, UInt32 crc, UInt64 unpackSize);\r
42   HRESULT CheckPassword(bool &passwOK);\r
43 };\r
44 \r
45 }}\r
46 \r
47 #endif\r