diff options
author | lloyd <[email protected]> | 2010-10-12 19:51:32 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-12 19:51:32 +0000 |
commit | a85f136550c08fc878e3983866af0e6460e980da (patch) | |
tree | e495666a243affb92b8a1c5097d536b22c305580 | |
parent | ff2210b035a1598bf99e18a578ff075bece8fbe5 (diff) |
Use size_t in filters
This breaks API for anyone creating their own Filter types, but it had
to happen eventually.
59 files changed, 452 insertions, 450 deletions
diff --git a/checks/block.cpp b/checks/block.cpp index e3b871aa1..dc3350ce3 100644 --- a/checks/block.cpp +++ b/checks/block.cpp @@ -27,7 +27,7 @@ class ECB_Encryption_ErrorCheck : public Filter std::string name() const { return "ECB_ErrCheck(" + cipher->name() + ")"; } - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); @@ -61,7 +61,7 @@ class ECB_Encryption_ErrorCheck : public Filter HashFunction* input_hash, *decrypt_hash; }; -void ECB_Encryption_ErrorCheck::write(const byte input[], u32bit length) +void ECB_Encryption_ErrorCheck::write(const byte input[], size_t length) { input_hash->update(input, length); buffer.copy(position, input, length); diff --git a/checks/dolook.cpp b/checks/dolook.cpp index a20268332..1015f4240 100644 --- a/checks/dolook.cpp +++ b/checks/dolook.cpp @@ -65,7 +65,7 @@ class PBKDF_Filter : public Filter public: std::string name() const { return pbkdf->name(); } - void write(const byte in[], u32bit len) + void write(const byte in[], size_t len) { passphrase += std::string(reinterpret_cast<const char*>(in), len); } void end_msg() @@ -98,7 +98,7 @@ class RNG_Filter : public Filter public: std::string name() const { return rng->name(); } - void write(const byte[], u32bit); + void write(const byte[], size_t); RNG_Filter(RandomNumberGenerator* r) : rng(r) {} ~RNG_Filter() { delete rng; } @@ -111,7 +111,7 @@ class KDF_Filter : public Filter public: std::string name() const { return "KDF_Filter"; } - void write(const byte in[], u32bit len) + void write(const byte in[], size_t len) { secret += std::make_pair(in, len); } void end_msg() @@ -150,7 +150,7 @@ Filter* lookup_pbkdf(const std::string& algname, return 0; } -void RNG_Filter::write(const byte[], u32bit length) +void RNG_Filter::write(const byte[], size_t length) { if(length) { diff --git a/src/cms/cms_algo.cpp b/src/cms/cms_algo.cpp index 458e8e3f5..79faaed4f 100644 --- a/src/cms/cms_algo.cpp +++ b/src/cms/cms_algo.cpp @@ -33,7 +33,7 @@ SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng, public: std::string name() const { return "Fip_Bytes"; } - void write(const byte data[], u32bit length) + void write(const byte data[], size_t length) { buf += std::make_pair(data, length); } diff --git a/src/entropy/unix_procs/unix_cmd.cpp b/src/entropy/unix_procs/unix_cmd.cpp index c92c84b4c..f4ae5054c 100644 --- a/src/entropy/unix_procs/unix_cmd.cpp +++ b/src/entropy/unix_procs/unix_cmd.cpp @@ -26,14 +26,14 @@ namespace { void do_exec(const std::vector<std::string>& arg_list, const std::vector<std::string>& paths) { - const u32bit args = arg_list.size() - 1; + const size_t args = arg_list.size() - 1; const char* arg1 = (args >= 1) ? arg_list[1].c_str() : 0; const char* arg2 = (args >= 2) ? arg_list[2].c_str() : 0; const char* arg3 = (args >= 3) ? arg_list[3].c_str() : 0; const char* arg4 = (args >= 4) ? arg_list[4].c_str() : 0; - for(u32bit j = 0; j != paths.size(); j++) + for(size_t j = 0; j != paths.size(); j++) { const std::string full_path = paths[j] + "/" + arg_list[0]; const char* fsname = full_path.c_str(); @@ -59,7 +59,7 @@ struct pipe_wrapper /** * Read from the pipe */ -u32bit DataSource_Command::read(byte buf[], u32bit length) +size_t DataSource_Command::read(byte buf[], size_t length) { if(end_of_data()) return 0; @@ -85,13 +85,13 @@ u32bit DataSource_Command::read(byte buf[], u32bit length) return 0; } - return static_cast<u32bit>(got); + return static_cast<size_t>(got); } /** * Peek at the pipe contents */ -u32bit DataSource_Command::peek(byte[], u32bit, u32bit) const +size_t DataSource_Command::peek(byte[], size_t, size_t) const { if(end_of_data()) throw Invalid_State("DataSource_Command: Cannot peek when out of data"); @@ -130,7 +130,8 @@ std::string DataSource_Command::id() const void DataSource_Command::create_pipe(const std::vector<std::string>& paths) { bool found_something = false; - for(u32bit j = 0; j != paths.size(); j++) + + for(size_t j = 0; j != paths.size(); j++) { const std::string full_path = paths[j] + "/" + arg_list[0]; if(::access(full_path.c_str(), X_OK) == 0) @@ -139,6 +140,7 @@ void DataSource_Command::create_pipe(const std::vector<std::string>& paths) break; } } + if(!found_something) return; diff --git a/src/entropy/unix_procs/unix_cmd.h b/src/entropy/unix_procs/unix_cmd.h index 2dc55f6d7..a4ad0c180 100644 --- a/src/entropy/unix_procs/unix_cmd.h +++ b/src/entropy/unix_procs/unix_cmd.h @@ -49,8 +49,8 @@ struct Unix_Program class DataSource_Command : public DataSource { public: - u32bit read(byte[], u32bit); - u32bit peek(byte[], u32bit, u32bit) const; + size_t read(byte[], size_t); + size_t peek(byte[], size_t, size_t) const; bool end_of_data() const; std::string id() const; diff --git a/src/filters/algo_filt.cpp b/src/filters/algo_filt.cpp index 4407fc892..337733b5f 100644 --- a/src/filters/algo_filt.cpp +++ b/src/filters/algo_filt.cpp @@ -64,11 +64,11 @@ void StreamCipher_Filter::set_iv(const InitializationVector& iv) /* * Write data into a StreamCipher_Filter */ -void StreamCipher_Filter::write(const byte input[], u32bit length) +void StreamCipher_Filter::write(const byte input[], size_t length) { while(length) { - u32bit copied = std::min<u32bit>(length, buffer.size()); + size_t copied = std::min<size_t>(length, buffer.size()); cipher->cipher(input, &buffer[0], copied); send(buffer, copied); input += copied; @@ -80,7 +80,7 @@ void StreamCipher_Filter::write(const byte input[], u32bit length) * Hash_Filter Constructor */ Hash_Filter::Hash_Filter(const std::string& algo_spec, - u32bit len) : + size_t len) : OUTPUT_LENGTH(len) { Algorithm_Factory& af = global_state().algorithm_factory(); @@ -94,7 +94,7 @@ void Hash_Filter::end_msg() { SecureVector<byte> output = hash->final(); if(OUTPUT_LENGTH) - send(output, std::min<u32bit>(OUTPUT_LENGTH, output.size())); + send(output, std::min<size_t>(OUTPUT_LENGTH, output.size())); else send(output); } @@ -102,7 +102,7 @@ void Hash_Filter::end_msg() /* * MAC_Filter Constructor */ -MAC_Filter::MAC_Filter(const std::string& mac_name, u32bit len) : +MAC_Filter::MAC_Filter(const std::string& mac_name, size_t len) : OUTPUT_LENGTH(len) { Algorithm_Factory& af = global_state().algorithm_factory(); @@ -113,7 +113,7 @@ MAC_Filter::MAC_Filter(const std::string& mac_name, u32bit len) : * MAC_Filter Constructor */ MAC_Filter::MAC_Filter(const std::string& mac_name, const SymmetricKey& key, - u32bit len) : OUTPUT_LENGTH(len) + size_t len) : OUTPUT_LENGTH(len) { Algorithm_Factory& af = global_state().algorithm_factory(); mac = af.make_mac(mac_name); @@ -127,7 +127,7 @@ void MAC_Filter::end_msg() { SecureVector<byte> output = mac->final(); if(OUTPUT_LENGTH) - send(output, std::min<u32bit>(OUTPUT_LENGTH, output.size())); + send(output, std::min<size_t>(OUTPUT_LENGTH, output.size())); else send(output); } diff --git a/src/filters/base64/base64.cpp b/src/filters/base64/base64.cpp index 134e42dd6..04883ed79 100644 --- a/src/filters/base64/base64.cpp +++ b/src/filters/base64/base64.cpp @@ -15,7 +15,7 @@ namespace Botan { /* * Base64_Encoder Constructor */ -Base64_Encoder::Base64_Encoder(bool breaks, u32bit length, bool t_n) : +Base64_Encoder::Base64_Encoder(bool breaks, size_t length, bool t_n) : line_length(breaks ? length : 0), trailing_newline(t_n) { in.resize(48); @@ -38,9 +38,9 @@ void Base64_Encoder::encode(const byte in[3], byte out[4]) /* * Encode and send a block */ -void Base64_Encoder::encode_and_send(const byte block[], u32bit length) +void Base64_Encoder::encode_and_send(const byte block[], size_t length) { - for(u32bit j = 0; j != length; j += 3) + for(size_t j = 0; j != length; j += 3) { encode(block + j, &out[0]); do_output(&out[0], 4); @@ -50,16 +50,16 @@ void Base64_Encoder::encode_and_send(const byte block[], u32bit length) /* * Handle the output */ -void Base64_Encoder::do_output(const byte input[], u32bit length) +void Base64_Encoder::do_output(const byte input[], size_t length) { if(line_length == 0) send(input, length); else { - u32bit remaining = length, offset = 0; + size_t remaining = length, offset = 0; while(remaining) { - u32bit sent = std::min(line_length - counter, remaining); + size_t sent = std::min(line_length - counter, remaining); send(input + offset, sent); counter += sent; remaining -= sent; @@ -76,7 +76,7 @@ void Base64_Encoder::do_output(const byte input[], u32bit length) /* * Convert some data into Base64 */ -void Base64_Encoder::write(const byte input[], u32bit length) +void Base64_Encoder::write(const byte input[], size_t length) { in.copy(position, input, length); if(position + length >= in.size()) @@ -101,7 +101,7 @@ void Base64_Encoder::write(const byte input[], u32bit length) */ void Base64_Encoder::end_msg() { - u32bit start_of_last_block = 3 * (position / 3), + size_t start_of_last_block = 3 * (position / 3), left_over = position % 3; encode_and_send(&in[0], start_of_last_block); @@ -112,7 +112,7 @@ void Base64_Encoder::end_msg() encode(&remainder[0], &out[0]); - u32bit empty_bits = 8 * (3 - left_over), index = 4 - 1; + size_t empty_bits = 8 * (3 - left_over), index = 4 - 1; while(empty_bits >= 8) { out[index--] = '='; @@ -159,9 +159,9 @@ void Base64_Decoder::decode(const byte in[4], byte out[3]) /* * Decode and send a block */ -void Base64_Decoder::decode_and_send(const byte block[], u32bit length) +void Base64_Decoder::decode_and_send(const byte block[], size_t length) { - for(u32bit j = 0; j != length; j += 4) + for(size_t j = 0; j != length; j += 4) { decode(block + j, &out[0]); send(out, 3); @@ -188,9 +188,9 @@ void Base64_Decoder::handle_bad_char(byte c) /* * Convert some data from Base64 */ -void Base64_Decoder::write(const byte input[], u32bit length) +void Base64_Decoder::write(const byte input[], size_t length) { - for(u32bit j = 0; j != length; ++j) + for(size_t j = 0; j != length; ++j) { if(is_valid(input[j])) in[position++] = input[j]; @@ -212,7 +212,7 @@ void Base64_Decoder::end_msg() { if(position != 0) { - u32bit start_of_last_block = 4 * (position / 4), + size_t start_of_last_block = 4 * (position / 4), left_over = position % 4; decode_and_send(&in[0], start_of_last_block); diff --git a/src/filters/base64/base64.h b/src/filters/base64/base64.h index 0f35859cc..ae5fa26ce 100644 --- a/src/filters/base64/base64.h +++ b/src/filters/base64/base64.h @@ -27,7 +27,7 @@ class BOTAN_DLL Base64_Encoder : public Filter * @param input the message to input as a byte array * @param length the length of the byte array input */ - void write(const byte input[], u32bit length); + void write(const byte input[], size_t length); /** * Inform the Encoder that the current message shall be closed. @@ -40,17 +40,17 @@ class BOTAN_DLL Base64_Encoder : public Filter * @param length the length of the lines of the output * @param t_n whether to use a trailing newline */ - Base64_Encoder(bool breaks = false, u32bit length = 72, + Base64_Encoder(bool breaks = false, size_t length = 72, bool t_n = false); private: - void encode_and_send(const byte[], u32bit); - void do_output(const byte[], u32bit); + void encode_and_send(const byte[], size_t); + void do_output(const byte[], size_t); static const byte BIN_TO_BASE64[64]; - const u32bit line_length; + const size_t line_length; const bool trailing_newline; SecureVector<byte> in, out; - u32bit position, counter; + size_t position, counter; }; /** @@ -70,7 +70,7 @@ class BOTAN_DLL Base64_Decoder : public Filter * @param input the message to input as a byte array * @param length the length of the byte array input */ - void write(const byte input[], u32bit length); + void write(const byte input[], size_t length); /** * Inform the Encoder that the current message shall be closed. @@ -84,13 +84,13 @@ class BOTAN_DLL Base64_Decoder : public Filter */ Base64_Decoder(Decoder_Checking checking = NONE); private: - void decode_and_send(const byte[], u32bit); + void decode_and_send(const byte[], size_t); void handle_bad_char(byte); static const byte BASE64_TO_BIN[256]; const Decoder_Checking checking; SecureVector<byte> in, out; - u32bit position; + size_t position; }; } diff --git a/src/filters/basefilt.cpp b/src/filters/basefilt.cpp index dfb81386b..eace9cfd5 100644 --- a/src/filters/basefilt.cpp +++ b/src/filters/basefilt.cpp @@ -30,9 +30,9 @@ Chain::Chain(Filter* f1, Filter* f2, Filter* f3, Filter* f4) /* * Chain Constructor */ -Chain::Chain(Filter* filters[], u32bit count) +Chain::Chain(Filter* filters[], size_t count) { - for(u32bit j = 0; j != count; ++j) + for(size_t j = 0; j != count; ++j) if(filters[j]) { attach(filters[j]); @@ -57,7 +57,7 @@ Fork::Fork(Filter* f1, Filter* f2, Filter* f3, Filter* f4) /* * Fork Constructor */ -Fork::Fork(Filter* filters[], u32bit count) +Fork::Fork(Filter* filters[], size_t count) { set_next(filters, count); } diff --git a/src/filters/basefilt.h b/src/filters/basefilt.h index a5c3dcd41..adde3dd54 100644 --- a/src/filters/basefilt.h +++ b/src/filters/basefilt.h @@ -17,7 +17,7 @@ namespace Botan { */ struct BOTAN_DLL BitBucket : public Filter { - void write(const byte[], u32bit) {} + void write(const byte[], size_t) {} std::string name() const { return "BitBucket"; } }; @@ -31,7 +31,7 @@ struct BOTAN_DLL BitBucket : public Filter class BOTAN_DLL Chain : public Fanout_Filter { public: - void write(const byte input[], u32bit length) { send(input, length); } + void write(const byte input[], size_t length) { send(input, length); } std::string name() const; @@ -46,7 +46,7 @@ class BOTAN_DLL Chain : public Fanout_Filter * @param filter_arr the list of filters * @param length how many filters */ - Chain(Filter* filter_arr[], u32bit length); + Chain(Filter* filter_arr[], size_t length); }; /** @@ -57,8 +57,8 @@ class BOTAN_DLL Chain : public Fanout_Filter class BOTAN_DLL Fork : public Fanout_Filter { public: - void write(const byte input[], u32bit length) { send(input, length); } - void set_port(u32bit n) { Fanout_Filter::set_port(n); } + void write(const byte input[], size_t length) { send(input, length); } + void set_port(size_t n) { Fanout_Filter::set_port(n); } std::string name() const; @@ -72,7 +72,7 @@ class BOTAN_DLL Fork : public Fanout_Filter * @param filter_arr the list of filters * @param length how many filters */ - Fork(Filter* filter_arr[], u32bit length); + Fork(Filter* filter_arr[], size_t length); }; } diff --git a/src/filters/buf_filt.cpp b/src/filters/buf_filt.cpp index 897fd9be7..b332d74b8 100644 --- a/src/filters/buf_filt.cpp +++ b/src/filters/buf_filt.cpp @@ -15,7 +15,7 @@ namespace Botan { /* * Buffered_Filter Constructor */ -Buffered_Filter::Buffered_Filter(u32bit b, u32bit f) : +Buffered_Filter::Buffered_Filter(size_t b, size_t f) : main_block_mod(b), final_minimum(f) { if(main_block_mod == 0) @@ -31,14 +31,14 @@ Buffered_Filter::Buffered_Filter(u32bit b, u32bit f) : /* * Buffer input into blocks, trying to minimize copying */ -void Buffered_Filter::write(const byte input[], u32bit input_size) +void Buffered_Filter::write(const byte input[], size_t input_size) { if(!input_size) return; if(buffer_pos + input_size >= main_block_mod + final_minimum) { - u32bit to_copy = std::min<u32bit>(buffer.size() - buffer_pos, input_size); + size_t to_copy = std::min<size_t>(buffer.size() - buffer_pos, input_size); copy_mem(&buffer[buffer_pos], input, to_copy); buffer_pos += to_copy; @@ -46,7 +46,7 @@ void Buffered_Filter::write(const byte input[], u32bit input_size) input += to_copy; input_size -= to_copy; - u32bit total_to_consume = + size_t total_to_consume = round_down(std::min(buffer_pos, buffer_pos + input_size - final_minimum), main_block_mod); @@ -60,8 +60,8 @@ void Buffered_Filter::write(const byte input[], u32bit input_size) if(input_size >= final_minimum) { - u32bit full_blocks = (input_size - final_minimum) / main_block_mod; - u32bit to_copy = full_blocks * main_block_mod; + size_t full_blocks = (input_size - final_minimum) / main_block_mod; + size_t to_copy = full_blocks * main_block_mod; if(to_copy) { @@ -84,11 +84,11 @@ void Buffered_Filter::end_msg() if(buffer_pos < final_minimum) throw std::runtime_error("Buffered_Operation::final - not enough input"); - u32bit spare_blocks = (buffer_pos - final_minimum) / main_block_mod; + size_t spare_blocks = (buffer_pos - final_minimum) / main_block_mod; if(spare_blocks) { - u32bit spare_bytes = main_block_mod * spare_blocks; + size_t spare_bytes = main_block_mod * spare_blocks; buffered_block(&buffer[0], spare_bytes); buffered_final(&buffer[spare_bytes], buffer_pos - spare_bytes); } diff --git a/src/filters/buf_filt.h b/src/filters/buf_filt.h index 1f5d7dae8..0f8443453 100644 --- a/src/filters/buf_filt.h +++ b/src/filters/buf_filt.h @@ -19,35 +19,35 @@ namespace Botan { class BOTAN_DLL Buffered_Filter { public: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); - Buffered_Filter(u32bit block_size, u32bit final_minimum); + Buffered_Filter(size_t block_size, size_t final_minimum); virtual ~Buffered_Filter() {} protected: - virtual void buffered_block(const byte input[], u32bit length) = 0; - virtual void buffered_final(const byte input[], u32bit length) = 0; + virtual void buffered_block(const byte input[], size_t length) = 0; + virtual void buffered_final(const byte input[], size_t length) = 0; /** * @return block size of inputs */ - u32bit buffered_block_size() const { return main_block_mod; } + size_t buffered_block_size() const { return main_block_mod; } /** * @return current position in the buffer */ - u32bit current_position() const { return buffer_pos; } + size_t current_position() const { return buffer_pos; } /** * Reset the buffer position */ void buffer_reset() { buffer_pos = 0; } private: - u32bit main_block_mod, final_minimum; + size_t main_block_mod, final_minimum; SecureVector<byte> buffer; - u32bit buffer_pos; + size_t buffer_pos; }; } diff --git a/src/filters/bzip2/bzip2.cpp b/src/filters/bzip2/bzip2.cpp index 022ddedf1..b166017c3 100644 --- a/src/filters/bzip2/bzip2.cpp +++ b/src/filters/bzip2/bzip2.cpp @@ -25,7 +25,7 @@ namespace { class Bzip_Alloc_Info { public: - std::map<void*, u32bit> current_allocs; + std::map<void*, size_t> current_allocs; Allocator* alloc; Bzip_Alloc_Info() { alloc = Allocator::get(false); } @@ -48,7 +48,7 @@ void* bzip_malloc(void* info_ptr, int n, int size) void bzip_free(void* info_ptr, void* ptr) { Bzip_Alloc_Info* info = static_cast<Bzip_Alloc_Info*>(info_ptr); - std::map<void*, u32bit>::const_iterator i = info->current_allocs.find(ptr); + std::map<void*, size_t>::const_iterator i = info->current_allocs.find(ptr); if(i == info->current_allocs.end()) throw Invalid_Argument("bzip_free: Got pointer not allocated by us"); info->alloc->deallocate(ptr, i->second); @@ -92,7 +92,7 @@ class Bzip_Stream /* * Bzip_Compression Constructor */ -Bzip_Compression::Bzip_Compression(u32bit l) : +Bzip_Compression::Bzip_Compression(size_t l) : level((l >= 9) ? 9 : l), buffer(DEFAULT_BUFFERSIZE) { bz = 0; @@ -112,7 +112,7 @@ void Bzip_Compression::start_msg() /* * Compress Input with Bzip */ -void Bzip_Compression::write(const byte input[], u32bit length) +void Bzip_Compression::write(const byte input[], size_t length) { bz->stream.next_in = reinterpret_cast<char*>(const_cast<byte*>(input)); bz->stream.avail_in = length; @@ -187,7 +187,7 @@ Bzip_Decompression::Bzip_Decompression(bool s) : /* * Decompress Input with Bzip */ -void Bzip_Decompression::write(const byte input_arr[], u32bit length) +void Bzip_Decompression::write(const byte input_arr[], size_t length) { if(length) no_writes = false; @@ -221,7 +221,7 @@ void Bzip_Decompression::write(const byte input_arr[], u32bit length) if(rc == BZ_STREAM_END) { - u32bit read_from_block = length - bz->stream.avail_in; + size_t read_from_block = length - bz->stream.avail_in; start_msg(); bz->stream.next_in = input + read_from_block; bz->stream.avail_in = length - read_from_block; diff --git a/src/filters/bzip2/bzip2.h b/src/filters/bzip2/bzip2.h index aacec8fa9..b3b222eb2 100644 --- a/src/filters/bzip2/bzip2.h +++ b/src/filters/bzip2/bzip2.h @@ -21,18 +21,18 @@ class BOTAN_DLL Bzip_Compression : public Filter public: std::string name() const { return "Bzip_Compression"; } - void write(const byte input[], u32bit length); + void write(const byte input[], size_t length); void start_msg(); void end_msg(); void flush(); - Bzip_Compression(u32bit = 9); + Bzip_Compression(size_t = 9); ~Bzip_Compression() { clear(); } private: void clear(); - const u32bit level; + const size_t level; SecureVector<byte> buffer; class Bzip_Stream* bz; }; @@ -45,7 +45,7 @@ class BOTAN_DLL Bzip_Decompression : public Filter public: std::string name() const { return "Bzip_Decompression"; } - void write(const byte input[], u32bit length); + void write(const byte input[], size_t length); void start_msg(); void end_msg(); diff --git a/src/filters/data_snk.cpp b/src/filters/data_snk.cpp index 82ffddc53..d651dcba7 100644 --- a/src/filters/data_snk.cpp +++ b/src/filters/data_snk.cpp @@ -15,7 +15,7 @@ namespace Botan { /* * Write to a stream */ -void DataSink_Stream::write(const byte out[], u32bit length) +void DataSink_Stream::write(const byte out[], size_t length) { sink.write(reinterpret_cast<const char*>(out), length); if(!sink.good()) diff --git a/src/filters/data_snk.h b/src/filters/data_snk.h index def9facbb..e31cb9d28 100644 --- a/src/filters/data_snk.h +++ b/src/filters/data_snk.h @@ -35,7 +35,7 @@ class BOTAN_DLL DataSink_Stream : public DataSink public: std::string name() const { return identifier; } - void write(const byte[], u32bit); + void write(const byte[], size_t); /** * Construct a DataSink_Stream from a stream. diff --git a/src/filters/data_src.cpp b/src/filters/data_src.cpp index 596e98ffd..9c9e19c23 100644 --- a/src/filters/data_src.cpp +++ b/src/filters/data_src.cpp @@ -16,7 +16,7 @@ namespace Botan { /* * Read a single byte from the DataSource */ -u32bit DataSource::read_byte(byte& out) +size_t DataSource::read_byte(byte& out) { return read(&out, 1); } @@ -24,7 +24,7 @@ u32bit DataSource::read_byte(byte& out) /* * Peek a single byte from the DataSource */ -u32bit DataSource::peek_byte(byte& out) const +size_t DataSource::peek_byte(byte& out) const { return peek(&out, 1, 0); } @@ -32,11 +32,11 @@ u32bit DataSource::peek_byte(byte& out) const /* * Discard the next N bytes of the data */ -u32bit DataSource::discard_next(u32bit n) +size_t DataSource::discard_next(size_t n) { - u32bit discarded = 0; + size_t discarded = 0; byte dummy; - for(u32bit j = 0; j != n; ++j) + for(size_t j = 0; j != n; ++j) discarded += read_byte(dummy); return discarded; } @@ -44,9 +44,9 @@ u32bit DataSource::discard_next(u32bit n) /* * Read from a memory buffer */ -u32bit DataSource_Memory::read(byte out[], u32bit length) +size_t DataSource_Memory::read(byte out[], size_t length) { - u32bit got = std::min<u32bit>(source.size() - offset, length); + size_t got = std::min<size_t>(source.size() - offset, length); copy_mem(out, &source[offset], got); offset += got; return got; @@ -55,13 +55,13 @@ u32bit DataSource_Memory::read(byte out[], u32bit length) /* * Peek into a memory buffer */ -u32bit DataSource_Memory::peek(byte out[], u32bit length, - u32bit peek_offset) const +size_t DataSource_Memory::peek(byte out[], size_t length, + size_t peek_offset) const { - const u32bit bytes_left = source.size() - offset; + const size_t bytes_left = source.size() - offset; if(peek_offset >= bytes_left) return 0; - u32bit got = std::min(bytes_left - peek_offset, length); + size_t got = std::min(bytes_left - peek_offset, length); copy_mem(out, &source[offset + peek_offset], got); return got; } @@ -77,7 +77,7 @@ bool DataSource_Memory::end_of_data() const /* * DataSource_Memory Constructor */ -DataSource_Memory::DataSource_Memory(const byte in[], u32bit length) +DataSource_Memory::DataSource_Memory(const byte in[], size_t length) { source.set(in, length); offset = 0; @@ -104,13 +104,13 @@ DataSource_Memory::DataSource_Memory(const std::string& in) /* * Read from a stream */ -u32bit DataSource_Stream::read(byte out[], u32bit length) +size_t DataSource_Stream::read(byte out[], size_t length) { source.read(reinterpret_cast<char*>(out), length); if(source.bad()) throw Stream_IO_Error("DataSource_Stream::read: Source failure"); - u32bit got = source.gcount(); + size_t got = source.gcount(); total_read += got; return got; } @@ -118,12 +118,12 @@ u32bit DataSource_Stream::read(byte out[], u32bit length) /* * Peek into a stream */ -u32bit DataSource_Stream::peek(byte out[], u32bit length, u32bit offset) const +size_t DataSource_Stream::peek(byte out[], size_t length, size_t offset) const { if(end_of_data()) throw Invalid_State("DataSource_Stream: Cannot peek when out of data"); - u32bit got = 0; + size_t got = 0; if(offset) { diff --git a/src/filters/data_src.h b/src/filters/data_src.h index 26238928d..a274de8e2 100644 --- a/src/filters/data_src.h +++ b/src/filters/data_src.h @@ -29,7 +29,7 @@ class BOTAN_DLL DataSource * @return length in bytes that was actually read and put * into out */ - virtual u32bit read(byte out[], u32bit length) = 0; + virtual size_t read(byte out[], size_t length) = 0; /** * Read from the source but do not modify the internal @@ -42,8 +42,8 @@ class BOTAN_DLL DataSource * @return length in bytes that was actually read and put * into out */ - virtual u32bit peek(byte out[], u32bit length, - u32bit peek_offset) const = 0; + virtual size_t peek(byte out[], size_t length, + size_t peek_offset) const = 0; /** * Test whether the source still has data that can be read. @@ -62,7 +62,7 @@ class BOTAN_DLL DataSource * @return length in bytes that was actually read and put * into out */ - u32bit read_byte(byte& out); + size_t read_byte(byte& out); /** * Peek at one byte. @@ -70,14 +70,14 @@ class BOTAN_DLL DataSource * @return length in bytes that was actually read and put * into out */ - u32bit peek_byte(byte& out) const; + size_t peek_byte(byte& out) const; /** * Discard the next N bytes of the data * @param N the number of bytes to discard * @return number of bytes actually discarded */ - u32bit discard_next(u32bit N); + size_t discard_next(size_t N); DataSource() {} virtual ~DataSource() {} @@ -92,8 +92,8 @@ class BOTAN_DLL DataSource class BOTAN_DLL DataSource_Memory : public DataSource { public: - u32bit read(byte[], u32bit); - u32bit peek(byte[], u32bit, u32bit) const; + size_t read(byte[], size_t); + size_t peek(byte[], size_t, size_t) const; bool end_of_data() const; /** @@ -107,7 +107,7 @@ class BOTAN_DLL DataSource_Memory : public DataSource * @param in the byte array to read from * @param length the length of the byte array */ - DataSource_Memory(const byte in[], u32bit length); + DataSource_Memory(const byte in[], size_t length); /** * Construct a memory source that reads from a MemoryRegion @@ -116,7 +116,7 @@ class BOTAN_DLL DataSource_Memory : public DataSource DataSource_Memory(const MemoryRegion<byte>& in); private: SecureVector<byte> source; - u32bit offset; + size_t offset; }; /** @@ -125,8 +125,8 @@ class BOTAN_DLL DataSource_Memory : public DataSource class BOTAN_DLL DataSource_Stream : public DataSource { public: - u32bit read(byte[], u32bit); - u32bit peek(byte[], u32bit, u32bit) const; + size_t read(byte[], size_t); + size_t peek(byte[], size_t, size_t) const; bool end_of_data() const; std::string id() const; @@ -146,7 +146,7 @@ class BOTAN_DLL DataSource_Stream : public DataSource std::istream* source_p; std::istream& source; - u32bit total_read; + size_t total_read; }; } diff --git a/src/filters/fd_unix/fd_unix.cpp b/src/filters/fd_unix/fd_unix.cpp index d2b3530a3..3a9253b5e 100644 --- a/src/filters/fd_unix/fd_unix.cpp +++ b/src/filters/fd_unix/fd_unix.cpp @@ -19,8 +19,8 @@ int operator<<(int fd, Pipe& pipe) SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); while(pipe.remaining()) { - u32bit got = pipe.read(&buffer[0], buffer.size()); - u32bit position = 0; + size_t got = pipe.read(&buffer[0], buffer.size()); + size_t position = 0; while(got) { ssize_t ret = write(fd, &buffer[position], got); diff --git a/src/filters/filter.cpp b/src/filters/filter.cpp index a9a307dbc..c33f25814 100644 --- a/src/filters/filter.cpp +++ b/src/filters/filter.cpp @@ -25,10 +25,10 @@ Filter::Filter() /* * Send data to all ports */ -void Filter::send(const byte input[], u32bit length) +void Filter::send(const byte input[], size_t length) { bool nothing_attached = true; - for(u32bit j = 0; j != total_ports(); ++j) + for(size_t j = 0; j != total_ports(); ++j) if(next[j]) { if(write_queue.size()) @@ -49,7 +49,7 @@ void Filter::send(const byte input[], u32bit length) void Filter::new_msg() { start_msg(); - for(u32bit j = 0; j != total_ports(); ++j) + for(size_t j = 0; j != total_ports(); ++j) if(next[j]) next[j]->new_msg(); } @@ -60,7 +60,7 @@ void Filter::new_msg() void Filter::finish_msg() { end_msg(); - for(u32bit j = 0; j != total_ports(); ++j) + for(size_t j = 0; j != total_ports(); ++j) if(next[j]) next[j]->finish_msg(); } @@ -82,7 +82,7 @@ void Filter::attach(Filter* new_filter) /* * Set the active port on a filter */ -void Filter::set_port(u32bit new_port) +void Filter::set_port(size_t new_port) { if(new_port >= total_ports()) throw Invalid_Argument("Filter: Invalid port number"); @@ -102,7 +102,7 @@ Filter* Filter::get_next() const /* * Set the next Filters */ -void Filter::set_next(Filter* filters[], u32bit size) +void Filter::set_next(Filter* filters[], size_t size) { while(size && filters && filters[size-1] == 0) --size; @@ -113,14 +113,14 @@ void Filter::set_next(Filter* filters[], u32bit size) port_num = 0; filter_owns = 0; - for(u32bit j = 0; j != size; ++j) + for(size_t j = 0; j != size; ++j) next[j] = filters[j]; } /* * Return the total number of ports */ -u32bit Filter::total_ports() const +size_t Filter::total_ports() const { return next.size(); } diff --git a/src/filters/filter.h b/src/filters/filter.h index 81641db3d..2bbaf155c 100644 --- a/src/filters/filter.h +++ b/src/filters/filter.h @@ -29,7 +29,7 @@ class BOTAN_DLL Filter * @param input the input as a byte array * @param length the length of the byte array input */ - virtual void write(const byte input[], u32bit length) = 0; + virtual void write(const byte input[], size_t length) = 0; /** * Start a new message. Must be closed by end_msg() before another @@ -55,7 +55,7 @@ class BOTAN_DLL Filter * @param in some input for the filter * @param length the length of in */ - void send(const byte in[], u32bit length); + void send(const byte in[], size_t length); /** * @param in some input for the filter @@ -70,7 +70,7 @@ class BOTAN_DLL Filter /** * @param in some input for the filter */ - void send(const MemoryRegion<byte>& in, u32bit length) + void send(const MemoryRegion<byte>& in, size_t length) { send(&in[0], length); } @@ -95,16 +95,16 @@ class BOTAN_DLL Filter friend class Pipe; friend class Fanout_Filter; - u32bit total_ports() const; - u32bit current_port() const { return port_num; } + size_t total_ports() const; + size_t current_port() const { return port_num; } /** * Set the active port * @param new_port the new value */ - void set_port(u32bit new_port); + void set_port(size_t new_port); - u32bit owns() const { return filter_owns; } + size_t owns() const { return filter_owns; } /** * Attach another filter to this one @@ -116,12 +116,12 @@ class BOTAN_DLL Filter * @param filters the filters to set * @param count number of items in filters */ - void set_next(Filter* filters[], u32bit count); + void set_next(Filter* filters[], size_t count); Filter* get_next() const; SecureVector<byte> write_queue; std::vector<Filter*> next; - u32bit port_num, filter_owns; + size_t port_num, filter_owns; // true if filter belongs to a pipe --> prohibit filter sharing! bool owned; @@ -138,9 +138,9 @@ class BOTAN_DLL Fanout_Filter : public Filter */ void incr_owns() { ++filter_owns; } - void set_port(u32bit n) { Filter::set_port(n); } + void set_port(size_t n) { Filter::set_port(n); } - void set_next(Filter* f[], u32bit n) { Filter::set_next(f, n); } + void set_next(Filter* f[], size_t n) { Filter::set_next(f, n); } void attach(Filter* f) { Filter::attach(f); } }; diff --git a/src/filters/filters.h b/src/filters/filters.h index 51b4f00fe..060b1d6d0 100644 --- a/src/filters/filters.h +++ b/src/filters/filters.h @@ -44,9 +44,9 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter * @param input data * @param input_len length of input in bytes */ - void write(const byte input[], u32bit input_len); + void write(const byte input[], size_t input_len); - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return cipher->valid_iv_length(iv_len); } /** @@ -66,7 +66,7 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter * @param length the key length to be checked for validity * @return true if the key length is valid, false otherwise */ - bool valid_keylength(u32bit length) const + bool valid_keylength(size_t length) const { return cipher->valid_keylength(length); } /** @@ -107,7 +107,7 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter class BOTAN_DLL Hash_Filter : public Filter { public: - void write(const byte input[], u32bit len) { hash->update(input, len); } + void write(const byte input[], size_t len) { hash->update(input, len); } void end_msg(); std::string name() const { return hash->name(); } @@ -120,7 +120,7 @@ class BOTAN_DLL Hash_Filter : public Filter * hash. Otherwise, specify a smaller value here so that the * output of the hash algorithm will be cut off. */ - Hash_Filter(HashFunction* hash_fun, u32bit len = 0) : + Hash_Filter(HashFunction* hash_fun, size_t len = 0) : OUTPUT_LENGTH(len), hash(hash_fun) {} /** @@ -131,11 +131,11 @@ class BOTAN_DLL Hash_Filter : public Filter * hash. Otherwise, specify a smaller value here so that the * output of the hash algorithm will be cut off. */ - Hash_Filter(const std::string& request, u32bit len = 0); + Hash_Filter(const std::string& request, size_t len = 0); ~Hash_Filter() { delete hash; } private: - const u32bit OUTPUT_LENGTH; + const size_t OUTPUT_LENGTH; HashFunction* hash; }; @@ -145,7 +145,7 @@ class BOTAN_DLL Hash_Filter : public Filter class BOTAN_DLL MAC_Filter : public Keyed_Filter { public: - void write(const byte input[], u32bit len) { mac->update(input, len); } + void write(const byte input[], size_t len) { mac->update(input, len); } void end_msg(); std::string name() const { return mac->name(); } @@ -161,7 +161,7 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter * @param length the key length to be checked for validity * @return true if the key length is valid, false otherwise */ - bool valid_keylength(u32bit length) const + bool valid_keylength(size_t length) const { return mac->valid_keylength(length); } /** @@ -173,7 +173,7 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter * output of the MAC will be cut off. */ MAC_Filter(MessageAuthenticationCode* mac_obj, - u32bit out_len = 0) : OUTPUT_LENGTH(out_len) + size_t out_len = 0) : OUTPUT_LENGTH(out_len) { mac = mac_obj; } @@ -189,7 +189,7 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter */ MAC_Filter(MessageAuthenticationCode* mac_obj, const SymmetricKey& key, - u32bit out_len = 0) : OUTPUT_LENGTH(out_len) + size_t out_len = 0) : OUTPUT_LENGTH(out_len) { mac = mac_obj; mac->set_key(key); @@ -203,7 +203,7 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter * MAC. Otherwise, specify a smaller value here so that the * output of the MAC will be cut off. */ - MAC_Filter(const std::string& mac, u32bit len = 0); + MAC_Filter(const std::string& mac, size_t len = 0); /** * Construct a MAC filter. @@ -215,11 +215,11 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter * output of the MAC will be cut off. */ MAC_Filter(const std::string& mac, const SymmetricKey& key, - u32bit len = 0); + size_t len = 0); ~MAC_Filter() { delete mac; } private: - const u32bit OUTPUT_LENGTH; + const size_t OUTPUT_LENGTH; MessageAuthenticationCode* mac; }; diff --git a/src/filters/hex_filt/hex_filt.cpp b/src/filters/hex_filt/hex_filt.cpp index d821ca514..3d56beec4 100644 --- a/src/filters/hex_filt/hex_filt.cpp +++ b/src/filters/hex_filt/hex_filt.cpp @@ -17,12 +17,12 @@ namespace Botan { /** * Size used for internal buffer in hex encoder/decoder */ -const u32bit HEX_CODEC_BUFFER_SIZE = 256; +const size_t HEX_CODEC_BUFFER_SIZE = 256; /* * Hex_Encoder Constructor */ -Hex_Encoder::Hex_Encoder(bool breaks, u32bit length, Case c) : +Hex_Encoder::Hex_Encoder(bool breaks, size_t length, Case c) : casing(c), line_length(breaks ? length : 0) { in.resize(HEX_CODEC_BUFFER_SIZE); @@ -43,7 +43,7 @@ Hex_Encoder::Hex_Encoder(Case c) : casing(c), line_length(0) /* * Encode and send a block */ -void Hex_Encoder::encode_and_send(const byte block[], u32bit length) +void Hex_Encoder::encode_and_send(const byte block[], size_t length) { hex_encode(reinterpret_cast<char*>(&out[0]), block, length, @@ -53,10 +53,10 @@ void Hex_Encoder::encode_and_send(const byte block[], u32bit length) send(out, 2*length); else { - u32bit remaining = 2*length, offset = 0; + size_t remaining = 2*length, offset = 0; while(remaining) { - u32bit sent = std::min(line_length - counter, remaining); + size_t sent = std::min(line_length - counter, remaining); send(&out[offset], sent); counter += sent; remaining -= sent; @@ -73,7 +73,7 @@ void Hex_Encoder::encode_and_send(const byte block[], u32bit length) /* * Convert some data into hex format */ -void Hex_Encoder::write(const byte input[], u32bit length) +void Hex_Encoder::write(const byte input[], size_t length) { in.copy(position, input, length); if(position + length >= in.size()) @@ -117,16 +117,16 @@ Hex_Decoder::Hex_Decoder(Decoder_Checking c) : checking(c) /* * Convert some data from hex format */ -void Hex_Decoder::write(const byte input[], u32bit length) +void Hex_Decoder::write(const byte input[], size_t length) { while(length) { - u32bit to_copy = std::min<u32bit>(length, in.size() - position); + size_t to_copy = std::min<size_t>(length, in.size() - position); copy_mem(&in[position], input, to_copy); position += to_copy; size_t consumed = 0; - u32bit written = hex_decode(&out[0], + size_t written = hex_decode(&out[0], reinterpret_cast<const char*>(&in[0]), position, consumed, @@ -153,7 +153,7 @@ void Hex_Decoder::write(const byte input[], u32bit length) void Hex_Decoder::end_msg() { size_t consumed = 0; - u32bit written = hex_decode(&out[0], + size_t written = hex_decode(&out[0], reinterpret_cast<const char*>(&in[0]), position, consumed, diff --git a/src/filters/hex_filt/hex_filt.h b/src/filters/hex_filt/hex_filt.h index 88bf35de8..cfbb818d3 100644 --- a/src/filters/hex_filt/hex_filt.h +++ b/src/filters/hex_filt/hex_filt.h @@ -26,7 +26,7 @@ class BOTAN_DLL Hex_Encoder : public Filter std::string name() const { return "Hex_Encoder"; } - void write(const byte in[], u32bit length); + void write(const byte in[], size_t length); void end_msg(); /** @@ -42,15 +42,15 @@ class BOTAN_DLL Hex_Encoder : public Filter * @param the_case the case to use in the encoded strings */ Hex_Encoder(bool newlines = false, - u32bit line_length = 72, + size_t line_length = 72, Case the_case = Uppercase); private: - void encode_and_send(const byte[], u32bit); + void encode_and_send(const byte[], size_t); const Case casing; - const u32bit line_length; + const size_t line_length; SecureVector<byte> in, out; - u32bit position, counter; + size_t position, counter; }; /** @@ -61,7 +61,7 @@ class BOTAN_DLL Hex_Decoder : public Filter public: std::string name() const { return "Hex_Decoder"; } - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); /** @@ -73,7 +73,7 @@ class BOTAN_DLL Hex_Decoder : public Filter private: const Decoder_Checking checking; SecureVector<byte> in, out; - u32bit position; + size_t position; }; } diff --git a/src/filters/key_filt.h b/src/filters/key_filt.h index 0afea446c..3c79ebac9 100644 --- a/src/filters/key_filt.h +++ b/src/filters/key_filt.h @@ -38,14 +38,14 @@ class BOTAN_DLL Keyed_Filter : public Filter * @param length the key length to be checked for validity * @return true if the key length is valid, false otherwise */ - virtual bool valid_keylength(u32bit length) const = 0; + virtual bool valid_keylength(size_t length) const = 0; /** * Check whether an IV length is valid for this filter * @param length the IV length to be checked for validity * @return true if the IV length is valid, false otherwise */ - virtual bool valid_iv_length(u32bit length) const + virtual bool valid_iv_length(size_t length) const { return (length == 0); } }; diff --git a/src/filters/modes/cbc/cbc.cpp b/src/filters/modes/cbc/cbc.cpp index 822b76030..8389fc070 100644 --- a/src/filters/modes/cbc/cbc.cpp +++ b/src/filters/modes/cbc/cbc.cpp @@ -59,11 +59,11 @@ void CBC_Encryption::set_iv(const InitializationVector& iv) /* * Encrypt in CBC mode */ -void CBC_Encryption::buffered_block(const byte input[], u32bit length) +void CBC_Encryption::buffered_block(const byte input[], size_t length) { - u32bit blocks = length / state.size(); + size_t blocks = length / state.size(); - for(u32bit i = 0; i != blocks; ++i) + for(size_t i = 0; i != blocks; ++i) { xor_buf(state, input + i * cipher->BLOCK_SIZE, state.size()); cipher->encrypt(state); @@ -74,7 +74,7 @@ void CBC_Encryption::buffered_block(const byte input[], u32bit length) /* * Finish encrypting in CBC mode */ -void CBC_Encryption::buffered_final(const byte input[], u32bit length) +void CBC_Encryption::buffered_final(const byte input[], size_t length) { if(length % cipher->BLOCK_SIZE == 0) buffered_block(input, length); @@ -82,19 +82,19 @@ void CBC_Encryption::buffered_final(const byte input[], u32bit length) throw Encoding_Error(name() + ": Did not pad to full blocksize"); } -void CBC_Encryption::write(const byte input[], u32bit input_length) +void CBC_Encryption::write(const byte input[], size_t input_length) { Buffered_Filter::write(input, input_length); } void CBC_Encryption::end_msg() { - u32bit last_block = current_position() % cipher->BLOCK_SIZE; + size_t last_block = current_position() % cipher->BLOCK_SIZE; SecureVector<byte> padding(cipher->BLOCK_SIZE); padder->pad(padding, padding.size(), last_block); - u32bit pad_bytes = padder->pad_bytes(cipher->BLOCK_SIZE, last_block); + size_t pad_bytes = padder->pad_bytes(cipher->BLOCK_SIZE, last_block); if(pad_bytes) Buffered_Filter::write(padding, pad_bytes); @@ -159,20 +159,20 @@ void CBC_Decryption::set_iv(const InitializationVector& iv) /* * Decrypt in CBC mode */ -void CBC_Decryption::buffered_block(const byte input[], u32bit length) +void CBC_Decryption::buffered_block(const byte input[], size_t length) { - const u32bit blocks_in_temp = temp.size() / cipher->BLOCK_SIZE; - u32bit blocks = length / cipher->BLOCK_SIZE; + const size_t blocks_in_temp = temp.size() / cipher->BLOCK_SIZE; + size_t blocks = length / cipher->BLOCK_SIZE; while(blocks) { - u32bit to_proc = std::min<u32bit>(blocks, blocks_in_temp); + size_t to_proc = std::min<size_t>(blocks, blocks_in_temp); cipher->decrypt_n(input, &temp[0], to_proc); xor_buf(temp, state, cipher->BLOCK_SIZE); - for(u32bit i = 1; i < to_proc; ++i) + for(size_t i = 1; i < to_proc; ++i) xor_buf(&temp[i * cipher->BLOCK_SIZE], input + (i-1) * cipher->BLOCK_SIZE, cipher->BLOCK_SIZE); @@ -189,7 +189,7 @@ void CBC_Decryption::buffered_block(const byte input[], u32bit length) /* * Finish encrypting in CBC mode */ -void CBC_Decryption::buffered_final(const byte input[], u32bit length) +void CBC_Decryption::buffered_final(const byte input[], size_t length) { if(length == 0 || length % cipher->BLOCK_SIZE != 0) throw Decoding_Error(name() + ": Ciphertext not multiple of block size"); @@ -210,7 +210,7 @@ void CBC_Decryption::buffered_final(const byte input[], u32bit length) /* * Decrypt in CBC mode */ -void CBC_Decryption::write(const byte input[], u32bit length) +void CBC_Decryption::write(const byte input[], size_t length) { Buffered_Filter::write(input, length); } diff --git a/src/filters/modes/cbc/cbc.h b/src/filters/modes/cbc/cbc.h index 4f682530b..801b57ec5 100644 --- a/src/filters/modes/cbc/cbc.h +++ b/src/filters/modes/cbc/cbc.h @@ -28,10 +28,10 @@ class BOTAN_DLL CBC_Encryption : public Keyed_Filter, void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } CBC_Encryption(BlockCipher* cipher, @@ -44,10 +44,10 @@ class BOTAN_DLL CBC_Encryption : public Keyed_Filter, ~CBC_Encryption() { delete cipher; delete padder; } private: - void buffered_block(const byte input[], u32bit input_length); - void buffered_final(const byte input[], u32bit input_length); + void buffered_block(const byte input[], size_t input_length); + void buffered_final(const byte input[], size_t input_length); - void write(const byte input[], u32bit input_length); + void write(const byte input[], size_t input_length); void end_msg(); BlockCipher* cipher; @@ -68,10 +68,10 @@ class BOTAN_DLL CBC_Decryption : public Keyed_Filter, void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } CBC_Decryption(BlockCipher* cipher, @@ -84,10 +84,10 @@ class BOTAN_DLL CBC_Decryption : public Keyed_Filter, ~CBC_Decryption() { delete cipher; delete padder; } private: - void buffered_block(const byte input[], u32bit input_length); - void buffered_final(const byte input[], u32bit input_length); + void buffered_block(const byte input[], size_t input_length); + void buffered_final(const byte input[], size_t input_length); - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); BlockCipher* cipher; diff --git a/src/filters/modes/cfb/cfb.cpp b/src/filters/modes/cfb/cfb.cpp index fc1490b30..98206ed8f 100644 --- a/src/filters/modes/cfb/cfb.cpp +++ b/src/filters/modes/cfb/cfb.cpp @@ -15,7 +15,7 @@ namespace Botan { /* * CFB Encryption Constructor */ -CFB_Encryption::CFB_Encryption(BlockCipher* ciph, u32bit fback_bits) +CFB_Encryption::CFB_Encryption(BlockCipher* ciph, size_t fback_bits) { cipher = ciph; feedback = fback_bits ? fback_bits / 8: cipher->BLOCK_SIZE; @@ -35,7 +35,7 @@ CFB_Encryption::CFB_Encryption(BlockCipher* ciph, u32bit fback_bits) CFB_Encryption::CFB_Encryption(BlockCipher* ciph, const SymmetricKey& key, const InitializationVector& iv, - u32bit fback_bits) + size_t fback_bits) { cipher = ciph; feedback = fback_bits ? fback_bits / 8: cipher->BLOCK_SIZE; @@ -67,11 +67,11 @@ void CFB_Encryption::set_iv(const InitializationVector& iv) /* * Encrypt data in CFB mode */ -void CFB_Encryption::write(const byte input[], u32bit length) +void CFB_Encryption::write(const byte input[], size_t length) { while(length) { - u32bit xored = std::min(feedback - position, length); + size_t xored = std::min(feedback - position, length); xor_buf(&buffer[position], input, xored); send(&buffer[position], xored); input += xored; @@ -80,7 +80,7 @@ void CFB_Encryption::write(const byte input[], u32bit length) if(position == feedback) { - for(u32bit j = 0; j != cipher->BLOCK_SIZE - feedback; ++j) + for(size_t j = 0; j != cipher->BLOCK_SIZE - feedback; ++j) state[j] = state[j + feedback]; state.copy(cipher->BLOCK_SIZE - feedback, buffer, feedback); cipher->encrypt(state, buffer); @@ -92,7 +92,7 @@ void CFB_Encryption::write(const byte input[], u32bit length) /* * CFB Decryption Constructor */ -CFB_Decryption::CFB_Decryption(BlockCipher* ciph, u32bit fback_bits) +CFB_Decryption::CFB_Decryption(BlockCipher* ciph, size_t fback_bits) { cipher = ciph; feedback = fback_bits ? fback_bits / 8: cipher->BLOCK_SIZE; @@ -112,7 +112,7 @@ CFB_Decryption::CFB_Decryption(BlockCipher* ciph, u32bit fback_bits) CFB_Decryption::CFB_Decryption(BlockCipher* ciph, const SymmetricKey& key, const InitializationVector& iv, - u32bit fback_bits) + size_t fback_bits) { cipher = ciph; feedback = fback_bits ? fback_bits / 8: cipher->BLOCK_SIZE; @@ -144,11 +144,11 @@ void CFB_Decryption::set_iv(const InitializationVector& iv) /* * Decrypt data in CFB mode */ -void CFB_Decryption::write(const byte input[], u32bit length) +void CFB_Decryption::write(const byte input[], size_t length) { while(length) { - u32bit xored = std::min(feedback - position, length); + size_t xored = std::min(feedback - position, length); xor_buf(&buffer[position], input, xored); send(&buffer[position], xored); buffer.copy(position, input, xored); @@ -157,7 +157,7 @@ void CFB_Decryption::write(const byte input[], u32bit length) position += xored; if(position == feedback) { - for(u32bit j = 0; j != cipher->BLOCK_SIZE - feedback; ++j) + for(size_t j = 0; j != cipher->BLOCK_SIZE - feedback; ++j) state[j] = state[j + feedback]; state.copy(cipher->BLOCK_SIZE - feedback, buffer, feedback); cipher->encrypt(state, buffer); diff --git a/src/filters/modes/cfb/cfb.h b/src/filters/modes/cfb/cfb.h index 05fb9574f..da1115f4f 100644 --- a/src/filters/modes/cfb/cfb.h +++ b/src/filters/modes/cfb/cfb.h @@ -25,26 +25,26 @@ class BOTAN_DLL CFB_Encryption : public Keyed_Filter void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } - CFB_Encryption(BlockCipher* cipher, u32bit feedback = 0); + CFB_Encryption(BlockCipher* cipher, size_t feedback = 0); CFB_Encryption(BlockCipher* cipher, const SymmetricKey& key, const InitializationVector& iv, - u32bit feedback = 0); + size_t feedback = 0); ~CFB_Encryption() { delete cipher; } private: - void write(const byte[], u32bit); + void write(const byte[], size_t); BlockCipher* cipher; SecureVector<byte> buffer, state; - u32bit position, feedback; + size_t position, feedback; }; /** @@ -59,26 +59,26 @@ class BOTAN_DLL CFB_Decryption : public Keyed_Filter void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } - CFB_Decryption(BlockCipher* cipher, u32bit feedback = 0); + CFB_Decryption(BlockCipher* cipher, size_t feedback = 0); CFB_Decryption(BlockCipher* cipher, const SymmetricKey& key, const InitializationVector& iv, - u32bit feedback = 0); + size_t feedback = 0); ~CFB_Decryption() { delete cipher; } private: - void write(const byte[], u32bit); + void write(const byte[], size_t); BlockCipher* cipher; SecureVector<byte> buffer, state; - u32bit position, feedback; + size_t position, feedback; }; } diff --git a/src/filters/modes/cts/cts.cpp b/src/filters/modes/cts/cts.cpp index f39c4be36..dc0082258 100644 --- a/src/filters/modes/cts/cts.cpp +++ b/src/filters/modes/cts/cts.cpp @@ -64,9 +64,9 @@ void CTS_Encryption::encrypt(const byte block[]) /* * Encrypt in CTS mode */ -void CTS_Encryption::write(const byte input[], u32bit length) +void CTS_Encryption::write(const byte input[], size_t length) { - u32bit copied = std::min<u32bit>(buffer.size() - position, length); + size_t copied = std::min<size_t>(buffer.size() - position, length); buffer.copy(position, input, copied); length -= copied; input += copied; @@ -167,9 +167,9 @@ void CTS_Decryption::decrypt(const byte block[]) /* * Decrypt in CTS mode */ -void CTS_Decryption::write(const byte input[], u32bit length) +void CTS_Decryption::write(const byte input[], size_t length) { - u32bit copied = std::min<u32bit>(buffer.size() - position, length); + size_t copied = std::min<size_t>(buffer.size() - position, length); buffer.copy(position, input, copied); length -= copied; input += copied; diff --git a/src/filters/modes/cts/cts.h b/src/filters/modes/cts/cts.h index e9c8ec592..51d6dec3e 100644 --- a/src/filters/modes/cts/cts.h +++ b/src/filters/modes/cts/cts.h @@ -25,10 +25,10 @@ class BOTAN_DLL CTS_Encryption : public Keyed_Filter void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } CTS_Encryption(BlockCipher* cipher); @@ -39,13 +39,13 @@ class BOTAN_DLL CTS_Encryption : public Keyed_Filter ~CTS_Encryption() { delete cipher; } private: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); void encrypt(const byte[]); BlockCipher* cipher; SecureVector<byte> buffer, state; - u32bit position; + size_t position; }; /** @@ -60,10 +60,10 @@ class BOTAN_DLL CTS_Decryption : public Keyed_Filter void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } CTS_Decryption(BlockCipher* cipher); @@ -74,13 +74,13 @@ class BOTAN_DLL CTS_Decryption : public Keyed_Filter ~CTS_Decryption() { delete cipher; } private: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); void decrypt(const byte[]); BlockCipher* cipher; SecureVector<byte> buffer, state, temp; - u32bit position; + size_t position; }; } diff --git a/src/filters/modes/eax/eax.cpp b/src/filters/modes/eax/eax.cpp index 89ba8edcd..bc281aab3 100644 --- a/src/filters/modes/eax/eax.cpp +++ b/src/filters/modes/eax/eax.cpp @@ -19,11 +19,11 @@ namespace { /* * EAX MAC-based PRF */ -SecureVector<byte> eax_prf(byte tag, u32bit BLOCK_SIZE, +SecureVector<byte> eax_prf(byte tag, size_t BLOCK_SIZE, MessageAuthenticationCode* mac, - const byte in[], u32bit length) + const byte in[], size_t length) { - for(u32bit j = 0; j != BLOCK_SIZE - 1; ++j) + for(size_t j = 0; j != BLOCK_SIZE - 1; ++j) mac->update(0); mac->update(tag); mac->update(in, length); @@ -35,7 +35,7 @@ SecureVector<byte> eax_prf(byte tag, u32bit BLOCK_SIZE, /* * EAX_Base Constructor */ -EAX_Base::EAX_Base(BlockCipher* cipher, u32bit tag_size) : +EAX_Base::EAX_Base(BlockCipher* cipher, size_t tag_size) : BLOCK_SIZE(cipher->BLOCK_SIZE), TAG_SIZE(tag_size ? tag_size / 8 : BLOCK_SIZE), cipher_name(cipher->name()), @@ -51,7 +51,7 @@ EAX_Base::EAX_Base(BlockCipher* cipher, u32bit tag_size) : /* * Check if a keylength is valid for EAX */ -bool EAX_Base::valid_keylength(u32bit n) const +bool EAX_Base::valid_keylength(size_t n) const { if(!ctr->valid_keylength(n)) return false; @@ -78,7 +78,7 @@ void EAX_Base::set_key(const SymmetricKey& key) */ void EAX_Base::start_msg() { - for(u32bit j = 0; j != BLOCK_SIZE - 1; ++j) + for(size_t j = 0; j != BLOCK_SIZE - 1; ++j) cmac->update(0); cmac->update(2); } @@ -95,7 +95,7 @@ void EAX_Base::set_iv(const InitializationVector& iv) /* * Set the EAX header */ -void EAX_Base::set_header(const byte header[], u32bit length) +void EAX_Base::set_header(const byte header[], size_t length) { header_mac = eax_prf(1, BLOCK_SIZE, cmac, header, length); } @@ -111,11 +111,11 @@ std::string EAX_Base::name() const /* * Encrypt in EAX mode */ -void EAX_Encryption::write(const byte input[], u32bit length) +void EAX_Encryption::write(const byte input[], size_t length) { while(length) { - u32bit copied = std::min<u32bit>(length, ctr_buf.size()); + size_t copied = std::min<size_t>(length, ctr_buf.size()); ctr->cipher(input, &ctr_buf[0], copied); cmac->update(&ctr_buf[0], copied); diff --git a/src/filters/modes/eax/eax.h b/src/filters/modes/eax/eax.h index 8f79039d9..c3dd213a2 100644 --- a/src/filters/modes/eax/eax.h +++ b/src/filters/modes/eax/eax.h @@ -30,19 +30,19 @@ class BOTAN_DLL EAX_Base : public Keyed_Filter * @param header the header contents * @param header_len length of header in bytes */ - void set_header(const byte header[], u32bit header_len); + void set_header(const byte header[], size_t header_len); /** * @return name of this mode */ std::string name() const; - bool valid_keylength(u32bit key_len) const; + bool valid_keylength(size_t key_len) const; /** * EAX supports arbitrary IV lengths */ - bool valid_iv_length(u32bit) const { return true; } + bool valid_iv_length(size_t) const { return true; } ~EAX_Base() { delete ctr; delete cmac; } protected: @@ -50,10 +50,10 @@ class BOTAN_DLL EAX_Base : public Keyed_Filter * @param cipher the cipher to use * @param tag_size is how big the auth tag will be */ - EAX_Base(BlockCipher* cipher, u32bit tag_size); + EAX_Base(BlockCipher* cipher, size_t tag_size); void start_msg(); - const u32bit BLOCK_SIZE, TAG_SIZE; + const size_t BLOCK_SIZE, TAG_SIZE; std::string cipher_name; StreamCipher* ctr; @@ -73,7 +73,7 @@ class BOTAN_DLL EAX_Encryption : public EAX_Base * @param ciph the cipher to use * @param tag_size is how big the auth tag will be */ - EAX_Encryption(BlockCipher* ciph, u32bit tag_size = 0) : + EAX_Encryption(BlockCipher* ciph, size_t tag_size = 0) : EAX_Base(ciph, tag_size) {} /** @@ -84,13 +84,13 @@ class BOTAN_DLL EAX_Encryption : public EAX_Base */ EAX_Encryption(BlockCipher* ciph, const SymmetricKey& key, const InitializationVector& iv, - u32bit tag_size) : EAX_Base(ciph, tag_size) + size_t tag_size) : EAX_Base(ciph, tag_size) { set_key(key); set_iv(iv); } private: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); }; @@ -104,7 +104,7 @@ class BOTAN_DLL EAX_Decryption : public EAX_Base * @param ciph the cipher to use * @param tag_size is how big the auth tag will be */ - EAX_Decryption(BlockCipher* ciph, u32bit tag_size = 0); + EAX_Decryption(BlockCipher* ciph, size_t tag_size = 0); /** * @param ciph the cipher to use @@ -114,14 +114,14 @@ class BOTAN_DLL EAX_Decryption : public EAX_Base */ EAX_Decryption(BlockCipher* ciph, const SymmetricKey& key, const InitializationVector& iv, - u32bit tag_size = 0); + size_t tag_size = 0); private: - void write(const byte[], u32bit); - void do_write(const byte[], u32bit); + void write(const byte[], size_t); + void do_write(const byte[], size_t); void end_msg(); SecureVector<byte> queue; - u32bit queue_start, queue_end; + size_t queue_start, queue_end; }; } diff --git a/src/filters/modes/eax/eax_dec.cpp b/src/filters/modes/eax/eax_dec.cpp index 96e19efe4..72e2249ac 100644 --- a/src/filters/modes/eax/eax_dec.cpp +++ b/src/filters/modes/eax/eax_dec.cpp @@ -16,7 +16,7 @@ namespace Botan { * EAX_Decryption Constructor */ EAX_Decryption::EAX_Decryption(BlockCipher* ciph, - u32bit tag_size) : + size_t tag_size) : EAX_Base(ciph, tag_size) { queue.resize(2*TAG_SIZE + DEFAULT_BUFFERSIZE); @@ -29,7 +29,7 @@ EAX_Decryption::EAX_Decryption(BlockCipher* ciph, EAX_Decryption::EAX_Decryption(BlockCipher* ciph, const SymmetricKey& key, const InitializationVector& iv, - u32bit tag_size) : + size_t tag_size) : EAX_Base(ciph, tag_size) { set_key(key); @@ -41,11 +41,11 @@ EAX_Decryption::EAX_Decryption(BlockCipher* ciph, /* * Decrypt in EAX mode */ -void EAX_Decryption::write(const byte input[], u32bit length) +void EAX_Decryption::write(const byte input[], size_t length) { while(length) { - const u32bit copied = std::min<u32bit>(length, queue.size() - queue_end); + const size_t copied = std::min<size_t>(length, queue.size() - queue_end); queue.copy(queue_end, input, copied); input += copied; @@ -54,7 +54,7 @@ void EAX_Decryption::write(const byte input[], u32bit length) while((queue_end - queue_start) > TAG_SIZE) { - u32bit removed = (queue_end - queue_start) - TAG_SIZE; + size_t removed = (queue_end - queue_start) - TAG_SIZE; do_write(&queue[queue_start], removed); queue_start += removed; } @@ -74,11 +74,11 @@ void EAX_Decryption::write(const byte input[], u32bit length) /* * Decrypt in EAX mode */ -void EAX_Decryption::do_write(const byte input[], u32bit length) +void EAX_Decryption::do_write(const byte input[], size_t length) { while(length) { - u32bit copied = std::min<u32bit>(length, ctr_buf.size()); + size_t copied = std::min<size_t>(length, ctr_buf.size()); /* Process same block with cmac and ctr at the same time to @@ -102,7 +102,7 @@ void EAX_Decryption::end_msg() SecureVector<byte> data_mac = cmac->final(); - for(u32bit j = 0; j != TAG_SIZE; ++j) + for(size_t j = 0; j != TAG_SIZE; ++j) if(queue[queue_start+j] != (data_mac[j] ^ nonce_mac[j] ^ header_mac[j])) throw Decoding_Error(name() + ": Message authentication failure"); diff --git a/src/filters/modes/ecb/ecb.cpp b/src/filters/modes/ecb/ecb.cpp index d97fe4f49..2a3ecf6f9 100644 --- a/src/filters/modes/ecb/ecb.cpp +++ b/src/filters/modes/ecb/ecb.cpp @@ -58,7 +58,7 @@ std::string ECB_Encryption::name() const /* * Encrypt in ECB mode */ -void ECB_Encryption::write(const byte input[], u32bit length) +void ECB_Encryption::write(const byte input[], size_t length) { Buffered_Filter::write(input, length); } @@ -68,26 +68,26 @@ void ECB_Encryption::write(const byte input[], u32bit length) */ void ECB_Encryption::end_msg() { - u32bit last_block = current_position() % cipher->BLOCK_SIZE; + size_t last_block = current_position() % cipher->BLOCK_SIZE; SecureVector<byte> padding(cipher->BLOCK_SIZE); padder->pad(padding, padding.size(), last_block); - u32bit pad_bytes = padder->pad_bytes(cipher->BLOCK_SIZE, last_block); + size_t pad_bytes = padder->pad_bytes(cipher->BLOCK_SIZE, last_block); if(pad_bytes) Buffered_Filter::write(padding, pad_bytes); Buffered_Filter::end_msg(); } -void ECB_Encryption::buffered_block(const byte input[], u32bit input_length) +void ECB_Encryption::buffered_block(const byte input[], size_t input_length) { - const u32bit blocks_in_temp = temp.size() / cipher->BLOCK_SIZE; - u32bit blocks = input_length / cipher->BLOCK_SIZE; + const size_t blocks_in_temp = temp.size() / cipher->BLOCK_SIZE; + size_t blocks = input_length / cipher->BLOCK_SIZE; while(blocks) { - u32bit to_proc = std::min(blocks, blocks_in_temp); + size_t to_proc = std::min(blocks, blocks_in_temp); cipher->encrypt_n(input, &temp[0], to_proc); @@ -98,7 +98,7 @@ void ECB_Encryption::buffered_block(const byte input[], u32bit input_length) } } -void ECB_Encryption::buffered_final(const byte input[], u32bit input_length) +void ECB_Encryption::buffered_final(const byte input[], size_t input_length) { if(input_length % cipher->BLOCK_SIZE == 0) buffered_block(input, input_length); @@ -155,7 +155,7 @@ std::string ECB_Decryption::name() const /* * Decrypt in ECB mode */ -void ECB_Decryption::write(const byte input[], u32bit length) +void ECB_Decryption::write(const byte input[], size_t length) { Buffered_Filter::write(input, length); } @@ -171,14 +171,14 @@ void ECB_Decryption::end_msg() /* * Decrypt in ECB mode */ -void ECB_Decryption::buffered_block(const byte input[], u32bit length) +void ECB_Decryption::buffered_block(const byte input[], size_t length) { - const u32bit blocks_in_temp = temp.size() / cipher->BLOCK_SIZE; - u32bit blocks = length / cipher->BLOCK_SIZE; + const size_t blocks_in_temp = temp.size() / cipher->BLOCK_SIZE; + size_t blocks = length / cipher->BLOCK_SIZE; while(blocks) { - u32bit to_proc = std::min(blocks, blocks_in_temp); + size_t to_proc = std::min(blocks, blocks_in_temp); cipher->decrypt_n(input, &temp[0], to_proc); @@ -192,7 +192,7 @@ void ECB_Decryption::buffered_block(const byte input[], u32bit length) /* * Finish encrypting in ECB mode */ -void ECB_Decryption::buffered_final(const byte input[], u32bit length) +void ECB_Decryption::buffered_final(const byte input[], size_t length) { if(length == 0 || length % cipher->BLOCK_SIZE != 0) throw Decoding_Error(name() + ": Ciphertext not multiple of block size"); diff --git a/src/filters/modes/ecb/ecb.h b/src/filters/modes/ecb/ecb.h index eaf7fb143..94cff1f52 100644 --- a/src/filters/modes/ecb/ecb.h +++ b/src/filters/modes/ecb/ecb.h @@ -26,7 +26,7 @@ class BOTAN_DLL ECB_Encryption : public Keyed_Filter, void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } ECB_Encryption(BlockCipher* ciph, @@ -38,10 +38,10 @@ class BOTAN_DLL ECB_Encryption : public Keyed_Filter, ~ECB_Encryption(); private: - void buffered_block(const byte input[], u32bit input_length); - void buffered_final(const byte input[], u32bit input_length); + void buffered_block(const byte input[], size_t input_length); + void buffered_final(const byte input[], size_t input_length); - void write(const byte input[], u32bit input_length); + void write(const byte input[], size_t input_length); void end_msg(); BlockCipher* cipher; @@ -60,7 +60,7 @@ class BOTAN_DLL ECB_Decryption : public Keyed_Filter, void set_key(const SymmetricKey& key) { cipher->set_key(key); } - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } ECB_Decryption(BlockCipher* ciph, @@ -72,10 +72,10 @@ class BOTAN_DLL ECB_Decryption : public Keyed_Filter, ~ECB_Decryption(); private: - void buffered_block(const byte input[], u32bit input_length); - void buffered_final(const byte input[], u32bit input_length); + void buffered_block(const byte input[], size_t input_length); + void buffered_final(const byte input[], size_t input_length); - void write(const byte input[], u32bit input_length); + void write(const byte input[], size_t input_length); void end_msg(); BlockCipher* cipher; diff --git a/src/filters/modes/mode_pad/mode_pad.cpp b/src/filters/modes/mode_pad/mode_pad.cpp index 94f84fa03..5d3a152d6 100644 --- a/src/filters/modes/mode_pad/mode_pad.cpp +++ b/src/filters/modes/mode_pad/mode_pad.cpp @@ -13,7 +13,7 @@ namespace Botan { /* * Default amount of padding */ -u32bit BlockCipherModePaddingMethod::pad_bytes(u32bit bs, u32bit pos) const +size_t BlockCipherModePaddingMethod::pad_bytes(size_t bs, size_t pos) const { return (bs - pos); } @@ -21,21 +21,21 @@ u32bit BlockCipherModePaddingMethod::pad_bytes(u32bit bs, u32bit pos) const /* * Pad with PKCS #7 Method */ -void PKCS7_Padding::pad(byte block[], u32bit size, u32bit position) const +void PKCS7_Padding::pad(byte block[], size_t size, size_t position) const { - for(u32bit j = 0; j != size; ++j) + for(size_t j = 0; j != size; ++j) block[j] = (size-position); } /* * Unpad with PKCS #7 Method */ -u32bit PKCS7_Padding::unpad(const byte block[], u32bit size) const +size_t PKCS7_Padding::unpad(const byte block[], size_t size) const { - u32bit position = block[size-1]; + size_t position = block[size-1]; if(position > size) throw Decoding_Error(name()); - for(u32bit j = size-position; j != size-1; ++j) + for(size_t j = size-position; j != size-1; ++j) if(block[j] != position) throw Decoding_Error(name()); return (size-position); @@ -44,7 +44,7 @@ u32bit PKCS7_Padding::unpad(const byte block[], u32bit size) const /* * Query if the size is valid for this method */ -bool PKCS7_Padding::valid_blocksize(u32bit size) const +bool PKCS7_Padding::valid_blocksize(size_t size) const { if(size > 0 && size < 256) return true; @@ -55,9 +55,9 @@ bool PKCS7_Padding::valid_blocksize(u32bit size) const /* * Pad with ANSI X9.23 Method */ -void ANSI_X923_Padding::pad(byte block[], u32bit size, u32bit position) const +void ANSI_X923_Padding::pad(byte block[], size_t size, size_t position) const { - for(u32bit j = 0; j != size-position; ++j) + for(size_t j = 0; j != size-position; ++j) block[j] = 0; block[size-position-1] = (size-position); } @@ -65,12 +65,12 @@ void ANSI_X923_Padding::pad(byte block[], u32bit size, u32bit position) const /* * Unpad with ANSI X9.23 Method */ -u32bit ANSI_X923_Padding::unpad(const byte block[], u32bit size) const +size_t ANSI_X923_Padding::unpad(const byte block[], size_t size) const { - u32bit position = block[size-1]; + size_t position = block[size-1]; if(position > size) throw Decoding_Error(name()); - for(u32bit j = size-position; j != size-1; ++j) + for(size_t j = size-position; j != size-1; ++j) if(block[j] != 0) throw Decoding_Error(name()); return (size-position); @@ -79,7 +79,7 @@ u32bit ANSI_X923_Padding::unpad(const byte block[], u32bit size) const /* * Query if the size is valid for this method */ -bool ANSI_X923_Padding::valid_blocksize(u32bit size) const +bool ANSI_X923_Padding::valid_blocksize(size_t size) const { if(size > 0 && size < 256) return true; @@ -90,17 +90,17 @@ bool ANSI_X923_Padding::valid_blocksize(u32bit size) const /* * Pad with One and Zeros Method */ -void OneAndZeros_Padding::pad(byte block[], u32bit size, u32bit) const +void OneAndZeros_Padding::pad(byte block[], size_t size, size_t) const { block[0] = 0x80; - for(u32bit j = 1; j != size; ++j) + for(size_t j = 1; j != size; ++j) block[j] = 0x00; } /* * Unpad with One and Zeros Method */ -u32bit OneAndZeros_Padding::unpad(const byte block[], u32bit size) const +size_t OneAndZeros_Padding::unpad(const byte block[], size_t size) const { while(size) { @@ -118,7 +118,7 @@ u32bit OneAndZeros_Padding::unpad(const byte block[], u32bit size) const /* * Query if the size is valid for this method */ -bool OneAndZeros_Padding::valid_blocksize(u32bit size) const +bool OneAndZeros_Padding::valid_blocksize(size_t size) const { return (size > 0); } diff --git a/src/filters/modes/mode_pad/mode_pad.h b/src/filters/modes/mode_pad/mode_pad.h index d6d1c5298..48cda02f4 100644 --- a/src/filters/modes/mode_pad/mode_pad.h +++ b/src/filters/modes/mode_pad/mode_pad.h @@ -31,29 +31,29 @@ class BOTAN_DLL BlockCipherModePaddingMethod * @param current_position in the last block */ virtual void pad(byte block[], - u32bit size, - u32bit current_position) const = 0; + size_t size, + size_t current_position) const = 0; /** * @param block the last block * @param size the of the block */ - virtual u32bit unpad(const byte block[], - u32bit size) const = 0; + virtual size_t unpad(const byte block[], + size_t size) const = 0; /** * @param block_size of the cipher * @param position in the current block * @return number of padding bytes that will be appended */ - virtual u32bit pad_bytes(u32bit block_size, - u32bit position) const; + virtual size_t pad_bytes(size_t block_size, + size_t position) const; /** * @param block_size of the cipher * @return valid block size for this padding mode */ - virtual bool valid_blocksize(u32bit block_size) const = 0; + virtual bool valid_blocksize(size_t block_size) const = 0; /** * @return name of the mode @@ -72,9 +72,9 @@ class BOTAN_DLL BlockCipherModePaddingMethod class BOTAN_DLL PKCS7_Padding : public BlockCipherModePaddingMethod { public: - void pad(byte[], u32bit, u32bit) const; - u32bit unpad(const byte[], u32bit) const; - bool valid_blocksize(u32bit) const; + void pad(byte[], size_t, size_t) const; + size_t unpad(const byte[], size_t) const; + bool valid_blocksize(size_t) const; std::string name() const { return "PKCS7"; } }; @@ -84,9 +84,9 @@ class BOTAN_DLL PKCS7_Padding : public BlockCipherModePaddingMethod class BOTAN_DLL ANSI_X923_Padding : public BlockCipherModePaddingMethod { public: - void pad(byte[], u32bit, u32bit) const; - u32bit unpad(const byte[], u32bit) const; - bool valid_blocksize(u32bit) const; + void pad(byte[], size_t, size_t) const; + size_t unpad(const byte[], size_t) const; + bool valid_blocksize(size_t) const; std::string name() const { return "X9.23"; } }; @@ -96,9 +96,9 @@ class BOTAN_DLL ANSI_X923_Padding : public BlockCipherModePaddingMethod class BOTAN_DLL OneAndZeros_Padding : public BlockCipherModePaddingMethod { public: - void pad(byte[], u32bit, u32bit) const; - u32bit unpad(const byte[], u32bit) const; - bool valid_blocksize(u32bit) const; + void pad(byte[], size_t, size_t) const; + size_t unpad(const byte[], size_t) const; + bool valid_blocksize(size_t) const; std::string name() const { return "OneAndZeros"; } }; @@ -108,10 +108,10 @@ class BOTAN_DLL OneAndZeros_Padding : public BlockCipherModePaddingMethod class BOTAN_DLL Null_Padding : public BlockCipherModePaddingMethod { public: - void pad(byte[], u32bit, u32bit) const { return; } - u32bit unpad(const byte[], u32bit size) const { return size; } - u32bit pad_bytes(u32bit, u32bit) const { return 0; } - bool valid_blocksize(u32bit) const { return true; } + void pad(byte[], size_t, size_t) const { return; } + size_t unpad(const byte[], size_t size) const { return size; } + size_t pad_bytes(size_t, size_t) const { return 0; } + bool valid_blocksize(size_t) const { return true; } std::string name() const { return "NoPadding"; } }; diff --git a/src/filters/modes/xts/xts.cpp b/src/filters/modes/xts/xts.cpp index 54d043d58..176746d0f 100644 --- a/src/filters/modes/xts/xts.cpp +++ b/src/filters/modes/xts/xts.cpp @@ -14,12 +14,12 @@ namespace Botan { namespace { -void poly_double(byte tweak[], u32bit size) +void poly_double(byte tweak[], size_t size) { const byte polynomial = (size == 16) ? 0x87 : 0x1B; byte carry = 0; - for(u32bit i = 0; i != size; ++i) + for(size_t i = 0; i != size; ++i) { byte carry2 = (tweak[i] >> 7); tweak[i] = (tweak[i] << 1) | carry; @@ -33,9 +33,9 @@ void poly_double(byte tweak[], u32bit size) /* XTS needs to process at least 2 blocks in parallel because block_size+1 bytes are needed at the end */ -u32bit xts_parallelism(BlockCipher* cipher) +size_t xts_parallelism(BlockCipher* cipher) { - return std::max<u32bit>(cipher->parallel_bytes(), + return std::max<size_t>(cipher->parallel_bytes(), 2 * cipher->BLOCK_SIZE); } @@ -90,12 +90,12 @@ void XTS_Encryption::set_iv(const InitializationVector& iv) if(!valid_iv_length(iv.length())) throw Invalid_IV_Length(name(), iv.length()); - const u32bit blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; + const size_t blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; tweak.copy(iv.begin(), iv.length()); cipher2->encrypt(tweak); - for(u32bit i = 1; i < blocks_in_tweak; ++i) + for(size_t i = 1; i < blocks_in_tweak; ++i) { tweak.copy(i*cipher->BLOCK_SIZE, &tweak[(i-1)*cipher->BLOCK_SIZE], @@ -107,7 +107,7 @@ void XTS_Encryption::set_iv(const InitializationVector& iv) void XTS_Encryption::set_key(const SymmetricKey& key) { - u32bit key_half = key.length() / 2; + size_t key_half = key.length() / 2; if(key.length() % 2 == 1 || !cipher->valid_keylength(key_half)) throw Invalid_Key_Length(name(), key.length()); @@ -119,7 +119,7 @@ void XTS_Encryption::set_key(const SymmetricKey& key) /* * Encrypt in XTS mode */ -void XTS_Encryption::write(const byte input[], u32bit length) +void XTS_Encryption::write(const byte input[], size_t length) { Buffered_Filter::write(input, length); } @@ -131,17 +131,17 @@ void XTS_Encryption::end_msg() Buffered_Filter::end_msg(); } -void XTS_Encryption::buffered_block(const byte input[], u32bit length) +void XTS_Encryption::buffered_block(const byte input[], size_t length) { - const u32bit blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; - u32bit blocks = length / cipher->BLOCK_SIZE; + const size_t blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; + size_t blocks = length / cipher->BLOCK_SIZE; SecureVector<byte> temp(tweak.size()); while(blocks) { - u32bit to_proc = std::min(blocks, blocks_in_tweak); - u32bit to_proc_bytes = to_proc * cipher->BLOCK_SIZE; + size_t to_proc = std::min(blocks, blocks_in_tweak); + size_t to_proc_bytes = to_proc * cipher->BLOCK_SIZE; xor_buf(temp, input, tweak, to_proc_bytes); @@ -155,7 +155,7 @@ void XTS_Encryption::buffered_block(const byte input[], u32bit length) cipher->BLOCK_SIZE); poly_double(&tweak[0], cipher->BLOCK_SIZE); - for(u32bit i = 1; i < blocks_in_tweak; ++i) + for(size_t i = 1; i < blocks_in_tweak; ++i) { tweak.copy(i*cipher->BLOCK_SIZE, &tweak[(i-1)*cipher->BLOCK_SIZE], @@ -172,7 +172,7 @@ void XTS_Encryption::buffered_block(const byte input[], u32bit length) /* * Finish encrypting in XTS mode */ -void XTS_Encryption::buffered_final(const byte input[], u32bit length) +void XTS_Encryption::buffered_final(const byte input[], size_t length) { if(length <= cipher->BLOCK_SIZE) throw Encoding_Error("XTS_Encryption: insufficient data to encrypt"); @@ -184,7 +184,7 @@ void XTS_Encryption::buffered_final(const byte input[], u32bit length) else { // steal ciphertext - u32bit leftover_blocks = + size_t leftover_blocks = ((length / cipher->BLOCK_SIZE) - 1) * cipher->BLOCK_SIZE; buffered_block(input, leftover_blocks); @@ -200,7 +200,7 @@ void XTS_Encryption::buffered_final(const byte input[], u32bit length) poly_double(&tweak[0], cipher->BLOCK_SIZE); - for(u32bit i = 0; i != length - cipher->BLOCK_SIZE; ++i) + for(size_t i = 0; i != length - cipher->BLOCK_SIZE; ++i) std::swap(temp[i], temp[i + cipher->BLOCK_SIZE]); xor_buf(temp, tweak, cipher->BLOCK_SIZE); @@ -262,12 +262,12 @@ void XTS_Decryption::set_iv(const InitializationVector& iv) if(!valid_iv_length(iv.length())) throw Invalid_IV_Length(name(), iv.length()); - const u32bit blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; + const size_t blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; tweak.copy(iv.begin(), iv.length()); cipher2->encrypt(tweak); - for(u32bit i = 1; i < blocks_in_tweak; ++i) + for(size_t i = 1; i < blocks_in_tweak; ++i) { tweak.copy(i*cipher->BLOCK_SIZE, &tweak[(i-1)*cipher->BLOCK_SIZE], @@ -279,7 +279,7 @@ void XTS_Decryption::set_iv(const InitializationVector& iv) void XTS_Decryption::set_key(const SymmetricKey& key) { - u32bit key_half = key.length() / 2; + size_t key_half = key.length() / 2; if(key.length() % 2 == 1 || !cipher->valid_keylength(key_half)) throw Invalid_Key_Length(name(), key.length()); @@ -291,7 +291,7 @@ void XTS_Decryption::set_key(const SymmetricKey& key) /* * Decrypt in XTS mode */ -void XTS_Decryption::write(const byte input[], u32bit length) +void XTS_Decryption::write(const byte input[], size_t length) { Buffered_Filter::write(input, length); } @@ -304,17 +304,17 @@ void XTS_Decryption::end_msg() Buffered_Filter::end_msg(); } -void XTS_Decryption::buffered_block(const byte input[], u32bit input_length) +void XTS_Decryption::buffered_block(const byte input[], size_t input_length) { - const u32bit blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; - u32bit blocks = input_length / cipher->BLOCK_SIZE; + const size_t blocks_in_tweak = tweak.size() / cipher->BLOCK_SIZE; + size_t blocks = input_length / cipher->BLOCK_SIZE; SecureVector<byte> temp(tweak.size()); while(blocks) { - u32bit to_proc = std::min(blocks, blocks_in_tweak); - u32bit to_proc_bytes = to_proc * cipher->BLOCK_SIZE; + size_t to_proc = std::min(blocks, blocks_in_tweak); + size_t to_proc_bytes = to_proc * cipher->BLOCK_SIZE; xor_buf(temp, input, tweak, to_proc_bytes); @@ -328,7 +328,7 @@ void XTS_Decryption::buffered_block(const byte input[], u32bit input_length) cipher->BLOCK_SIZE); poly_double(&tweak[0], cipher->BLOCK_SIZE); - for(u32bit i = 1; i < blocks_in_tweak; ++i) + for(size_t i = 1; i < blocks_in_tweak; ++i) { tweak.copy(i*cipher->BLOCK_SIZE, &tweak[(i-1)*cipher->BLOCK_SIZE], @@ -342,7 +342,7 @@ void XTS_Decryption::buffered_block(const byte input[], u32bit input_length) } } -void XTS_Decryption::buffered_final(const byte input[], u32bit length) +void XTS_Decryption::buffered_final(const byte input[], size_t length) { if(length <= cipher->BLOCK_SIZE) throw Decoding_Error("XTS_Decryption: insufficient data to decrypt"); @@ -353,7 +353,7 @@ void XTS_Decryption::buffered_final(const byte input[], u32bit length) } else { - u32bit leftover_blocks = + size_t leftover_blocks = ((length / cipher->BLOCK_SIZE) - 1) * cipher->BLOCK_SIZE; buffered_block(input, leftover_blocks); @@ -370,7 +370,7 @@ void XTS_Decryption::buffered_final(const byte input[], u32bit length) cipher->decrypt(temp); xor_buf(temp, tweak_copy, cipher->BLOCK_SIZE); - for(u32bit i = 0; i != length - cipher->BLOCK_SIZE; ++i) + for(size_t i = 0; i != length - cipher->BLOCK_SIZE; ++i) std::swap(temp[i], temp[i + cipher->BLOCK_SIZE]); xor_buf(temp, tweak, cipher->BLOCK_SIZE); diff --git a/src/filters/modes/xts/xts.h b/src/filters/modes/xts/xts.h index 67c087c72..0cf7080bd 100644 --- a/src/filters/modes/xts/xts.h +++ b/src/filters/modes/xts/xts.h @@ -24,10 +24,10 @@ class BOTAN_DLL XTS_Encryption : public Keyed_Filter, void set_key(const SymmetricKey& key); void set_iv(const InitializationVector& iv); - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } std::string name() const; @@ -40,11 +40,11 @@ class BOTAN_DLL XTS_Encryption : public Keyed_Filter, ~XTS_Encryption() { delete cipher; delete cipher2; } private: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); - void buffered_block(const byte input[], u32bit input_length); - void buffered_final(const byte input[], u32bit input_length); + void buffered_block(const byte input[], size_t input_length); + void buffered_final(const byte input[], size_t input_length); BlockCipher* cipher; BlockCipher* cipher2; @@ -61,10 +61,10 @@ class BOTAN_DLL XTS_Decryption : public Keyed_Filter, void set_key(const SymmetricKey& key); void set_iv(const InitializationVector& iv); - bool valid_keylength(u32bit key_len) const + bool valid_keylength(size_t key_len) const { return cipher->valid_keylength(key_len); } - bool valid_iv_length(u32bit iv_len) const + bool valid_iv_length(size_t iv_len) const { return (iv_len == cipher->BLOCK_SIZE); } std::string name() const; @@ -77,11 +77,11 @@ class BOTAN_DLL XTS_Decryption : public Keyed_Filter, ~XTS_Decryption() { delete cipher; delete cipher2; } private: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); - void buffered_block(const byte input[], u32bit input_length); - void buffered_final(const byte input[], u32bit input_length); + void buffered_block(const byte input[], size_t input_length); + void buffered_final(const byte input[], size_t input_length); BlockCipher* cipher; BlockCipher* cipher2; diff --git a/src/filters/out_buf.cpp b/src/filters/out_buf.cpp index f00cbb866..7fa13b8e3 100644 --- a/src/filters/out_buf.cpp +++ b/src/filters/out_buf.cpp @@ -14,7 +14,7 @@ namespace Botan { /* * Read data from a message */ -u32bit Output_Buffers::read(byte output[], u32bit length, +size_t Output_Buffers::read(byte output[], size_t length, Pipe::message_id msg) { SecureQueue* q = get(msg); @@ -26,8 +26,8 @@ u32bit Output_Buffers::read(byte output[], u32bit length, /* * Peek at data in a message */ -u32bit Output_Buffers::peek(byte output[], u32bit length, - u32bit stream_offset, +size_t Output_Buffers::peek(byte output[], size_t length, + size_t stream_offset, Pipe::message_id msg) const { SecureQueue* q = get(msg); @@ -39,7 +39,7 @@ u32bit Output_Buffers::peek(byte output[], u32bit length, /* * Check available bytes in a message */ -u32bit Output_Buffers::remaining(Pipe::message_id msg) const +size_t Output_Buffers::remaining(Pipe::message_id msg) const { SecureQueue* q = get(msg); if(q) @@ -113,7 +113,7 @@ Output_Buffers::Output_Buffers() */ Output_Buffers::~Output_Buffers() { - for(u32bit j = 0; j != buffers.size(); ++j) + for(size_t j = 0; j != buffers.size(); ++j) delete buffers[j]; } diff --git a/src/filters/out_buf.h b/src/filters/out_buf.h index 120729de4..d4244ca5e 100644 --- a/src/filters/out_buf.h +++ b/src/filters/out_buf.h @@ -20,9 +20,9 @@ namespace Botan { class Output_Buffers { public: - u32bit read(byte[], u32bit, Pipe::message_id); - u32bit peek(byte[], u32bit, u32bit, Pipe::message_id) const; - u32bit remaining(Pipe::message_id) const; + size_t read(byte[], size_t, Pipe::message_id); + size_t peek(byte[], size_t, size_t, Pipe::message_id) const; + size_t remaining(Pipe::message_id) const; void add(class SecureQueue*); void retire(); diff --git a/src/filters/pipe.cpp b/src/filters/pipe.cpp index cba5449de..3c3b5e6a4 100644 --- a/src/filters/pipe.cpp +++ b/src/filters/pipe.cpp @@ -20,7 +20,7 @@ namespace { class Null_Filter : public Filter { public: - void write(const byte input[], u32bit length) + void write(const byte input[], size_t length) { send(input, length); } std::string name() const { return "Null"; } @@ -43,10 +43,10 @@ Pipe::Pipe(Filter* f1, Filter* f2, Filter* f3, Filter* f4) /* * Pipe Constructor */ -Pipe::Pipe(Filter* filter_array[], u32bit count) +Pipe::Pipe(Filter* filter_array[], size_t count) { init(); - for(u32bit j = 0; j != count; ++j) + for(size_t j = 0; j != count; ++j) append(filter_array[j]); } @@ -89,7 +89,7 @@ void Pipe::destruct(Filter* to_kill) { if(!to_kill || dynamic_cast<SecureQueue*>(to_kill)) return; - for(u32bit j = 0; j != to_kill->total_ports(); ++j) + for(size_t j = 0; j != to_kill->total_ports(); ++j) destruct(to_kill->next[j]); delete to_kill; } @@ -115,7 +115,7 @@ void Pipe::set_default_msg(message_id msg) /* * Process a full message at once */ -void Pipe::process_msg(const byte input[], u32bit length) +void Pipe::process_msg(const byte input[], size_t length) { start_msg(); write(input, length); @@ -186,7 +186,7 @@ void Pipe::end_msg() */ void Pipe::find_endpoints(Filter* f) { - for(u32bit j = 0; j != f->total_ports(); ++j) + for(size_t j = 0; j != f->total_ports(); ++j) if(f->next[j] && !dynamic_cast<SecureQueue*>(f->next[j])) find_endpoints(f->next[j]); else @@ -203,7 +203,7 @@ void Pipe::find_endpoints(Filter* f) void Pipe::clear_endpoints(Filter* f) { if(!f) return; - for(u32bit j = 0; j != f->total_ports(); ++j) + for(size_t j = 0; j != f->total_ports(); ++j) { if(f->next[j] && dynamic_cast<SecureQueue*>(f->next[j])) f->next[j] = 0; @@ -266,7 +266,7 @@ void Pipe::pop() throw Invalid_State("Cannot pop off a Filter with multiple ports"); Filter* f = pipe; - u32bit owns = f->owns(); + size_t owns = f->owns(); pipe = pipe->next[0]; delete f; diff --git a/src/filters/pipe.h b/src/filters/pipe.h index b7f09199b..5d2ccf81e 100644 --- a/src/filters/pipe.h +++ b/src/filters/pipe.h @@ -28,7 +28,7 @@ class BOTAN_DLL Pipe : public DataSource /* * An opaque type that identifies a message in this Pipe */ - typedef u32bit message_id; + typedef size_t message_id; /** * Exception if you use an invalid message as an argument to @@ -61,7 +61,7 @@ class BOTAN_DLL Pipe : public DataSource * @param in the byte array to write * @param length the length of the byte array in */ - void write(const byte in[], u32bit length); + void write(const byte in[], size_t length); /** * Write input to the pipe, i.e. to its first filter. @@ -92,7 +92,7 @@ class BOTAN_DLL Pipe : public DataSource * @param in the byte array containing the data to write * @param length the length of the byte array to write */ - void process_msg(const byte in[], u32bit length); + void process_msg(const byte in[], size_t length); /** * Perform start_msg(), write() and end_msg() sequentially. @@ -118,7 +118,7 @@ class BOTAN_DLL Pipe : public DataSource * for which the information is desired * @return number of bytes that can still be read */ - u32bit remaining(message_id msg = DEFAULT_MESSAGE) const; + size_t remaining(message_id msg = DEFAULT_MESSAGE) const; /** * Read the default message from the pipe. Moves the internal @@ -129,7 +129,7 @@ class BOTAN_DLL Pipe : public DataSource * @param length the length of the byte array output * @return number of bytes actually read into output */ - u32bit read(byte output[], u32bit length); + size_t read(byte output[], size_t length); /** * Read a specified message from the pipe. Moves the internal @@ -140,7 +140,7 @@ class BOTAN_DLL Pipe : public DataSource * @param msg the number identifying the message to read from * @return number of bytes actually read into output */ - u32bit read(byte output[], u32bit length, message_id msg); + size_t read(byte output[], size_t length, message_id msg); /** * Read a single byte from the pipe. Moves the internal offset so @@ -151,7 +151,7 @@ class BOTAN_DLL Pipe : public DataSource * @param msg the message to read from * @return number of bytes actually read into output */ - u32bit read(byte& output, message_id msg = DEFAULT_MESSAGE); + size_t read(byte& output, message_id msg = DEFAULT_MESSAGE); /** * Read the full contents of the pipe. @@ -175,7 +175,7 @@ class BOTAN_DLL Pipe : public DataSource * @param offset the offset from the current position in message * @return number of bytes actually peeked and written into output */ - u32bit peek(byte output[], u32bit length, u32bit offset) const; + size_t peek(byte output[], size_t length, size_t offset) const; /** Read from the specified message but do not modify the * internal offset. Consecutive calls to peek() will return @@ -186,8 +186,8 @@ class BOTAN_DLL Pipe : public DataSource * @param msg the number identifying the message to peek from * @return number of bytes actually peeked and written into output */ - u32bit peek(byte output[], u32bit length, - u32bit offset, message_id msg) const; + size_t peek(byte output[], size_t length, + size_t offset, message_id msg) const; /** Read a single byte from the specified message but do not * modify the internal offset. Consecutive calls to peek() will @@ -197,13 +197,13 @@ class BOTAN_DLL Pipe : public DataSource * @param msg the number identifying the message to peek from * @return number of bytes actually peeked and written into output */ - u32bit peek(byte& output, u32bit offset, + size_t peek(byte& output, size_t offset, message_id msg = DEFAULT_MESSAGE) const; /** * @return currently set default message */ - u32bit default_msg() const { return default_read; } + size_t default_msg() const { return default_read; } /** * Set the default message @@ -268,7 +268,7 @@ class BOTAN_DLL Pipe : public DataSource * @param filters the set of filters to use * @param count the number of elements in filters */ - Pipe(Filter* filters[], u32bit count); + Pipe(Filter* filters[], size_t count); ~Pipe(); private: Pipe(const Pipe&) : DataSource() {} diff --git a/src/filters/pipe_io.cpp b/src/filters/pipe_io.cpp index 7c3ed689e..9dd0ad0bb 100644 --- a/src/filters/pipe_io.cpp +++ b/src/filters/pipe_io.cpp @@ -18,7 +18,7 @@ std::ostream& operator<<(std::ostream& stream, Pipe& pipe) SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); while(stream.good() && pipe.remaining()) { - u32bit got = pipe.read(&buffer[0], buffer.size()); + size_t got = pipe.read(&buffer[0], buffer.size()); stream.write(reinterpret_cast<const char*>(&buffer[0]), got); } if(!stream.good()) diff --git a/src/filters/pipe_rw.cpp b/src/filters/pipe_rw.cpp index 937262e26..90af9ed34 100644 --- a/src/filters/pipe_rw.cpp +++ b/src/filters/pipe_rw.cpp @@ -31,7 +31,7 @@ Pipe::message_id Pipe::get_message_no(const std::string& func_name, /* * Write into a Pipe */ -void Pipe::write(const byte input[], u32bit length) +void Pipe::write(const byte input[], size_t length) { if(!inside_msg) throw Invalid_State("Cannot write to a Pipe while it is not processing"); @@ -70,7 +70,7 @@ void Pipe::write(DataSource& source) SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); while(!source.end_of_data()) { - u32bit got = source.read(&buffer[0], buffer.size()); + size_t got = source.read(&buffer[0], buffer.size()); write(&buffer[0], got); } } @@ -78,7 +78,7 @@ void Pipe::write(DataSource& source) /* * Read some data from the pipe */ -u32bit Pipe::read(byte output[], u32bit length, message_id msg) +size_t Pipe::read(byte output[], size_t length, message_id msg) { return outputs->read(output, length, get_message_no("read", msg)); } @@ -86,7 +86,7 @@ u32bit Pipe::read(byte output[], u32bit length, message_id msg) /* * Read some data from the pipe */ -u32bit Pipe::read(byte output[], u32bit length) +size_t Pipe::read(byte output[], size_t length) { return read(output, length, DEFAULT_MESSAGE); } @@ -94,7 +94,7 @@ u32bit Pipe::read(byte output[], u32bit length) /* * Read a single byte from the pipe */ -u32bit Pipe::read(byte& out, message_id msg) +size_t Pipe::read(byte& out, message_id msg) { return read(&out, 1, msg); } @@ -106,7 +106,7 @@ SecureVector<byte> Pipe::read_all(message_id msg) { msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg()); SecureVector<byte> buffer(remaining(msg)); - u32bit got = read(&buffer[0], buffer.size(), msg); + size_t got = read(&buffer[0], buffer.size(), msg); buffer.resize(got); return buffer; } @@ -123,7 +123,7 @@ std::string Pipe::read_all_as_string(message_id msg) while(true) { - u32bit got = read(&buffer[0], buffer.size(), msg); + size_t got = read(&buffer[0], buffer.size(), msg); if(got == 0) break; str.append(reinterpret_cast<const char*>(&buffer[0]), got); @@ -135,7 +135,7 @@ std::string Pipe::read_all_as_string(message_id msg) /* * Find out how many bytes are ready to read */ -u32bit Pipe::remaining(message_id msg) const +size_t Pipe::remaining(message_id msg) const { return outputs->remaining(get_message_no("remaining", msg)); } @@ -143,8 +143,8 @@ u32bit Pipe::remaining(message_id msg) const /* * Peek at some data in the pipe */ -u32bit Pipe::peek(byte output[], u32bit length, - u32bit offset, message_id msg) const +size_t Pipe::peek(byte output[], size_t length, + size_t offset, message_id msg) const { return outputs->peek(output, length, offset, get_message_no("peek", msg)); } @@ -152,7 +152,7 @@ u32bit Pipe::peek(byte output[], u32bit length, /* * Peek at some data in the pipe */ -u32bit Pipe::peek(byte output[], u32bit length, u32bit offset) const +size_t Pipe::peek(byte output[], size_t length, size_t offset) const { return peek(output, length, offset, DEFAULT_MESSAGE); } @@ -160,7 +160,7 @@ u32bit Pipe::peek(byte output[], u32bit length, u32bit offset) const /* * Peek at a byte in the pipe */ -u32bit Pipe::peek(byte& out, u32bit offset, message_id msg) const +size_t Pipe::peek(byte& out, size_t offset, message_id msg) const { return peek(&out, 1, offset, msg); } diff --git a/src/filters/pk_filts/pk_filts.cpp b/src/filters/pk_filts/pk_filts.cpp index 7e566e4fa..a0a8095d6 100644 --- a/src/filters/pk_filts/pk_filts.cpp +++ b/src/filters/pk_filts/pk_filts.cpp @@ -12,7 +12,7 @@ namespace Botan { /* * Append to the buffer */ -void PK_Encryptor_Filter::write(const byte input[], u32bit length) +void PK_Encryptor_Filter::write(const byte input[], size_t length) { buffer += std::make_pair(input, length); } @@ -29,7 +29,7 @@ void PK_Encryptor_Filter::end_msg() /* * Append to the buffer */ -void PK_Decryptor_Filter::write(const byte input[], u32bit length) +void PK_Decryptor_Filter::write(const byte input[], size_t length) { buffer += std::make_pair(input, length); } @@ -46,7 +46,7 @@ void PK_Decryptor_Filter::end_msg() /* * Add more data */ -void PK_Signer_Filter::write(const byte input[], u32bit length) +void PK_Signer_Filter::write(const byte input[], size_t length) { signer->update(input, length); } @@ -62,7 +62,7 @@ void PK_Signer_Filter::end_msg() /* * Add more data */ -void PK_Verifier_Filter::write(const byte input[], u32bit length) +void PK_Verifier_Filter::write(const byte input[], size_t length) { verifier->update(input, length); } @@ -81,7 +81,7 @@ void PK_Verifier_Filter::end_msg() /* * Set the signature to check */ -void PK_Verifier_Filter::set_signature(const byte sig[], u32bit length) +void PK_Verifier_Filter::set_signature(const byte sig[], size_t length) { signature.set(sig, length); } @@ -98,7 +98,7 @@ void PK_Verifier_Filter::set_signature(const MemoryRegion<byte>& sig) * PK_Verifier_Filter Constructor */ PK_Verifier_Filter::PK_Verifier_Filter(PK_Verifier* v, const byte sig[], - u32bit length) : + size_t length) : verifier(v), signature(sig, length) { } diff --git a/src/filters/pk_filts/pk_filts.h b/src/filters/pk_filts/pk_filts.h index 81d6c9008..dd67e389b 100644 --- a/src/filters/pk_filts/pk_filts.h +++ b/src/filters/pk_filts/pk_filts.h @@ -19,7 +19,7 @@ namespace Botan { class BOTAN_DLL PK_Encryptor_Filter : public Filter { public: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); PK_Encryptor_Filter(PK_Encryptor* c, RandomNumberGenerator& rng_ref) : @@ -37,7 +37,7 @@ class BOTAN_DLL PK_Encryptor_Filter : public Filter class BOTAN_DLL PK_Decryptor_Filter : public Filter { public: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); PK_Decryptor_Filter(PK_Decryptor* c) : cipher(c) {} ~PK_Decryptor_Filter() { delete cipher; } @@ -52,7 +52,7 @@ class BOTAN_DLL PK_Decryptor_Filter : public Filter class BOTAN_DLL PK_Signer_Filter : public Filter { public: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); PK_Signer_Filter(PK_Signer* s, @@ -71,14 +71,14 @@ class BOTAN_DLL PK_Signer_Filter : public Filter class BOTAN_DLL PK_Verifier_Filter : public Filter { public: - void write(const byte[], u32bit); + void write(const byte[], size_t); void end_msg(); - void set_signature(const byte[], u32bit); + void set_signature(const byte[], size_t); void set_signature(const MemoryRegion<byte>&); PK_Verifier_Filter(PK_Verifier* v) : verifier(v) {} - PK_Verifier_Filter(PK_Verifier*, const byte[], u32bit); + PK_Verifier_Filter(PK_Verifier*, const byte[], size_t); PK_Verifier_Filter(PK_Verifier*, const MemoryRegion<byte>&); ~PK_Verifier_Filter() { delete verifier; } private: diff --git a/src/filters/secqueue.cpp b/src/filters/secqueue.cpp index fb3bbf526..8dc95ea99 100644 --- a/src/filters/secqueue.cpp +++ b/src/filters/secqueue.cpp @@ -21,37 +21,37 @@ class SecureQueueNode ~SecureQueueNode() { next = 0; start = end = 0; } - u32bit write(const byte input[], u32bit length) + size_t write(const byte input[], size_t length) { - u32bit copied = std::min<u32bit>(length, buffer.size() - end); + size_t copied = std::min<size_t>(length, buffer.size() - end); copy_mem(&buffer[end], input, copied); end += copied; return copied; } - u32bit read(byte output[], u32bit length) + size_t read(byte output[], size_t length) { - u32bit copied = std::min(length, end - start); + size_t copied = std::min(length, end - start); copy_mem(output, &buffer[start], copied); start += copied; return copied; } - u32bit peek(byte output[], u32bit length, u32bit offset = 0) + size_t peek(byte output[], size_t length, size_t offset = 0) { - const u32bit left = end - start; + const size_t left = end - start; if(offset >= left) return 0; - u32bit copied = std::min(length, left - offset); + size_t copied = std::min(length, left - offset); copy_mem(output, &buffer[start + offset], copied); return copied; } - u32bit size() const { return (end - start); } + size_t size() const { return (end - start); } private: friend class SecureQueue; SecureQueueNode* next; SecureVector<byte> buffer; - u32bit start, end; + size_t start, end; }; /* @@ -114,13 +114,13 @@ SecureQueue& SecureQueue::operator=(const SecureQueue& input) /* * Add some bytes to the queue */ -void SecureQueue::write(const byte input[], u32bit length) +void SecureQueue::write(const byte input[], size_t length) { if(!head) head = tail = new SecureQueueNode; while(length) { - const u32bit n = tail->write(input, length); + const size_t n = tail->write(input, length); input += n; length -= n; if(length) @@ -134,12 +134,12 @@ void SecureQueue::write(const byte input[], u32bit length) /* * Read some bytes from the queue */ -u32bit SecureQueue::read(byte output[], u32bit length) +size_t SecureQueue::read(byte output[], size_t length) { - u32bit got = 0; + size_t got = 0; while(length && head) { - const u32bit n = head->read(output, length); + const size_t n = head->read(output, length); output += n; got += n; length -= n; @@ -156,7 +156,7 @@ u32bit SecureQueue::read(byte output[], u32bit length) /* * Read data, but do not remove it from queue */ -u32bit SecureQueue::peek(byte output[], u32bit length, u32bit offset) const +size_t SecureQueue::peek(byte output[], size_t length, size_t offset) const { SecureQueueNode* current = head; @@ -171,10 +171,10 @@ u32bit SecureQueue::peek(byte output[], u32bit length, u32bit offset) const break; } - u32bit got = 0; + size_t got = 0; while(length && current) { - const u32bit n = current->peek(output, length, offset); + const size_t n = current->peek(output, length, offset); offset = 0; output += n; got += n; @@ -187,10 +187,10 @@ u32bit SecureQueue::peek(byte output[], u32bit length, u32bit offset) const /* * Return how many bytes the queue holds */ -u32bit SecureQueue::size() const +size_t SecureQueue::size() const { SecureQueueNode* current = head; - u32bit count = 0; + size_t count = 0; while(current) { diff --git a/src/filters/secqueue.h b/src/filters/secqueue.h index 483a31d60..82d70ef27 100644 --- a/src/filters/secqueue.h +++ b/src/filters/secqueue.h @@ -21,13 +21,13 @@ class BOTAN_DLL SecureQueue : public Fanout_Filter, public DataSource public: std::string name() const { return "Queue"; } - void write(const byte[], u32bit); + void write(const byte[], size_t); - u32bit read(byte[], u32bit); - u32bit peek(byte[], u32bit, u32bit = 0) const; + size_t read(byte[], size_t); + size_t peek(byte[], size_t, size_t = 0) const; bool end_of_data() const; - u32bit size() const; + size_t size() const; bool attachable() { return false; } SecureQueue& operator=(const SecureQueue&); diff --git a/src/filters/zlib/zlib.cpp b/src/filters/zlib/zlib.cpp index 6d8a22b9e..30dee0225 100644 --- a/src/filters/zlib/zlib.cpp +++ b/src/filters/zlib/zlib.cpp @@ -24,7 +24,7 @@ namespace { class Zlib_Alloc_Info { public: - std::map<void*, u32bit> current_allocs; + std::map<void*, size_t> current_allocs; Allocator* alloc; Zlib_Alloc_Info() { alloc = Allocator::get(false); } @@ -47,7 +47,7 @@ void* zlib_malloc(void* info_ptr, unsigned int n, unsigned int size) void zlib_free(void* info_ptr, void* ptr) { Zlib_Alloc_Info* info = static_cast<Zlib_Alloc_Info*>(info_ptr); - std::map<void*, u32bit>::const_iterator i = info->current_allocs.find(ptr); + std::map<void*, size_t>::const_iterator i = info->current_allocs.find(ptr); if(i == info->current_allocs.end()) throw Invalid_Argument("zlib_free: Got pointer not allocated by us"); info->alloc->deallocate(ptr, i->second); @@ -91,7 +91,7 @@ class Zlib_Stream /* * Zlib_Compression Constructor */ -Zlib_Compression::Zlib_Compression(u32bit l) : +Zlib_Compression::Zlib_Compression(size_t l) : level((l >= 9) ? 9 : l), buffer(DEFAULT_BUFFERSIZE) { zlib = 0; @@ -111,7 +111,7 @@ void Zlib_Compression::start_msg() /* * Compress Input with Zlib */ -void Zlib_Compression::write(const byte input[], u32bit length) +void Zlib_Compression::write(const byte input[], size_t length) { zlib->stream.next_in = static_cast<Bytef*>(const_cast<byte*>(input)); zlib->stream.avail_in = length; @@ -203,7 +203,7 @@ void Zlib_Decompression::start_msg() /* * Decompress Input with Zlib */ -void Zlib_Decompression::write(const byte input_arr[], u32bit length) +void Zlib_Decompression::write(const byte input_arr[], size_t length) { if(length) no_writes = false; @@ -237,7 +237,7 @@ void Zlib_Decompression::write(const byte input_arr[], u32bit length) if(rc == Z_STREAM_END) { - u32bit read_from_block = length - zlib->stream.avail_in; + size_t read_from_block = length - zlib->stream.avail_in; start_msg(); zlib->stream.next_in = input + read_from_block; diff --git a/src/filters/zlib/zlib.h b/src/filters/zlib/zlib.h index e1645e1ee..77ec5eecc 100644 --- a/src/filters/zlib/zlib.h +++ b/src/filters/zlib/zlib.h @@ -21,7 +21,7 @@ class BOTAN_DLL Zlib_Compression : public Filter public: std::string name() const { return "Zlib_Compression"; } - void write(const byte input[], u32bit length); + void write(const byte input[], size_t length); void start_msg(); void end_msg(); @@ -34,12 +34,12 @@ class BOTAN_DLL Zlib_Compression : public Filter @param level how much effort to use on compressing (0 to 9); higher levels are slower but tend to give better compression */ - Zlib_Compression(u32bit level = 6); + Zlib_Compression(size_t level = 6); ~Zlib_Compression() { clear(); } private: void clear(); - const u32bit level; + const size_t level; SecureVector<byte> buffer; class Zlib_Stream* zlib; }; @@ -52,7 +52,7 @@ class BOTAN_DLL Zlib_Decompression : public Filter public: std::string name() const { return "Zlib_Decompression"; } - void write(const byte input[], u32bit length); + void write(const byte input[], size_t length); void start_msg(); void end_msg(); diff --git a/src/pbe/pbes1/pbes1.cpp b/src/pbe/pbes1/pbes1.cpp index c1d34f9e3..994b02d0a 100644 --- a/src/pbe/pbes1/pbes1.cpp +++ b/src/pbe/pbes1/pbes1.cpp @@ -17,11 +17,11 @@ namespace Botan { /* * Encrypt some bytes using PBES1 */ -void PBE_PKCS5v15::write(const byte input[], u32bit length) +void PBE_PKCS5v15::write(const byte input[], size_t length) { while(length) { - u32bit put = std::min(DEFAULT_BUFFERSIZE, length); + size_t put = std::min(DEFAULT_BUFFERSIZE, length); pipe.write(input, length); flush_pipe(true); length -= put; @@ -68,7 +68,7 @@ void PBE_PKCS5v15::flush_pipe(bool safe_to_skip) SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); while(pipe.remaining()) { - u32bit got = pipe.read(&buffer[0], buffer.size()); + size_t got = pipe.read(&buffer[0], buffer.size()); send(buffer, got); } } diff --git a/src/pbe/pbes1/pbes1.h b/src/pbe/pbes1/pbes1.h index dcce38e24..dd991a515 100644 --- a/src/pbe/pbes1/pbes1.h +++ b/src/pbe/pbes1/pbes1.h @@ -23,7 +23,7 @@ class BOTAN_DLL PBE_PKCS5v15 : public PBE public: std::string name() const; - void write(const byte[], u32bit); + void write(const byte[], size_t); void start_msg(); void end_msg(); diff --git a/src/pbe/pbes2/pbes2.cpp b/src/pbe/pbes2/pbes2.cpp index 0e8b3fb86..7188e42d7 100644 --- a/src/pbe/pbes2/pbes2.cpp +++ b/src/pbe/pbes2/pbes2.cpp @@ -24,11 +24,11 @@ namespace Botan { /* * Encrypt some bytes using PBES2 */ -void PBE_PKCS5v20::write(const byte input[], u32bit length) +void PBE_PKCS5v20::write(const byte input[], size_t length) { while(length) { - u32bit put = std::min(DEFAULT_BUFFERSIZE, length); + size_t put = std::min(DEFAULT_BUFFERSIZE, length); pipe.write(input, length); flush_pipe(true); length -= put; @@ -75,7 +75,7 @@ void PBE_PKCS5v20::flush_pipe(bool safe_to_skip) SecureVector<byte> buffer(DEFAULT_BUFFERSIZE); while(pipe.remaining()) { - u32bit got = pipe.read(&buffer[0], buffer.size()); + size_t got = pipe.read(&buffer[0], buffer.size()); send(buffer, got); } } diff --git a/src/pbe/pbes2/pbes2.h b/src/pbe/pbes2/pbes2.h index 4a021840a..1c7119e3a 100644 --- a/src/pbe/pbes2/pbes2.h +++ b/src/pbe/pbes2/pbes2.h @@ -29,7 +29,7 @@ class BOTAN_DLL PBE_PKCS5v20 : public PBE std::string name() const; - void write(const byte[], u32bit); + void write(const byte[], size_t); void start_msg(); void end_msg(); diff --git a/src/ssl/tls_client.cpp b/src/ssl/tls_client.cpp index ad4074ab2..d6d62d59a 100644 --- a/src/ssl/tls_client.cpp +++ b/src/ssl/tls_client.cpp @@ -205,7 +205,7 @@ u32bit TLS_Client::read(byte out[], u32bit length) break; } - u32bit got = std::min(read_buf.size(), length); + u32bit got = std::min<size_t>(read_buf.size(), length); read_buf.read(out, got); return got; } diff --git a/src/ssl/tls_server.cpp b/src/ssl/tls_server.cpp index 3d72d9dca..1503912d0 100644 --- a/src/ssl/tls_server.cpp +++ b/src/ssl/tls_server.cpp @@ -166,7 +166,7 @@ u32bit TLS_Server::read(byte out[], u32bit length) break; } - u32bit got = std::min(read_buf.size(), length); + u32bit got = std::min<size_t>(read_buf.size(), length); read_buf.read(out, got); return got; } diff --git a/src/utils/types.h b/src/utils/types.h index c14149779..61a55368c 100644 --- a/src/utils/types.h +++ b/src/utils/types.h @@ -52,7 +52,7 @@ typedef signed int s32bit; /** * A default buffer size; typically a memory page */ -static const u32bit DEFAULT_BUFFERSIZE = BOTAN_DEFAULT_BUFFER_SIZE; +static const size_t DEFAULT_BUFFERSIZE = BOTAN_DEFAULT_BUFFER_SIZE; } |