ZipCryptograph.h
Go to the documentation of this file.
1 
2 // This source file is part of the ZipArchive Library Open Source distribution
3 // and is Copyrighted 2000 - 2022 by Artpol Software - Tadeusz Dracz
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // For the licensing details refer to the License.txt file.
11 //
12 // Web Site: https://www.artpol-software.com
14 
21 #if !defined(ZIPARCHIVE_ZIPCRYPTOGRAPH_DOT_H)
22 #define ZIPARCHIVE_ZIPCRYPTOGRAPH_DOT_H
23 
24 #if _MSC_VER > 1000
25  #pragma once
26  #pragma warning( push )
27  #pragma warning (disable : 4100) // unreferenced formal parameter
28 #endif // _MSC_VER > 1000
29 
30 #include "ZipAutoBuffer.h"
31 #include "ZipStorage.h"
32 
33 class CZipFileHeader;
34 
41 class ZIP_API CZipCryptograph
42 {
43 public:
44 
52  {
57  encNone = 0xFF
58  };
59 
70  static CZipCryptograph* CreateCryptograph(int iEncryptionMethod);
71 
81  static bool IsWinZipAesEncryption(int iEncryptionMethod)
82  {
83  return iEncryptionMethod == encWinZipAes128 || iEncryptionMethod == encWinZipAes192 || iEncryptionMethod == encWinZipAes256;
84  }
85 
96  static DWORD GetEncryptedInfoSize(int iEncryptionMethod);
97 
108  static DWORD GetEncryptedInfoSizeBeforeData(int iEncryptionMethod);
109 
120  static DWORD GetEncryptedInfoSizeAfterData(int iEncryptionMethod);
121 
131  static bool IsEncryptionSupported(int iEncryptionMethod)
132  {
133  return iEncryptionMethod == encStandard;
134  }
135 
154  virtual bool InitDecode(CZipAutoBuffer& password, CZipFileHeader& currentFile, CZipStorage& storage, bool ignoreCheck) = 0;
155 
168  virtual void InitEncode(CZipAutoBuffer& password, CZipFileHeader& currentFile, CZipStorage& storage) = 0;
169 
179  virtual void Decode(char* pBuffer, DWORD uSize) = 0;
180 
190  virtual void Encode(char* pBuffer, DWORD uSize) = 0;
191 
201  virtual void FinishDecode(CZipFileHeader& currentFile, CZipStorage& storage){};
202 
212  virtual void FinishEncode(CZipFileHeader& currentFile, CZipStorage& storage){};
213 
223  virtual bool CanHandle(int iEncryptionMethod)
224  {
225  return false;
226  }
227  virtual ~CZipCryptograph(){}
228 };
229 
230 #if _MSC_VER > 1000
231  #pragma warning( pop )
232 #endif // _MSC_VER > 1000
233 
234 #endif

The ZipArchive Library Copyright © 2000 - 2022 Artpol Software - Tadeusz Dracz. Generated at Sat Dec 17 2022 19:57:03.