aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/compression
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/compression
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/compression')
-rw-r--r--src/lib/compression/bzip2/bzip2.cpp10
-rw-r--r--src/lib/compression/compress_utils.cpp12
-rw-r--r--src/lib/compression/compress_utils.h4
-rw-r--r--src/lib/compression/compression.h40
-rw-r--r--src/lib/compression/lzma/lzma.cpp10
-rw-r--r--src/lib/compression/zlib/zlib.cpp12
-rw-r--r--src/lib/compression/zlib/zlib.h4
7 files changed, 46 insertions, 46 deletions
diff --git a/src/lib/compression/bzip2/bzip2.cpp b/src/lib/compression/bzip2/bzip2.cpp
index 1d1af7e29..4ebf572c9 100644
--- a/src/lib/compression/bzip2/bzip2.cpp
+++ b/src/lib/compression/bzip2/bzip2.cpp
@@ -28,9 +28,9 @@ class Bzip2_Stream : public Zlib_Style_Stream<bz_stream, char>
streamp()->bzfree = Compression_Alloc_Info::free;
}
- u32bit run_flag() const override { return BZ_RUN; }
- u32bit flush_flag() const override { return BZ_FLUSH; }
- u32bit finish_flag() const override { return BZ_FINISH; }
+ uint32_t run_flag() const override { return BZ_RUN; }
+ uint32_t flush_flag() const override { return BZ_FLUSH; }
+ uint32_t finish_flag() const override { return BZ_FINISH; }
};
class Bzip2_Compression_Stream : public Bzip2_Stream
@@ -59,7 +59,7 @@ class Bzip2_Compression_Stream : public Bzip2_Stream
BZ2_bzCompressEnd(streamp());
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
int rc = BZ2_bzCompress(streamp(), flags);
@@ -90,7 +90,7 @@ class Bzip2_Decompression_Stream : public Bzip2_Stream
BZ2_bzDecompressEnd(streamp());
}
- bool run(u32bit) override
+ bool run(uint32_t) override
{
int rc = BZ2_bzDecompress(streamp());
diff --git a/src/lib/compression/compress_utils.cpp b/src/lib/compression/compress_utils.cpp
index 65361fba8..06e7fea53 100644
--- a/src/lib/compression/compress_utils.cpp
+++ b/src/lib/compression/compress_utils.cpp
@@ -62,7 +62,7 @@ void Stream_Compression::start(size_t level)
m_stream.reset(make_stream(level));
}
-void Stream_Compression::process(secure_vector<byte>& buf, size_t offset, u32bit flags)
+void Stream_Compression::process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags)
{
BOTAN_ASSERT(m_stream, "Initialized");
BOTAN_ASSERT(buf.size() >= offset, "Offset is sane");
@@ -102,13 +102,13 @@ void Stream_Compression::process(secure_vector<byte>& buf, size_t offset, u32bit
buf.swap(m_buffer);
}
-void Stream_Compression::update(secure_vector<byte>& buf, size_t offset, bool flush)
+void Stream_Compression::update(secure_vector<uint8_t>& buf, size_t offset, bool flush)
{
BOTAN_ASSERT(m_stream, "Initialized");
process(buf, offset, flush ? m_stream->flush_flag() : m_stream->run_flag());
}
-void Stream_Compression::finish(secure_vector<byte>& buf, size_t offset)
+void Stream_Compression::finish(secure_vector<uint8_t>& buf, size_t offset)
{
BOTAN_ASSERT(m_stream, "Initialized");
process(buf, offset, m_stream->finish_flag());
@@ -125,7 +125,7 @@ void Stream_Decompression::start()
m_stream.reset(make_stream());
}
-void Stream_Decompression::process(secure_vector<byte>& buf, size_t offset, u32bit flags)
+void Stream_Decompression::process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags)
{
BOTAN_ASSERT(m_stream, "Initialized");
BOTAN_ASSERT(buf.size() >= offset, "Offset is sane");
@@ -172,12 +172,12 @@ void Stream_Decompression::process(secure_vector<byte>& buf, size_t offset, u32b
buf.swap(m_buffer);
}
-void Stream_Decompression::update(secure_vector<byte>& buf, size_t offset)
+void Stream_Decompression::update(secure_vector<uint8_t>& buf, size_t offset)
{
process(buf, offset, m_stream->run_flag());
}
-void Stream_Decompression::finish(secure_vector<byte>& buf, size_t offset)
+void Stream_Decompression::finish(secure_vector<uint8_t>& buf, size_t offset)
{
if(buf.size() != offset || m_stream.get())
process(buf, offset, m_stream->finish_flag());
diff --git a/src/lib/compression/compress_utils.h b/src/lib/compression/compress_utils.h
index 9f6871a0b..a34faef69 100644
--- a/src/lib/compression/compress_utils.h
+++ b/src/lib/compression/compress_utils.h
@@ -45,13 +45,13 @@ template<typename Stream, typename ByteType>
class Zlib_Style_Stream : public Compression_Stream
{
public:
- void next_in(byte* b, size_t len) override
+ void next_in(uint8_t* b, size_t len) override
{
m_stream.next_in = reinterpret_cast<ByteType*>(b);
m_stream.avail_in = len;
}
- void next_out(byte* b, size_t len) override
+ void next_out(uint8_t* b, size_t len) override
{
m_stream.next_out = reinterpret_cast<ByteType*>(b);
m_stream.avail_out = len;
diff --git a/src/lib/compression/compression.h b/src/lib/compression/compression.h
index 1c429195c..ad5ed45c5 100644
--- a/src/lib/compression/compression.h
+++ b/src/lib/compression/compression.h
@@ -30,12 +30,12 @@ class BOTAN_DLL Compression_Algorithm
virtual void start(size_t comp_level = 0) = 0;
/**
- * Process some data. Input must be in size update_granularity() byte blocks.
+ * Process some data. Input must be in size update_granularity() uint8_t blocks.
* @param buf in/out parameter which will possibly be resized or swapped
* @param offset an offset into blocks to begin processing
* @param flush if true the compressor will be told to flush state
*/
- virtual void update(secure_vector<byte>& buf, size_t offset = 0, bool flush = false) = 0;
+ virtual void update(secure_vector<uint8_t>& buf, size_t offset = 0, bool flush = false) = 0;
/**
* Finish compressing
@@ -43,7 +43,7 @@ class BOTAN_DLL Compression_Algorithm
* @param final_block in/out parameter
* @param offset an offset into final_block to begin processing
*/
- virtual void finish(secure_vector<byte>& final_block, size_t offset = 0) = 0;
+ virtual void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) = 0;
/**
* @return name of the compression algorithm
@@ -72,11 +72,11 @@ class BOTAN_DLL Decompression_Algorithm
virtual void start() = 0;
/**
- * Process some data. Input must be in size update_granularity() byte blocks.
+ * Process some data. Input must be in size update_granularity() uint8_t blocks.
* @param buf in/out parameter which will possibly be resized or swapped
* @param offset an offset into blocks to begin processing
*/
- virtual void update(secure_vector<byte>& buf, size_t offset = 0) = 0;
+ virtual void update(secure_vector<uint8_t>& buf, size_t offset = 0) = 0;
/**
* Finish decompressing
@@ -84,7 +84,7 @@ class BOTAN_DLL Decompression_Algorithm
* @param final_block in/out parameter
* @param offset an offset into final_block to begin processing
*/
- virtual void finish(secure_vector<byte>& final_block, size_t offset = 0) = 0;
+ virtual void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) = 0;
/**
* @return name of the decompression algorithm
@@ -111,19 +111,19 @@ class Compression_Stream
public:
virtual ~Compression_Stream() {}
- virtual void next_in(byte* b, size_t len) = 0;
+ virtual void next_in(uint8_t* b, size_t len) = 0;
- virtual void next_out(byte* b, size_t len) = 0;
+ virtual void next_out(uint8_t* b, size_t len) = 0;
virtual size_t avail_in() const = 0;
virtual size_t avail_out() const = 0;
- virtual u32bit run_flag() const = 0;
- virtual u32bit flush_flag() const = 0;
- virtual u32bit finish_flag() const = 0;
+ virtual uint32_t run_flag() const = 0;
+ virtual uint32_t flush_flag() const = 0;
+ virtual uint32_t finish_flag() const = 0;
- virtual bool run(u32bit flags) = 0;
+ virtual bool run(uint32_t flags) = 0;
};
/**
@@ -132,20 +132,20 @@ class Compression_Stream
class Stream_Compression : public Compression_Algorithm
{
public:
- void update(secure_vector<byte>& buf, size_t offset, bool flush) final override;
+ void update(secure_vector<uint8_t>& buf, size_t offset, bool flush) final override;
- void finish(secure_vector<byte>& buf, size_t offset) final override;
+ void finish(secure_vector<uint8_t>& buf, size_t offset) final override;
void clear() final override;
private:
void start(size_t level) final override;
- void process(secure_vector<byte>& buf, size_t offset, u32bit flags);
+ void process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags);
virtual Compression_Stream* make_stream(size_t level) const = 0;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
std::unique_ptr<Compression_Stream> m_stream;
};
@@ -155,20 +155,20 @@ class Stream_Compression : public Compression_Algorithm
class Stream_Decompression : public Decompression_Algorithm
{
public:
- void update(secure_vector<byte>& buf, size_t offset) final override;
+ void update(secure_vector<uint8_t>& buf, size_t offset) final override;
- void finish(secure_vector<byte>& buf, size_t offset) final override;
+ void finish(secure_vector<uint8_t>& buf, size_t offset) final override;
void clear() final override;
private:
void start() final override;
- void process(secure_vector<byte>& buf, size_t offset, u32bit flags);
+ void process(secure_vector<uint8_t>& buf, size_t offset, uint32_t flags);
virtual Compression_Stream* make_stream() const = 0;
- secure_vector<byte> m_buffer;
+ secure_vector<uint8_t> m_buffer;
std::unique_ptr<Compression_Stream> m_stream;
};
diff --git a/src/lib/compression/lzma/lzma.cpp b/src/lib/compression/lzma/lzma.cpp
index 3831ef68c..44af1ee67 100644
--- a/src/lib/compression/lzma/lzma.cpp
+++ b/src/lib/compression/lzma/lzma.cpp
@@ -17,7 +17,7 @@ namespace Botan {
namespace {
-class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
+class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, uint8_t>
{
public:
LZMA_Stream()
@@ -35,7 +35,7 @@ class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
delete streamp()->allocator;
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
lzma_ret rc = ::lzma_code(streamp(), static_cast<lzma_action>(flags));
@@ -47,9 +47,9 @@ class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
return (rc == LZMA_STREAM_END);
}
- u32bit run_flag() const override { return LZMA_RUN; }
- u32bit flush_flag() const override { return LZMA_FULL_FLUSH; }
- u32bit finish_flag() const override { return LZMA_FINISH; }
+ uint32_t run_flag() const override { return LZMA_RUN; }
+ uint32_t flush_flag() const override { return LZMA_FULL_FLUSH; }
+ uint32_t finish_flag() const override { return LZMA_FINISH; }
};
class LZMA_Compression_Stream : public LZMA_Stream
diff --git a/src/lib/compression/zlib/zlib.cpp b/src/lib/compression/zlib/zlib.cpp
index 27ae6fb20..2bfd22928 100644
--- a/src/lib/compression/zlib/zlib.cpp
+++ b/src/lib/compression/zlib/zlib.cpp
@@ -27,9 +27,9 @@ class Zlib_Stream : public Zlib_Style_Stream<z_stream, Bytef>
streamp()->zfree = Compression_Alloc_Info::free;
}
- u32bit run_flag() const override { return Z_NO_FLUSH; }
- u32bit flush_flag() const override { return Z_SYNC_FLUSH; }
- u32bit finish_flag() const override { return Z_FINISH; }
+ uint32_t run_flag() const override { return Z_NO_FLUSH; }
+ uint32_t flush_flag() const override { return Z_SYNC_FLUSH; }
+ uint32_t finish_flag() const override { return Z_FINISH; }
int compute_window_bits(int wbits, int wbits_offset) const
{
@@ -63,7 +63,7 @@ class Zlib_Compression_Stream : public Zlib_Stream
::deflateEnd(streamp());
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
int rc = ::deflate(streamp(), flags);
@@ -94,7 +94,7 @@ class Zlib_Decompression_Stream : public Zlib_Stream
::inflateEnd(streamp());
}
- bool run(u32bit flags) override
+ bool run(uint32_t flags) override
{
int rc = ::inflate(streamp(), flags);
@@ -123,7 +123,7 @@ class Deflate_Decompression_Stream : public Zlib_Decompression_Stream
class Gzip_Compression_Stream : public Zlib_Compression_Stream
{
public:
- Gzip_Compression_Stream(size_t level, int wbits, byte os_code) :
+ Gzip_Compression_Stream(size_t level, int wbits, uint8_t os_code) :
Zlib_Compression_Stream(level, wbits, 16)
{
clear_mem(&m_header, 1);
diff --git a/src/lib/compression/zlib/zlib.h b/src/lib/compression/zlib/zlib.h
index 0cedb1eab..a2cae34f4 100644
--- a/src/lib/compression/zlib/zlib.h
+++ b/src/lib/compression/zlib/zlib.h
@@ -63,12 +63,12 @@ class BOTAN_DLL Deflate_Decompression final : public Stream_Decompression
class BOTAN_DLL Gzip_Compression final : public Stream_Compression
{
public:
- Gzip_Compression(byte os_code = 255) : m_os_code(os_code) {}
+ Gzip_Compression(uint8_t os_code = 255) : m_os_code(os_code) {}
std::string name() const override { return "Gzip_Compression"; }
private:
Compression_Stream* make_stream(size_t level) const override;
- const byte m_os_code;
+ const uint8_t m_os_code;
};
/**