Botan 3.6.1
Crypto and TLS for C&
Botan::Deflate_Compression Class Referencefinal

#include <zlib.h>

Inheritance diagram for Botan::Deflate_Compression:
Botan::Stream_Compression Botan::Compression_Algorithm

Public Member Functions

void clear () final
 
void finish (secure_vector< uint8_t > &buf, size_t offset) final
 
std::string name () const override
 
void update (secure_vector< uint8_t > &buf, size_t offset, bool flush) final
 

Static Public Member Functions

static std::unique_ptr< Compression_Algorithmcreate (std::string_view algo_spec)
 
static std::unique_ptr< Compression_Algorithmcreate_or_throw (std::string_view algo_spec)
 

Detailed Description

Deflate Compression

Definition at line 41 of file zlib.h.

Member Function Documentation

◆ clear()

void Botan::Stream_Compression::clear ( )
finalvirtualinherited

Reset the state and abort the current message; start can be called again to process a new message.

Implements Botan::Compression_Algorithm.

Definition at line 59 of file compress_utils.cpp.

59 {
60 m_stream.reset();
61}

Referenced by Botan::Stream_Compression::finish().

◆ create()

std::unique_ptr< Compression_Algorithm > Botan::Compression_Algorithm::create ( std::string_view algo_spec)
staticinherited

Create an instance based on a name, or return null if the algo combination cannot be found.

Definition at line 29 of file compression.cpp.

29 {
30#if defined(BOTAN_HAS_ZLIB)
31 if(name == "Zlib" || name == "zlib") {
32 return std::make_unique<Zlib_Compression>();
33 }
34 if(name == "Gzip" || name == "gzip" || name == "gz") {
35 return std::make_unique<Gzip_Compression>();
36 }
37 if(name == "Deflate" || name == "deflate") {
38 return std::make_unique<Deflate_Compression>();
39 }
40#endif
41
42#if defined(BOTAN_HAS_BZIP2)
43 if(name == "bzip2" || name == "bz2" || name == "Bzip2") {
44 return std::make_unique<Bzip2_Compression>();
45 }
46#endif
47
48#if defined(BOTAN_HAS_LZMA)
49 if(name == "lzma" || name == "xz" || name == "LZMA") {
50 return std::make_unique<LZMA_Compression>();
51 }
52#endif
53
55 return nullptr;
56}
#define BOTAN_UNUSED
Definition assert.h:118
virtual std::string name() const =0

References BOTAN_UNUSED, and Botan::Compression_Algorithm::name().

Referenced by Botan::Compression_Algorithm::create_or_throw(), and Botan::make_compressor().

◆ create_or_throw()

std::unique_ptr< Compression_Algorithm > Botan::Compression_Algorithm::create_or_throw ( std::string_view algo_spec)
staticinherited

Create an instance based on a name

Parameters
algo_specalgorithm name Throws Lookup_Error if not found.

Definition at line 59 of file compression.cpp.

59 {
60 if(auto compressor = Compression_Algorithm::create(algo)) {
61 return compressor;
62 }
63 throw Lookup_Error("Compression", algo, "");
64}
static std::unique_ptr< Compression_Algorithm > create(std::string_view algo_spec)

References Botan::Compression_Algorithm::create().

◆ finish()

void Botan::Stream_Compression::finish ( secure_vector< uint8_t > & final_block,
size_t offset )
finalvirtualinherited

Finish compressing

The buf and offset parameters are treated as in update(). It is acceptable to call start() followed by finish() with the entire message, without any intervening call to update().

Parameters
final_blockin/out parameter
offsetan offset into final_block to begin processing

Implements Botan::Compression_Algorithm.

Definition at line 118 of file compress_utils.cpp.

118 {
119 BOTAN_ASSERT(m_stream, "Initialized");
120 process(buf, offset, m_stream->finish_flag());
121 clear();
122}
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:50

References BOTAN_ASSERT, and Botan::Stream_Compression::clear().

◆ name()

std::string Botan::Deflate_Compression::name ( ) const
inlineoverridevirtual
Returns
name of the compression algorithm

Implements Botan::Compression_Algorithm.

Definition at line 43 of file zlib.h.

43{ return "Deflate_Compression"; }

◆ update()

void Botan::Stream_Compression::update ( secure_vector< uint8_t > & buf,
size_t offset,
bool flush )
finalvirtualinherited

Process some data.

The leading offset bytes of buf are ignored and remain untouched; this can be useful for ignoring packet headers. If flush is true, the compression state is flushed, allowing the decompressor to recover the entire message up to this point without having to see the rest of the compressed stream.

Parameters
bufin/out parameter which will possibly be resized or swapped
offsetan offset into blocks to begin processing
flushif true the compressor will be told to flush state

Implements Botan::Compression_Algorithm.

Definition at line 113 of file compress_utils.cpp.

113 {
114 BOTAN_ASSERT(m_stream, "Initialized");
115 process(buf, offset, flush ? m_stream->flush_flag() : m_stream->run_flag());
116}

References BOTAN_ASSERT.


The documentation for this class was generated from the following files: