Crypto++ 8.1 Free C++ class library of cryptographic schemes

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
9 NAMESPACE_BEGIN(CryptoPP)
10
11 /// ZLIB Compressor (RFC 1950)
12 class ZlibCompressor : public Deflator
13 {
14 public:
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
22 protected:
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)
31 class ZlibDecompressor : public Inflator
32 {
33 public:
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
47 private:
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
58 NAMESPACE_END
59
60 #endif
ZlibDecompressor::ZlibDecompressor
ZlibDecompressor(BufferedTransformation *attachment=NULL, bool repeat=false, int autoSignalPropagation=-1)
Construct a ZlibDecompressor.
Definition: zlib.cpp:51
ZlibDecompressor::Adler32Err
Definition: zlib.h:36
cryptlib.h
Abstract base classes that provide a uniform interface to this library.
Deflator
DEFLATE compressor (RFC 1951)
Definition: zdeflate.h:75
ZlibDecompressor::UnsupportedAlgorithm
Definition: zlib.h:37
Inflator::Err
Definition: zinflate.h:92
BufferedTransformation
Interface for buffered transformations.
Definition: cryptlib.h:1598
zdeflate.h
DEFLATE compression and decompression (RFC 1951)
Exception::DATA_INTEGRITY_CHECK_FAILED
Data integerity check, such as CRC or MAC, failed.
Definition: cryptlib.h:171
Adler32
ADLER-32 checksum calculations.
Definition: adler32.h:14
Exception::INVALID_DATA_FORMAT
Input data was received that did not conform to expected format.
Definition: cryptlib.h:173
ZlibCompressor
ZLIB Compressor (RFC 1950)
Definition: zlib.h:12
ZlibDecompressor::HeaderErr
Definition: zlib.h:35
ZlibDecompressor
ZLIB Decompressor (RFC 1950)
Definition: zlib.h:31
adler32.h
Class file for ADLER-32 checksum calculations.
Inflator
DEFLATE decompressor (RFC 1951)
Definition: zinflate.h:89
ZlibDecompressor::UnsupportedPresetDictionary
Definition: zlib.h:38
CryptoPP
Crypto++ library namespace.
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:293