Crypto++ 8.2
Free C&
zlib.h
1#ifndef CRYPTOPP_ZLIB_H
2#define CRYPTOPP_ZLIB_H
3
4#include "cryptlib.h"
5#include "adler32.h"
6#include "zdeflate.h"
7#include "zinflate.h"
8
9NAMESPACE_BEGIN(CryptoPP)
10
11/// ZLIB Compressor (RFC 1950)
13{
14public:
15 ZlibCompressor(BufferedTransformation *attachment=NULLPTR, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true)
16 : Deflator(attachment, deflateLevel, log2WindowSize, detectUncompressible) {}
17 ZlibCompressor(const NameValuePairs &parameters, BufferedTransformation *attachment=NULLPTR)
18 : Deflator(parameters, attachment) {}
19
20 unsigned int GetCompressionLevel() const;
21
22protected:
23 void WritePrestreamHeader();
24 void ProcessUncompressedData(const byte *string, size_t length);
25 void WritePoststreamTail();
26
27 Adler32 m_adler32;
28};
29
30/// ZLIB Decompressor (RFC 1950)
32{
33public:
34 typedef Inflator::Err Err;
35 class HeaderErr : public Err {public: HeaderErr() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: header decoding error") {}};
36 class Adler32Err : public Err {public: Adler32Err() : Err(DATA_INTEGRITY_CHECK_FAILED, "ZlibDecompressor: ADLER32 check error") {}};
37 class UnsupportedAlgorithm : public Err {public: UnsupportedAlgorithm() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported algorithm") {}};
38 class UnsupportedPresetDictionary : public Err {public: UnsupportedPresetDictionary() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported preset dictionary") {}};
39
40 /// \brief Construct a ZlibDecompressor
41 /// \param attachment a \ BufferedTransformation to attach to this object
42 /// \param repeat decompress multiple compressed streams in series
43 /// \param autoSignalPropagation 0 to turn off MessageEnd signal
44 ZlibDecompressor(BufferedTransformation *attachment = NULLPTR, bool repeat = false, int autoSignalPropagation = -1);
45 unsigned int GetLog2WindowSize() const {return m_log2WindowSize;}
46
47private:
48 unsigned int MaxPrestreamHeaderSize() const {return 2;}
49 void ProcessPrestreamHeader();
50 void ProcessDecompressedData(const byte *string, size_t length);
51 unsigned int MaxPoststreamTailSize() const {return 4;}
52 void ProcessPoststreamTail();
53
54 unsigned int m_log2WindowSize;
55 Adler32 m_adler32;
56};
57
58NAMESPACE_END
59
60#endif
Class file for ADLER-32 checksum calculations.
ADLER-32 checksum calculations.
Definition: adler32.h:15
Interface for buffered transformations.
Definition: cryptlib.h:1599
DEFLATE compressor (RFC 1951)
Definition: zdeflate.h:76
@ INVALID_DATA_FORMAT
Input data was received that did not conform to expected format.
Definition: cryptlib.h:173
@ DATA_INTEGRITY_CHECK_FAILED
Data integerity check, such as CRC or MAC, failed.
Definition: cryptlib.h:171
DEFLATE decompressor (RFC 1951)
Definition: zinflate.h:90
Interface for retrieving values given their names.
Definition: cryptlib.h:294
ZLIB Compressor (RFC 1950)
Definition: zlib.h:13
ZLIB Decompressor (RFC 1950)
Definition: zlib.h:32
Abstract base classes that provide a uniform interface to this library.
Crypto++ library namespace.
DEFLATE compression and decompression (RFC 1951)