aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-12 15:45:16 +0000
committerlloyd <[email protected]>2010-10-12 15:45:16 +0000
commita263ae6b9cfb5e93e3f446bd736ab3f86ba3c681 (patch)
tree31076d3432d35ea24c235c2b8064d5c86d7665c0 /src
parent18a58396b7bb2925a33c57b17f1820b386b54c2d (diff)
s/u32bit/size_t/ in codec and benchmark
Diffstat (limited to 'src')
-rw-r--r--src/benchmark/benchmark.cpp16
-rw-r--r--src/benchmark/benchmark.h2
-rw-r--r--src/codec/hex/hex.cpp30
-rw-r--r--src/codec/hex/hex.h18
-rw-r--r--src/codec/openpgp/openpgp.cpp12
-rw-r--r--src/codec/openpgp/openpgp.h4
-rw-r--r--src/codec/pem/pem.cpp18
-rw-r--r--src/codec/pem/pem.h8
-rw-r--r--src/filters/hex_filt/hex_filt.cpp4
9 files changed, 56 insertions, 56 deletions
diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp
index fc4a8ba37..46dcfb58c 100644
--- a/src/benchmark/benchmark.cpp
+++ b/src/benchmark/benchmark.cpp
@@ -23,7 +23,7 @@ namespace {
*/
std::pair<u64bit, u64bit> bench_buf_comp(BufferedComputation* buf_comp,
u64bit nanoseconds_max,
- const byte buf[], u32bit buf_len)
+ const byte buf[], size_t buf_len)
{
u64bit reps = 0;
u64bit nanoseconds_used = 0;
@@ -46,9 +46,9 @@ std::pair<u64bit, u64bit> bench_buf_comp(BufferedComputation* buf_comp,
std::pair<u64bit, u64bit>
bench_block_cipher(BlockCipher* block_cipher,
u64bit nanoseconds_max,
- byte buf[], u32bit buf_len)
+ byte buf[], size_t buf_len)
{
- const u32bit in_blocks = buf_len / block_cipher->BLOCK_SIZE;
+ const size_t in_blocks = buf_len / block_cipher->BLOCK_SIZE;
u64bit reps = 0;
u64bit nanoseconds_used = 0;
@@ -74,7 +74,7 @@ bench_block_cipher(BlockCipher* block_cipher,
std::pair<u64bit, u64bit>
bench_stream_cipher(StreamCipher* stream_cipher,
u64bit nanoseconds_max,
- byte buf[], u32bit buf_len)
+ byte buf[], size_t buf_len)
{
u64bit reps = 0;
u64bit nanoseconds_used = 0;
@@ -99,7 +99,7 @@ bench_stream_cipher(StreamCipher* stream_cipher,
std::pair<u64bit, u64bit>
bench_hash(HashFunction* hash,
u64bit nanoseconds_max,
- const byte buf[], u32bit buf_len)
+ const byte buf[], size_t buf_len)
{
return bench_buf_comp(hash, nanoseconds_max, buf, buf_len);
}
@@ -110,7 +110,7 @@ bench_hash(HashFunction* hash,
std::pair<u64bit, u64bit>
bench_mac(MessageAuthenticationCode* mac,
u64bit nanoseconds_max,
- const byte buf[], u32bit buf_len)
+ const byte buf[], size_t buf_len)
{
mac->set_key(buf, mac->MAXIMUM_KEYLENGTH);
return bench_buf_comp(mac, nanoseconds_max, buf, buf_len);
@@ -123,7 +123,7 @@ algorithm_benchmark(const std::string& name,
Algorithm_Factory& af,
RandomNumberGenerator& rng,
u32bit milliseconds,
- u32bit buf_size)
+ size_t buf_size)
{
std::vector<std::string> providers = af.providers_of(name);
std::map<std::string, double> all_results;
@@ -137,7 +137,7 @@ algorithm_benchmark(const std::string& name,
std::vector<byte> buf(buf_size * 1024);
rng.randomize(&buf[0], buf.size());
- for(u32bit i = 0; i != providers.size(); ++i)
+ for(size_t i = 0; i != providers.size(); ++i)
{
const std::string provider = providers[i];
diff --git a/src/benchmark/benchmark.h b/src/benchmark/benchmark.h
index accfc86f3..c47fdc166 100644
--- a/src/benchmark/benchmark.h
+++ b/src/benchmark/benchmark.h
@@ -29,7 +29,7 @@ BOTAN_DLL algorithm_benchmark(const std::string& name,
Algorithm_Factory& af,
RandomNumberGenerator& rng,
u32bit milliseconds,
- u32bit buf_size);
+ size_t buf_size);
}
diff --git a/src/codec/hex/hex.cpp b/src/codec/hex/hex.cpp
index 0034de95a..596e0e235 100644
--- a/src/codec/hex/hex.cpp
+++ b/src/codec/hex/hex.cpp
@@ -13,7 +13,7 @@ namespace Botan {
void hex_encode(char output[],
const byte input[],
- u32bit input_length,
+ size_t input_length,
bool uppercase)
{
static const byte BIN_TO_HEX_UPPER[16] = {
@@ -26,7 +26,7 @@ void hex_encode(char output[],
const byte* tbl = uppercase ? BIN_TO_HEX_UPPER : BIN_TO_HEX_LOWER;
- for(u32bit i = 0; i != input_length; ++i)
+ for(size_t i = 0; i != input_length; ++i)
{
byte x = input[i];
output[2*i ] = tbl[(x >> 4) & 0x0F];
@@ -43,7 +43,7 @@ std::string hex_encode(const MemoryRegion<byte>& input,
}
std::string hex_encode(const byte input[],
- u32bit input_length,
+ size_t input_length,
bool uppercase)
{
std::string output(2 * input_length, 0);
@@ -51,10 +51,10 @@ std::string hex_encode(const byte input[],
return output;
}
-u32bit hex_decode(byte output[],
+size_t hex_decode(byte output[],
const char input[],
- u32bit input_length,
- u32bit& input_consumed,
+ size_t input_length,
+ size_t& input_consumed,
bool ignore_ws)
{
/*
@@ -99,7 +99,7 @@ u32bit hex_decode(byte output[],
clear_mem(output, input_length / 2);
- for(u32bit i = 0; i != input_length; ++i)
+ for(size_t i = 0; i != input_length; ++i)
{
const byte bin = HEX_TO_BIN[(byte)input[i]];
@@ -127,7 +127,7 @@ u32bit hex_decode(byte output[],
}
input_consumed = input_length;
- u32bit written = (out_ptr - output);
+ size_t written = (out_ptr - output);
/*
* We only got half of a byte at the end; zap the half-written
@@ -142,13 +142,13 @@ u32bit hex_decode(byte output[],
return written;
}
-u32bit hex_decode(byte output[],
+size_t hex_decode(byte output[],
const char input[],
- u32bit input_length,
+ size_t input_length,
bool ignore_ws)
{
- u32bit consumed = 0;
- u32bit written = hex_decode(output, input, input_length,
+ size_t consumed = 0;
+ size_t written = hex_decode(output, input, input_length,
consumed, ignore_ws);
if(consumed != input_length)
@@ -157,7 +157,7 @@ u32bit hex_decode(byte output[],
return written;
}
-u32bit hex_decode(byte output[],
+size_t hex_decode(byte output[],
const std::string& input,
bool ignore_ws)
{
@@ -165,12 +165,12 @@ u32bit hex_decode(byte output[],
}
SecureVector<byte> hex_decode(const char input[],
- u32bit input_length,
+ size_t input_length,
bool ignore_ws)
{
SecureVector<byte> bin(1 + input_length / 2);
- u32bit written = hex_decode(&bin[0],
+ size_t written = hex_decode(&bin[0],
input,
input_length,
ignore_ws);
diff --git a/src/codec/hex/hex.h b/src/codec/hex/hex.h
index afef1ec84..40930e808 100644
--- a/src/codec/hex/hex.h
+++ b/src/codec/hex/hex.h
@@ -22,7 +22,7 @@ namespace Botan {
*/
void BOTAN_DLL hex_encode(char output[],
const byte input[],
- u32bit input_length,
+ size_t input_length,
bool uppercase = true);
/**
@@ -33,7 +33,7 @@ void BOTAN_DLL hex_encode(char output[],
* @return hexadecimal representation of input
*/
std::string BOTAN_DLL hex_encode(const byte input[],
- u32bit input_length,
+ size_t input_length,
bool uppercase = true);
/**
@@ -58,10 +58,10 @@ std::string BOTAN_DLL hex_encode(const MemoryRegion<byte>& input,
exception if whitespace is encountered
* @return number of bytes written to output
*/
-u32bit BOTAN_DLL hex_decode(byte output[],
+size_t BOTAN_DLL hex_decode(byte output[],
const char input[],
- u32bit input_length,
- u32bit& input_consumed,
+ size_t input_length,
+ size_t& input_consumed,
bool ignore_ws = true);
/**
@@ -73,9 +73,9 @@ u32bit BOTAN_DLL hex_decode(byte output[],
exception if whitespace is encountered
* @return number of bytes written to output
*/
-u32bit BOTAN_DLL hex_decode(byte output[],
+size_t BOTAN_DLL hex_decode(byte output[],
const char input[],
- u32bit input_length,
+ size_t input_length,
bool ignore_ws = true);
/**
@@ -86,7 +86,7 @@ u32bit BOTAN_DLL hex_decode(byte output[],
exception if whitespace is encountered
* @return number of bytes written to output
*/
-u32bit BOTAN_DLL hex_decode(byte output[],
+size_t BOTAN_DLL hex_decode(byte output[],
const std::string& input,
bool ignore_ws = true);
@@ -99,7 +99,7 @@ u32bit BOTAN_DLL hex_decode(byte output[],
* @return decoded hex output
*/
SecureVector<byte> BOTAN_DLL hex_decode(const char input[],
- u32bit input_length,
+ size_t input_length,
bool ignore_ws = true);
/**
diff --git a/src/codec/openpgp/openpgp.cpp b/src/codec/openpgp/openpgp.cpp
index ca1ea6d9c..ab9673689 100644
--- a/src/codec/openpgp/openpgp.cpp
+++ b/src/codec/openpgp/openpgp.cpp
@@ -17,13 +17,13 @@ namespace Botan {
* OpenPGP Base64 encoding
*/
std::string PGP_encode(
- const byte input[], u32bit length,
+ const byte input[], size_t length,
const std::string& label,
const std::map<std::string, std::string>& headers)
{
const std::string PGP_HEADER = "-----BEGIN PGP " + label + "-----\n";
const std::string PGP_TRAILER = "-----END PGP " + label + "-----\n";
- const u32bit PGP_WIDTH = 64;
+ const size_t PGP_WIDTH = 64;
std::string pgp_encoded = PGP_HEADER;
@@ -57,7 +57,7 @@ std::string PGP_encode(
/*
* OpenPGP Base64 encoding
*/
-std::string PGP_encode(const byte input[], u32bit length,
+std::string PGP_encode(const byte input[], size_t length,
const std::string& type)
{
std::map<std::string, std::string> empty;
@@ -71,11 +71,11 @@ SecureVector<byte> PGP_decode(DataSource& source,
std::string& label,
std::map<std::string, std::string>& headers)
{
- const u32bit RANDOM_CHAR_LIMIT = 5;
+ const size_t RANDOM_CHAR_LIMIT = 5;
const std::string PGP_HEADER1 = "-----BEGIN PGP ";
const std::string PGP_HEADER2 = "-----";
- u32bit position = 0;
+ size_t position = 0;
while(position != PGP_HEADER1.length())
{
@@ -119,7 +119,7 @@ SecureVector<byte> PGP_decode(DataSource& source,
}
end_of_headers = true;
- for(u32bit j = 0; j != this_header.length(); ++j)
+ for(size_t j = 0; j != this_header.length(); ++j)
if(!Charset::is_space(this_header[j]))
end_of_headers = false;
diff --git a/src/codec/openpgp/openpgp.h b/src/codec/openpgp/openpgp.h
index 1e2cf10f0..0cd77d53a 100644
--- a/src/codec/openpgp/openpgp.h
+++ b/src/codec/openpgp/openpgp.h
@@ -22,7 +22,7 @@ namespace Botan {
*/
BOTAN_DLL std::string PGP_encode(
const byte input[],
- u32bit length,
+ size_t length,
const std::string& label,
const std::map<std::string, std::string>& headers);
@@ -33,7 +33,7 @@ BOTAN_DLL std::string PGP_encode(
*/
BOTAN_DLL std::string PGP_encode(
const byte input[],
- u32bit length,
+ size_t length,
const std::string& label);
/**
diff --git a/src/codec/pem/pem.cpp b/src/codec/pem/pem.cpp
index 1fe5910f3..005ec7310 100644
--- a/src/codec/pem/pem.cpp
+++ b/src/codec/pem/pem.cpp
@@ -16,8 +16,8 @@ namespace PEM_Code {
/*
* PEM encode BER/DER-encoded objects
*/
-std::string encode(const byte der[], u32bit length, const std::string& label,
- u32bit width)
+std::string encode(const byte der[], size_t length, const std::string& label,
+ size_t width)
{
const std::string PEM_HEADER = "-----BEGIN " + label + "-----\n";
const std::string PEM_TRAILER = "-----END " + label + "-----\n";
@@ -31,7 +31,7 @@ std::string encode(const byte der[], u32bit length, const std::string& label,
* PEM encode BER/DER-encoded objects
*/
std::string encode(const MemoryRegion<byte>& data, const std::string& label,
- u32bit width)
+ size_t width)
{
return encode(&data[0], data.size(), label, width);
}
@@ -55,11 +55,11 @@ SecureVector<byte> decode_check_label(DataSource& source,
*/
SecureVector<byte> decode(DataSource& source, std::string& label)
{
- const u32bit RANDOM_CHAR_LIMIT = 8;
+ const size_t RANDOM_CHAR_LIMIT = 8;
const std::string PEM_HEADER1 = "-----BEGIN ";
const std::string PEM_HEADER2 = "-----";
- u32bit position = 0;
+ size_t position = 0;
while(position != PEM_HEADER1.length())
{
@@ -114,19 +114,19 @@ SecureVector<byte> decode(DataSource& source, std::string& label)
* Search for a PEM signature
*/
bool matches(DataSource& source, const std::string& extra,
- u32bit search_range)
+ size_t search_range)
{
const std::string PEM_HEADER = "-----BEGIN " + extra;
SecureVector<byte> search_buf(search_range);
- u32bit got = source.peek(&search_buf[0], search_buf.size(), 0);
+ size_t got = source.peek(&search_buf[0], search_buf.size(), 0);
if(got < PEM_HEADER.length())
return false;
- u32bit index = 0;
+ size_t index = 0;
- for(u32bit j = 0; j != got; ++j)
+ for(size_t j = 0; j != got; ++j)
{
if(search_buf[j] == PEM_HEADER[index])
++index;
diff --git a/src/codec/pem/pem.h b/src/codec/pem/pem.h
index 9fe8acb87..d15bfe978 100644
--- a/src/codec/pem/pem.h
+++ b/src/codec/pem/pem.h
@@ -17,16 +17,16 @@ namespace PEM_Code {
/*
* PEM Encoding/Decoding
*/
-BOTAN_DLL std::string encode(const byte[], u32bit,
- const std::string&, u32bit = 64);
+BOTAN_DLL std::string encode(const byte[], size_t,
+ const std::string&, size_t = 64);
BOTAN_DLL std::string encode(const MemoryRegion<byte>&,
- const std::string&, u32bit = 64);
+ const std::string&, size_t = 64);
BOTAN_DLL SecureVector<byte> decode(DataSource&, std::string&);
BOTAN_DLL SecureVector<byte> decode_check_label(DataSource&,
const std::string&);
BOTAN_DLL bool matches(DataSource&, const std::string& = "",
- u32bit search_range = 4096);
+ size_t search_range = 4096);
}
diff --git a/src/filters/hex_filt/hex_filt.cpp b/src/filters/hex_filt/hex_filt.cpp
index 51b8c1fd6..d821ca514 100644
--- a/src/filters/hex_filt/hex_filt.cpp
+++ b/src/filters/hex_filt/hex_filt.cpp
@@ -125,7 +125,7 @@ void Hex_Decoder::write(const byte input[], u32bit length)
copy_mem(&in[position], input, to_copy);
position += to_copy;
- u32bit consumed = 0;
+ size_t consumed = 0;
u32bit written = hex_decode(&out[0],
reinterpret_cast<const char*>(&in[0]),
position,
@@ -152,7 +152,7 @@ void Hex_Decoder::write(const byte input[], u32bit length)
*/
void Hex_Decoder::end_msg()
{
- u32bit consumed = 0;
+ size_t consumed = 0;
u32bit written = hex_decode(&out[0],
reinterpret_cast<const char*>(&in[0]),
position,