File indexing completed on 2025-01-18 09:55:11
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_ZLIB_H
0007 #define CRYPTOPP_ZLIB_H
0008
0009 #include "cryptlib.h"
0010 #include "adler32.h"
0011 #include "zdeflate.h"
0012 #include "zinflate.h"
0013
0014 NAMESPACE_BEGIN(CryptoPP)
0015
0016
0017 class ZlibCompressor : public Deflator
0018 {
0019 public:
0020 ZlibCompressor(BufferedTransformation *attachment=NULLPTR, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true)
0021 : Deflator(attachment, deflateLevel, log2WindowSize, detectUncompressible) {}
0022 ZlibCompressor(const NameValuePairs ¶meters, BufferedTransformation *attachment=NULLPTR)
0023 : Deflator(parameters, attachment) {}
0024
0025 unsigned int GetCompressionLevel() const;
0026
0027 protected:
0028 void WritePrestreamHeader();
0029 void ProcessUncompressedData(const byte *string, size_t length);
0030 void WritePoststreamTail();
0031
0032 Adler32 m_adler32;
0033 };
0034
0035
0036 class ZlibDecompressor : public Inflator
0037 {
0038 public:
0039 typedef Inflator::Err Err;
0040 class HeaderErr : public Err {public: HeaderErr() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: header decoding error") {}};
0041 class Adler32Err : public Err {public: Adler32Err() : Err(DATA_INTEGRITY_CHECK_FAILED, "ZlibDecompressor: ADLER32 check error") {}};
0042 class UnsupportedAlgorithm : public Err {public: UnsupportedAlgorithm() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported algorithm") {}};
0043 class UnsupportedPresetDictionary : public Err {public: UnsupportedPresetDictionary() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported preset dictionary") {}};
0044
0045
0046
0047
0048
0049 ZlibDecompressor(BufferedTransformation *attachment = NULLPTR, bool repeat = false, int autoSignalPropagation = -1);
0050 unsigned int GetLog2WindowSize() const {return m_log2WindowSize;}
0051
0052 private:
0053 unsigned int MaxPrestreamHeaderSize() const {return 2;}
0054 void ProcessPrestreamHeader();
0055 void ProcessDecompressedData(const byte *string, size_t length);
0056 unsigned int MaxPoststreamTailSize() const {return 4;}
0057 void ProcessPoststreamTail();
0058
0059 unsigned int m_log2WindowSize;
0060 Adler32 m_adler32;
0061 };
0062
0063 NAMESPACE_END
0064
0065 #endif