16static const byte DEFLATE_METHOD = 8;
17static const byte FDICT_FLAG = (1 << 5);
21void ZlibCompressor::WritePrestreamHeader()
27 byte flags =
byte(GetCompressionLevel() << 6);
31void ZlibCompressor::ProcessUncompressedData(
const byte *inString,
size_t length)
33 m_adler32.
Update(inString, length);
36void ZlibCompressor::WritePoststreamTail()
39 m_adler32.
Final(adler32);
43unsigned int ZlibCompressor::GetCompressionLevel()
const
45 static const unsigned int deflateToCompressionLevel[] = {0, 1, 1, 1, 2, 2, 2, 2, 2, 3};
52 :
Inflator(attachment, repeat, propagation), m_log2WindowSize(0)
56void ZlibDecompressor::ProcessPrestreamHeader()
63 if (!m_inQueue.Get(cmf) || !m_inQueue.Get(flags))
66 if ((cmf*256+flags) % 31 != 0)
69 if ((cmf & 0xf) != DEFLATE_METHOD)
70 throw UnsupportedAlgorithm();
72 if (flags & FDICT_FLAG)
73 throw UnsupportedPresetDictionary();
75 m_log2WindowSize = 8 + (cmf >> 4);
78void ZlibDecompressor::ProcessDecompressedData(
const byte *inString,
size_t length)
81 m_adler32.
Update(inString, length);
84void ZlibDecompressor::ProcessPoststreamTail()
87 if (m_inQueue.Get(adler32, 4) != 4)
89 if (!m_adler32.
Verify(adler32))
void Update(const byte *input, size_t length)
Updates a hash with additional input.
int GetDeflateLevel() const
Retrieves the deflation level.
int GetLog2WindowSize() const
Retrieves the window size.
BufferedTransformation * AttachedTransformation()
Retrieve attached transformation.
Fixed size stack-based SecBlock.
DEFLATE decompressor (RFC 1951)
ZlibDecompressor(BufferedTransformation *attachment=NULL, bool repeat=false, int autoSignalPropagation=-1)
Construct a ZlibDecompressor.
unsigned char byte
8-bit unsigned datatype
unsigned short word16
16-bit unsigned datatype
T1 RoundUpToMultipleOf(const T1 &n, const T2 &m)
Rounds a value up to a multiple of a second value.
Crypto++ library namespace.
Classes and functions for secure memory allocations.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
DEFLATE compression and decompression (RFC 1951)
DEFLATE compression and decompression (RFC 1951)
ZLIB compression and decompression (RFC 1950)