aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/entropy/cryptoapi_rng/es_capi.cpp18
-rw-r--r--src/entropy/dev_random/dev_random.cpp14
-rw-r--r--src/entropy/dev_random/dev_random.h2
-rw-r--r--src/entropy/egd/es_egd.cpp10
-rw-r--r--src/entropy/egd/es_egd.h2
-rw-r--r--src/entropy/entropy_src.h22
-rw-r--r--src/entropy/hres_timer/hres_timer.cpp4
-rw-r--r--src/entropy/proc_walk/es_ftw.cpp4
-rw-r--r--src/entropy/unix_procs/es_unix.cpp18
-rw-r--r--src/entropy/unix_procs/es_unix.h2
-rw-r--r--src/entropy/unix_procs/unix_cmd.h6
-rw-r--r--src/entropy/win32_stats/es_win32.cpp8
-rw-r--r--src/libstate/global_rng.cpp6
-rw-r--r--src/rng/auto_rng/auto_rng.h6
-rw-r--r--src/rng/hmac_rng/hmac_rng.cpp13
-rw-r--r--src/rng/hmac_rng/hmac_rng.h9
-rw-r--r--src/rng/randpool/randpool.cpp26
-rw-r--r--src/rng/randpool/randpool.h12
-rw-r--r--src/rng/rng.h14
-rw-r--r--src/rng/x931_rng/x931_rng.cpp8
-rw-r--r--src/rng/x931_rng/x931_rng.h8
21 files changed, 106 insertions, 106 deletions
diff --git a/src/entropy/cryptoapi_rng/es_capi.cpp b/src/entropy/cryptoapi_rng/es_capi.cpp
index f3a94ad34..1de76dabb 100644
--- a/src/entropy/cryptoapi_rng/es_capi.cpp
+++ b/src/entropy/cryptoapi_rng/es_capi.cpp
@@ -33,7 +33,7 @@ class CSP_Handle
CryptReleaseContext(handle, 0);
}
- u32bit gen_random(byte out[], u32bit n) const
+ size_t gen_random(byte out[], size_t n) const
{
if(is_valid() && CryptGenRandom(handle, n, out))
return n;
@@ -57,11 +57,11 @@ void Win32_CAPI_EntropySource::poll(Entropy_Accumulator& accum)
{
MemoryRegion<byte>& io_buffer = accum.get_io_buffer(32);
- for(u32bit j = 0; j != prov_types.size(); ++j)
+ for(size_t i = 0; i != prov_types.size(); ++i)
{
- CSP_Handle csp(prov_types[j]);
+ CSP_Handle csp(prov_types[i]);
- u32bit got = csp.gen_random(&io_buffer[0], io_buffer.size());
+ size_t got = csp.gen_random(&io_buffer[0], io_buffer.size());
if(got)
{
@@ -78,12 +78,12 @@ Win32_CAPI_EntropySource::Win32_CAPI_EntropySource(const std::string& provs)
{
std::vector<std::string> capi_provs = split_on(provs, ':');
- for(u32bit j = 0; j != capi_provs.size(); ++j)
+ for(size_t i = 0; i != capi_provs.size(); ++i)
{
- if(capi_provs[j] == "RSA_FULL") prov_types.push_back(PROV_RSA_FULL);
- if(capi_provs[j] == "INTEL_SEC") prov_types.push_back(PROV_INTEL_SEC);
- if(capi_provs[j] == "FORTEZZA") prov_types.push_back(PROV_FORTEZZA);
- if(capi_provs[j] == "RNG") prov_types.push_back(PROV_RNG);
+ if(capi_provs[i] == "RSA_FULL") prov_types.push_back(PROV_RSA_FULL);
+ if(capi_provs[i] == "INTEL_SEC") prov_types.push_back(PROV_INTEL_SEC);
+ if(capi_provs[i] == "FORTEZZA") prov_types.push_back(PROV_FORTEZZA);
+ if(capi_provs[i] == "RNG") prov_types.push_back(PROV_RNG);
}
if(prov_types.size() == 0)
diff --git a/src/entropy/dev_random/dev_random.cpp b/src/entropy/dev_random/dev_random.cpp
index a942806d0..b15240aba 100644
--- a/src/entropy/dev_random/dev_random.cpp
+++ b/src/entropy/dev_random/dev_random.cpp
@@ -26,8 +26,8 @@ void Device_EntropySource::Device_Reader::close()
/**
Read bytes from a device file
*/
-u32bit Device_EntropySource::Device_Reader::get(byte out[], u32bit length,
- u32bit ms_wait_time)
+size_t Device_EntropySource::Device_Reader::get(byte out[], size_t length,
+ size_t ms_wait_time)
{
if(fd < 0)
return 0;
@@ -54,7 +54,7 @@ u32bit Device_EntropySource::Device_Reader::get(byte out[], u32bit length,
if(got <= 0)
return 0;
- return static_cast<u32bit>(got);
+ return static_cast<size_t>(got);
}
/**
@@ -82,7 +82,7 @@ Open a file descriptor to each (available) device in fsnames
Device_EntropySource::Device_EntropySource(
const std::vector<std::string>& fsnames)
{
- for(u32bit i = 0; i != fsnames.size(); ++i)
+ for(size_t i = 0; i != fsnames.size(); ++i)
{
Device_Reader::fd_type fd = Device_Reader::open(fsnames[i]);
if(fd > 0)
@@ -104,14 +104,14 @@ Device_EntropySource::~Device_EntropySource()
*/
void Device_EntropySource::poll(Entropy_Accumulator& accum)
{
- u32bit go_get = std::min<u32bit>(accum.desired_remaining_bits() / 8, 48);
+ size_t go_get = std::min<size_t>(accum.desired_remaining_bits() / 8, 48);
- u32bit read_wait_ms = std::max<u32bit>(go_get, 1000);
+ size_t read_wait_ms = std::max<size_t>(go_get, 1000);
MemoryRegion<byte>& io_buffer = accum.get_io_buffer(go_get);
for(size_t i = 0; i != devices.size(); ++i)
{
- u32bit got = devices[i].get(&io_buffer[0], io_buffer.size(),
+ size_t got = devices[i].get(&io_buffer[0], io_buffer.size(),
read_wait_ms);
if(got)
diff --git a/src/entropy/dev_random/dev_random.h b/src/entropy/dev_random/dev_random.h
index e20e74300..171adcc76 100644
--- a/src/entropy/dev_random/dev_random.h
+++ b/src/entropy/dev_random/dev_random.h
@@ -41,7 +41,7 @@ class Device_EntropySource : public EntropySource
void close();
- u32bit get(byte out[], u32bit length, u32bit ms_wait_time);
+ size_t get(byte out[], size_t length, size_t ms_wait_time);
static fd_type open(const std::string& pathname);
private:
diff --git a/src/entropy/egd/es_egd.cpp b/src/entropy/egd/es_egd.cpp
index 7efcf204d..d2ce2706b 100644
--- a/src/entropy/egd/es_egd.cpp
+++ b/src/entropy/egd/es_egd.cpp
@@ -63,7 +63,7 @@ int EGD_EntropySource::EGD_Socket::open_socket(const std::string& path)
/**
* Attempt to read entropy from EGD
*/
-u32bit EGD_EntropySource::EGD_Socket::read(byte outbuf[], u32bit length)
+size_t EGD_EntropySource::EGD_Socket::read(byte outbuf[], size_t length)
{
if(length == 0)
return 0;
@@ -79,7 +79,7 @@ u32bit EGD_EntropySource::EGD_Socket::read(byte outbuf[], u32bit length)
{
// 1 == EGD command for non-blocking read
byte egd_read_command[2] = {
- 1, static_cast<byte>(std::min<u32bit>(length, 255)) };
+ 1, static_cast<byte>(std::min<size_t>(length, 255)) };
if(::write(m_fd, egd_read_command, 2) != 2)
throw std::runtime_error("Writing entropy read command to EGD failed");
@@ -96,7 +96,7 @@ u32bit EGD_EntropySource::EGD_Socket::read(byte outbuf[], u32bit length)
if(count != out_len)
throw std::runtime_error("Reading entropy result from EGD failed");
- return static_cast<u32bit>(count);
+ return static_cast<size_t>(count);
}
catch(std::exception)
{
@@ -137,13 +137,13 @@ EGD_EntropySource::~EGD_EntropySource()
*/
void EGD_EntropySource::poll(Entropy_Accumulator& accum)
{
- u32bit go_get = std::min<u32bit>(accum.desired_remaining_bits() / 8, 32);
+ size_t go_get = std::min<size_t>(accum.desired_remaining_bits() / 8, 32);
MemoryRegion<byte>& io_buffer = accum.get_io_buffer(go_get);
for(size_t i = 0; i != sockets.size(); ++i)
{
- u32bit got = sockets[i].read(&io_buffer[0], io_buffer.size());
+ size_t got = sockets[i].read(&io_buffer[0], io_buffer.size());
if(got)
{
diff --git a/src/entropy/egd/es_egd.h b/src/entropy/egd/es_egd.h
index defe88a54..02c52b9a3 100644
--- a/src/entropy/egd/es_egd.h
+++ b/src/entropy/egd/es_egd.h
@@ -33,7 +33,7 @@ class EGD_EntropySource : public EntropySource
EGD_Socket(const std::string& path);
void close();
- u32bit read(byte outbuf[], u32bit length);
+ size_t read(byte outbuf[], size_t length);
private:
static int open_socket(const std::string& path);
diff --git a/src/entropy/entropy_src.h b/src/entropy/entropy_src.h
index fa61d9ea8..97ebe8bd9 100644
--- a/src/entropy/entropy_src.h
+++ b/src/entropy/entropy_src.h
@@ -24,7 +24,7 @@ class BOTAN_DLL Entropy_Accumulator
* Initialize an Entropy_Accumulator
* @param goal is how many bits we would like to collect
*/
- Entropy_Accumulator(u32bit goal) :
+ Entropy_Accumulator(size_t goal) :
entropy_goal(goal), collected_bits(0) {}
virtual ~Entropy_Accumulator() {}
@@ -36,14 +36,14 @@ class BOTAN_DLL Entropy_Accumulator
* @param size requested size for the I/O buffer
* @return cached I/O buffer for repeated polls
*/
- MemoryRegion<byte>& get_io_buffer(u32bit size)
+ MemoryRegion<byte>& get_io_buffer(size_t size)
{ io_buffer.resize(size); return io_buffer; }
/**
* @return number of bits collected so far
*/
- u32bit bits_collected() const
- { return static_cast<u32bit>(collected_bits); }
+ size_t bits_collected() const
+ { return static_cast<size_t>(collected_bits); }
/**
* @return if our polling goal has been achieved
@@ -54,11 +54,11 @@ class BOTAN_DLL Entropy_Accumulator
/**
* @return how many bits we need to reach our polling goal
*/
- u32bit desired_remaining_bits() const
+ size_t desired_remaining_bits() const
{
if(collected_bits >= entropy_goal)
return 0;
- return static_cast<u32bit>(entropy_goal - collected_bits);
+ return static_cast<size_t>(entropy_goal - collected_bits);
}
/**
@@ -68,7 +68,7 @@ class BOTAN_DLL Entropy_Accumulator
* @param entropy_bits_per_byte is a best guess at how much
* entropy per byte is in this input
*/
- void add(const void* bytes, u32bit length, double entropy_bits_per_byte)
+ void add(const void* bytes, size_t length, double entropy_bits_per_byte)
{
add_bytes(reinterpret_cast<const byte*>(bytes), length);
collected_bits += entropy_bits_per_byte * length;
@@ -86,10 +86,10 @@ class BOTAN_DLL Entropy_Accumulator
add(&v, sizeof(T), entropy_bits_per_byte);
}
private:
- virtual void add_bytes(const byte bytes[], u32bit length) = 0;
+ virtual void add_bytes(const byte bytes[], size_t length) = 0;
SecureVector<byte> io_buffer;
- u32bit entropy_goal;
+ size_t entropy_goal;
double collected_bits;
};
@@ -104,11 +104,11 @@ class BOTAN_DLL Entropy_Accumulator_BufferedComputation : public Entropy_Accumul
* @param goal is how many bits we want to collect in this poll
*/
Entropy_Accumulator_BufferedComputation(BufferedComputation& sink,
- u32bit goal) :
+ size_t goal) :
Entropy_Accumulator(goal), entropy_sink(sink) {}
private:
- virtual void add_bytes(const byte bytes[], u32bit length)
+ virtual void add_bytes(const byte bytes[], size_t length)
{
entropy_sink.update(bytes, length);
}
diff --git a/src/entropy/hres_timer/hres_timer.cpp b/src/entropy/hres_timer/hres_timer.cpp
index e1b4928df..b0bbf6fa7 100644
--- a/src/entropy/hres_timer/hres_timer.cpp
+++ b/src/entropy/hres_timer/hres_timer.cpp
@@ -34,13 +34,13 @@ void High_Resolution_Timestamp::poll(Entropy_Accumulator& accum)
#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY)
if(CPUID::has_rdtsc()) // not availble on all x86 CPUs
{
- u32bit rtc_low = 0, rtc_high = 0;
+ size_t rtc_low = 0, rtc_high = 0;
asm volatile("rdtsc" : "=d" (rtc_high), "=a" (rtc_low));
rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
}
#elif defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
- u32bit rtc_low = 0, rtc_high = 0;
+ size_t rtc_low = 0, rtc_high = 0;
asm volatile("mftbu %0; mftb %1" : "=r" (rtc_high), "=r" (rtc_low));
rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
diff --git a/src/entropy/proc_walk/es_ftw.cpp b/src/entropy/proc_walk/es_ftw.cpp
index ce359f03f..5d58f9869 100644
--- a/src/entropy/proc_walk/es_ftw.cpp
+++ b/src/entropy/proc_walk/es_ftw.cpp
@@ -127,14 +127,14 @@ FTW_EntropySource::~FTW_EntropySource()
void FTW_EntropySource::poll(Entropy_Accumulator& accum)
{
- const u32bit MAX_FILES_READ_PER_POLL = 1024;
+ const size_t MAX_FILES_READ_PER_POLL = 1024;
if(!dir)
dir = new Directory_Walker(path);
MemoryRegion<byte>& io_buffer = accum.get_io_buffer(128);
- for(u32bit i = 0; i != MAX_FILES_READ_PER_POLL; ++i)
+ for(size_t i = 0; i != MAX_FILES_READ_PER_POLL; ++i)
{
int fd = dir->next_fd();
diff --git a/src/entropy/unix_procs/es_unix.cpp b/src/entropy/unix_procs/es_unix.cpp
index b96b740e9..b989e0213 100644
--- a/src/entropy/unix_procs/es_unix.cpp
+++ b/src/entropy/unix_procs/es_unix.cpp
@@ -45,7 +45,7 @@ Unix_EntropySource::Unix_EntropySource(const std::vector<std::string>& path) :
/**
* Add sources to the list
*/
-void Unix_EntropySource::add_sources(const Unix_Program srcs[], u32bit count)
+void Unix_EntropySource::add_sources(const Unix_Program srcs[], size_t count)
{
sources.insert(sources.end(), srcs, srcs + count);
std::sort(sources.begin(), sources.end(), Unix_Program_Cmp);
@@ -70,11 +70,11 @@ void Unix_EntropySource::poll(Entropy_Accumulator& accum)
"..",
0 };
- for(u32bit j = 0; stat_targets[j]; j++)
+ for(size_t i = 0; stat_targets[i]; i++)
{
struct stat statbuf;
clear_mem(&statbuf, 1);
- ::stat(stat_targets[j], &statbuf);
+ ::stat(stat_targets[i], &statbuf);
accum.add(&statbuf, sizeof(statbuf), .005);
}
@@ -91,25 +91,25 @@ void Unix_EntropySource::poll(Entropy_Accumulator& accum)
::getrusage(RUSAGE_CHILDREN, &usage);
accum.add(usage, .005);
- const u32bit MINIMAL_WORKING = 16;
+ const size_t MINIMAL_WORKING = 16;
MemoryRegion<byte>& io_buffer = accum.get_io_buffer(DEFAULT_BUFFERSIZE);
- for(u32bit j = 0; j != sources.size(); j++)
+ for(size_t i = 0; i != sources.size(); i++)
{
- DataSource_Command pipe(sources[j].name_and_args, PATH);
+ DataSource_Command pipe(sources[i].name_and_args, PATH);
- u32bit got_from_src = 0;
+ size_t got_from_src = 0;
while(!pipe.end_of_data())
{
- u32bit got_this_loop = pipe.read(&io_buffer[0], io_buffer.size());
+ size_t got_this_loop = pipe.read(&io_buffer[0], io_buffer.size());
got_from_src += got_this_loop;
accum.add(&io_buffer[0], got_this_loop, .005);
}
- sources[j].working = (got_from_src >= MINIMAL_WORKING) ? true : false;
+ sources[i].working = (got_from_src >= MINIMAL_WORKING) ? true : false;
if(accum.polling_goal_achieved())
break;
diff --git a/src/entropy/unix_procs/es_unix.h b/src/entropy/unix_procs/es_unix.h
index 415cce9fe..9c217ebe7 100644
--- a/src/entropy/unix_procs/es_unix.h
+++ b/src/entropy/unix_procs/es_unix.h
@@ -24,7 +24,7 @@ class Unix_EntropySource : public EntropySource
void poll(Entropy_Accumulator& accum);
- void add_sources(const Unix_Program[], u32bit);
+ void add_sources(const Unix_Program[], size_t);
Unix_EntropySource(const std::vector<std::string>& path);
private:
static std::vector<Unix_Program> get_default_sources();
diff --git a/src/entropy/unix_procs/unix_cmd.h b/src/entropy/unix_procs/unix_cmd.h
index a4ad0c180..5185c1c8f 100644
--- a/src/entropy/unix_procs/unix_cmd.h
+++ b/src/entropy/unix_procs/unix_cmd.h
@@ -24,7 +24,7 @@ struct Unix_Program
* @param n is the name and arguments of what we are going run
* @param p is the priority level (lower prio numbers get polled first)
*/
- Unix_Program(const char* n, u32bit p)
+ Unix_Program(const char* n, size_t p)
{ name_and_args = n; priority = p; working = true; }
/**
@@ -35,7 +35,7 @@ struct Unix_Program
/**
* Priority: we scan from low to high
*/
- u32bit priority;
+ size_t priority;
/**
* Does this source seem to be working?
@@ -63,7 +63,7 @@ class DataSource_Command : public DataSource
void create_pipe(const std::vector<std::string>&);
void shutdown_pipe();
- const u32bit MAX_BLOCK_USECS, KILL_WAIT;
+ const size_t MAX_BLOCK_USECS, KILL_WAIT;
std::vector<std::string> arg_list;
struct pipe_wrapper* pipe;
diff --git a/src/entropy/win32_stats/es_win32.cpp b/src/entropy/win32_stats/es_win32.cpp
index b3d7d27e5..fff11592d 100644
--- a/src/entropy/win32_stats/es_win32.cpp
+++ b/src/entropy/win32_stats/es_win32.cpp
@@ -75,12 +75,12 @@ void Win32_EntropySource::poll(Entropy_Accumulator& accum)
if(!accum.polling_goal_achieved())
{
- u32bit heap_lists_found = 0;
+ size_t heap_lists_found = 0;
HEAPLIST32 heap_list;
heap_list.dwSize = sizeof(HEAPLIST32);
- const u32bit HEAP_LISTS_MAX = 32;
- const u32bit HEAP_OBJS_PER_LIST = 128;
+ const size_t HEAP_LISTS_MAX = 32;
+ const size_t HEAP_OBJS_PER_LIST = 128;
if(Heap32ListFirst(snapshot, &heap_list))
{
@@ -91,7 +91,7 @@ void Win32_EntropySource::poll(Entropy_Accumulator& accum)
if(++heap_lists_found > HEAP_LISTS_MAX)
break;
- u32bit heap_objs_found = 0;
+ size_t heap_objs_found = 0;
HEAPENTRY32 heap_entry;
heap_entry.dwSize = sizeof(HEAPENTRY32);
if(Heap32First(&heap_entry, heap_list.th32ProcessID,
diff --git a/src/libstate/global_rng.cpp b/src/libstate/global_rng.cpp
index 2678813f1..a73924213 100644
--- a/src/libstate/global_rng.cpp
+++ b/src/libstate/global_rng.cpp
@@ -105,7 +105,7 @@ void add_entropy_sources(RandomNumberGenerator* rng)
class Serialized_PRNG : public RandomNumberGenerator
{
public:
- void randomize(byte out[], u32bit len)
+ void randomize(byte out[], size_t len)
{
Mutex_Holder lock(mutex);
rng->randomize(out, len);
@@ -129,7 +129,7 @@ class Serialized_PRNG : public RandomNumberGenerator
return rng->name();
}
- void reseed(u32bit poll_bits)
+ void reseed(size_t poll_bits)
{
Mutex_Holder lock(mutex);
rng->reseed(poll_bits);
@@ -141,7 +141,7 @@ class Serialized_PRNG : public RandomNumberGenerator
rng->add_entropy_source(es);
}
- void add_entropy(const byte in[], u32bit len)
+ void add_entropy(const byte in[], size_t len)
{
Mutex_Holder lock(mutex);
rng->add_entropy(in, len);
diff --git a/src/rng/auto_rng/auto_rng.h b/src/rng/auto_rng/auto_rng.h
index 28a603feb..520323e3e 100644
--- a/src/rng/auto_rng/auto_rng.h
+++ b/src/rng/auto_rng/auto_rng.h
@@ -20,7 +20,7 @@ namespace Botan {
class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator
{
public:
- void randomize(byte out[], u32bit len)
+ void randomize(byte out[], size_t len)
{ rng->randomize(out, len); }
bool is_seeded() const { return rng->is_seeded(); }
@@ -29,12 +29,12 @@ class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator
std::string name() const { return rng->name(); }
- void reseed(u32bit poll_bits = 256) { rng->reseed(poll_bits); }
+ void reseed(size_t poll_bits = 256) { rng->reseed(poll_bits); }
void add_entropy_source(EntropySource* es)
{ rng->add_entropy_source(es); }
- void add_entropy(const byte in[], u32bit len)
+ void add_entropy(const byte in[], size_t len)
{ rng->add_entropy(in, len); }
AutoSeeded_RNG() { rng = &global_state().global_rng(); }
diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp
index 6abdc66ce..a3456d9e0 100644
--- a/src/rng/hmac_rng/hmac_rng.cpp
+++ b/src/rng/hmac_rng/hmac_rng.cpp
@@ -22,8 +22,7 @@ void hmac_prf(MessageAuthenticationCode* prf,
{
prf->update(K);
prf->update(label);
- for(u32bit i = 0; i != 4; ++i)
- prf->update(get_byte(i, counter));
+ prf->update_be(counter);
prf->final(&K[0]);
++counter;
@@ -34,7 +33,7 @@ void hmac_prf(MessageAuthenticationCode* prf,
/*
* Generate a buffer of random bytes
*/
-void HMAC_RNG::randomize(byte out[], u32bit length)
+void HMAC_RNG::randomize(byte out[], size_t length)
{
if(!is_seeded())
throw PRNG_Unseeded(name());
@@ -46,7 +45,7 @@ void HMAC_RNG::randomize(byte out[], u32bit length)
{
hmac_prf(prf, K, counter, "rng");
- const u32bit copied = std::min<u32bit>(K.size(), length);
+ const size_t copied = std::min<size_t>(K.size(), length);
copy_mem(out, &K[0], copied);
out += copied;
@@ -57,7 +56,7 @@ void HMAC_RNG::randomize(byte out[], u32bit length)
/*
* Poll for entropy and reset the internal keys
*/
-void HMAC_RNG::reseed(u32bit poll_bits)
+void HMAC_RNG::reseed(size_t poll_bits)
{
/*
Using the terminology of E-t-E, XTR is the MAC function (normally
@@ -72,7 +71,7 @@ void HMAC_RNG::reseed(u32bit poll_bits)
if(!entropy_sources.empty())
{
- u32bit poll_attempt = 0;
+ size_t poll_attempt = 0;
while(!accum.polling_goal_achieved() && poll_attempt < poll_bits)
{
@@ -118,7 +117,7 @@ void HMAC_RNG::reseed(u32bit poll_bits)
/*
* Add user-supplied entropy to the extractor input
*/
-void HMAC_RNG::add_entropy(const byte input[], u32bit length)
+void HMAC_RNG::add_entropy(const byte input[], size_t length)
{
extractor->update(input, length);
user_input_len += length;
diff --git a/src/rng/hmac_rng/hmac_rng.h b/src/rng/hmac_rng/hmac_rng.h
index fc712b3ec..fc6a14f3a 100644
--- a/src/rng/hmac_rng/hmac_rng.h
+++ b/src/rng/hmac_rng/hmac_rng.h
@@ -27,14 +27,14 @@ and CMAC(AES-256) as the PRF.
class BOTAN_DLL HMAC_RNG : public RandomNumberGenerator
{
public:
- void randomize(byte buf[], u32bit len);
+ void randomize(byte buf[], size_t len);
bool is_seeded() const { return seeded; }
void clear();
std::string name() const;
- void reseed(u32bit poll_bits);
+ void reseed(size_t poll_bits);
void add_entropy_source(EntropySource* es);
- void add_entropy(const byte[], u32bit);
+ void add_entropy(const byte[], size_t);
/**
* @param extractor a MAC used for extracting the entropy
@@ -52,7 +52,8 @@ class BOTAN_DLL HMAC_RNG : public RandomNumberGenerator
bool seeded;
SecureVector<byte> K, io_buffer;
- u32bit counter, user_input_len;
+ size_t user_input_len;
+ u32bit counter;
};
}
diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp
index bce3f8ac3..d99ae5463 100644
--- a/src/rng/randpool/randpool.cpp
+++ b/src/rng/randpool/randpool.cpp
@@ -29,7 +29,7 @@ enum RANDPOOL_PRF_TAG {
/*
* Generate a buffer of random bytes
*/
-void Randpool::randomize(byte out[], u32bit length)
+void Randpool::randomize(byte out[], size_t length)
{
if(!is_seeded())
throw PRNG_Unseeded(name());
@@ -37,7 +37,7 @@ void Randpool::randomize(byte out[], u32bit length)
update_buffer();
while(length)
{
- const u32bit copied = std::min<u32bit>(length, buffer.size());
+ const size_t copied = std::min<size_t>(length, buffer.size());
copy_mem(out, &buffer[0], copied);
out += copied;
length -= copied;
@@ -50,7 +50,7 @@ void Randpool::randomize(byte out[], u32bit length)
*/
void Randpool::update_buffer()
{
- for(u32bit i = 0; i != counter.size(); ++i)
+ for(size_t i = 0; i != counter.size(); ++i)
if(++counter[i])
break;
@@ -58,7 +58,7 @@ void Randpool::update_buffer()
mac->update(counter);
SecureVector<byte> mac_val = mac->final();
- for(u32bit i = 0; i != mac_val.size(); ++i)
+ for(size_t i = 0; i != mac_val.size(); ++i)
buffer[i % buffer.size()] ^= mac_val[i];
cipher->encrypt(buffer);
@@ -71,7 +71,7 @@ void Randpool::update_buffer()
*/
void Randpool::mix_pool()
{
- const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE;
+ const size_t BLOCK_SIZE = cipher->BLOCK_SIZE;
mac->update(static_cast<byte>(MAC_KEY));
mac->update(pool);
@@ -83,7 +83,7 @@ void Randpool::mix_pool()
xor_buf(pool, buffer, BLOCK_SIZE);
cipher->encrypt(pool);
- for(u32bit i = 1; i != POOL_BLOCKS; ++i)
+ for(size_t i = 1; i != POOL_BLOCKS; ++i)
{
const byte* previous_block = &pool[BLOCK_SIZE*(i-1)];
byte* this_block = &pool[BLOCK_SIZE*i];
@@ -97,13 +97,13 @@ void Randpool::mix_pool()
/*
* Reseed the internal state
*/
-void Randpool::reseed(u32bit poll_bits)
+void Randpool::reseed(size_t poll_bits)
{
Entropy_Accumulator_BufferedComputation accum(*mac, poll_bits);
if(!entropy_sources.empty())
{
- u32bit poll_attempt = 0;
+ size_t poll_attempt = 0;
while(!accum.polling_goal_achieved() && poll_attempt < poll_bits)
{
@@ -124,7 +124,7 @@ void Randpool::reseed(u32bit poll_bits)
/*
* Add user-supplied entropy
*/
-void Randpool::add_entropy(const byte input[], u32bit length)
+void Randpool::add_entropy(const byte input[], size_t length)
{
SecureVector<byte> mac_val = mac->process(input, length);
xor_buf(pool, mac_val, mac_val.size());
@@ -168,15 +168,15 @@ std::string Randpool::name() const
*/
Randpool::Randpool(BlockCipher* cipher_in,
MessageAuthenticationCode* mac_in,
- u32bit pool_blocks,
- u32bit iter_before_reseed) :
+ size_t pool_blocks,
+ size_t iter_before_reseed) :
ITERATIONS_BEFORE_RESEED(iter_before_reseed),
POOL_BLOCKS(pool_blocks),
cipher(cipher_in),
mac(mac_in)
{
- const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE;
- const u32bit OUTPUT_LENGTH = mac->OUTPUT_LENGTH;
+ const size_t BLOCK_SIZE = cipher->BLOCK_SIZE;
+ const size_t OUTPUT_LENGTH = mac->OUTPUT_LENGTH;
if(OUTPUT_LENGTH < BLOCK_SIZE ||
!cipher->valid_keylength(OUTPUT_LENGTH) ||
diff --git a/src/rng/randpool/randpool.h b/src/rng/randpool/randpool.h
index 471bb791a..ed224221c 100644
--- a/src/rng/randpool/randpool.h
+++ b/src/rng/randpool/randpool.h
@@ -21,14 +21,14 @@ namespace Botan {
class BOTAN_DLL Randpool : public RandomNumberGenerator
{
public:
- void randomize(byte[], u32bit);
+ void randomize(byte[], size_t);
bool is_seeded() const { return seeded; }
void clear();
std::string name() const;
- void reseed(u32bit bits_to_collect);
+ void reseed(size_t bits_to_collect);
void add_entropy_source(EntropySource* es);
- void add_entropy(const byte input[], u32bit length);
+ void add_entropy(const byte input[], size_t length);
/**
* @param cipher a block cipher to use
@@ -39,15 +39,15 @@ class BOTAN_DLL Randpool : public RandomNumberGenerator
*/
Randpool(BlockCipher* cipher,
MessageAuthenticationCode* mac,
- u32bit pool_blocks = 32,
- u32bit iterations_before_reseed = 128);
+ size_t pool_blocks = 32,
+ size_t iterations_before_reseed = 128);
~Randpool();
private:
void update_buffer();
void mix_pool();
- u32bit ITERATIONS_BEFORE_RESEED, POOL_BLOCKS;
+ size_t ITERATIONS_BEFORE_RESEED, POOL_BLOCKS;
BlockCipher* cipher;
MessageAuthenticationCode* mac;
diff --git a/src/rng/rng.h b/src/rng/rng.h
index e024eeb59..95e1f12cb 100644
--- a/src/rng/rng.h
+++ b/src/rng/rng.h
@@ -30,9 +30,9 @@ class BOTAN_DLL RandomNumberGenerator
* @param output the byte array to hold the random output.
* @param length the length of the byte array output.
*/
- virtual void randomize(byte output[], u32bit length) = 0;
+ virtual void randomize(byte output[], size_t length) = 0;
- SecureVector<byte> random_vec(u32bit bytes)
+ SecureVector<byte> random_vec(size_t bytes)
{
SecureVector<byte> output(bytes);
randomize(&output[0], output.size());
@@ -66,7 +66,7 @@ class BOTAN_DLL RandomNumberGenerator
* @param bits_to_collect is the number of bits of entropy to
attempt to gather from the entropy sources
*/
- virtual void reseed(u32bit bits_to_collect) = 0;
+ virtual void reseed(size_t bits_to_collect) = 0;
/**
* Add this entropy source to the RNG object
@@ -79,7 +79,7 @@ class BOTAN_DLL RandomNumberGenerator
* @param in a byte array containg the entropy to be added
* @param length the length of the byte array in
*/
- virtual void add_entropy(const byte in[], u32bit length) = 0;
+ virtual void add_entropy(const byte in[], size_t length) = 0;
RandomNumberGenerator() {}
virtual ~RandomNumberGenerator() {}
@@ -95,13 +95,13 @@ class BOTAN_DLL RandomNumberGenerator
class BOTAN_DLL Null_RNG : public RandomNumberGenerator
{
public:
- void randomize(byte[], u32bit) { throw PRNG_Unseeded("Null_RNG"); }
+ void randomize(byte[], size_t) { throw PRNG_Unseeded("Null_RNG"); }
void clear() {}
std::string name() const { return "Null_RNG"; }
- void reseed(u32bit) {}
+ void reseed(size_t) {}
bool is_seeded() const { return false; }
- void add_entropy(const byte[], u32bit) {}
+ void add_entropy(const byte[], size_t) {}
void add_entropy_source(EntropySource* es) { delete es; }
};
diff --git a/src/rng/x931_rng/x931_rng.cpp b/src/rng/x931_rng/x931_rng.cpp
index 1d5e57f6e..6da1e214d 100644
--- a/src/rng/x931_rng/x931_rng.cpp
+++ b/src/rng/x931_rng/x931_rng.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* Generate a buffer of random bytes
*/
-void ANSI_X931_RNG::randomize(byte out[], u32bit length)
+void ANSI_X931_RNG::randomize(byte out[], size_t length)
{
if(!is_seeded())
throw PRNG_Unseeded(name());
@@ -24,7 +24,7 @@ void ANSI_X931_RNG::randomize(byte out[], u32bit length)
if(position == R.size())
update_buffer();
- const u32bit copied = std::min<u32bit>(length, R.size() - position);
+ const size_t copied = std::min<size_t>(length, R.size() - position);
copy_mem(out, &R[position], copied);
out += copied;
@@ -70,7 +70,7 @@ void ANSI_X931_RNG::rekey()
/*
* Reseed the internal state
*/
-void ANSI_X931_RNG::reseed(u32bit poll_bits)
+void ANSI_X931_RNG::reseed(size_t poll_bits)
{
prng->reseed(poll_bits);
rekey();
@@ -87,7 +87,7 @@ void ANSI_X931_RNG::add_entropy_source(EntropySource* src)
/*
* Add some entropy to the underlying PRNG
*/
-void ANSI_X931_RNG::add_entropy(const byte input[], u32bit length)
+void ANSI_X931_RNG::add_entropy(const byte input[], size_t length)
{
prng->add_entropy(input, length);
rekey();
diff --git a/src/rng/x931_rng/x931_rng.h b/src/rng/x931_rng/x931_rng.h
index 345ee3ca9..41fa9328b 100644
--- a/src/rng/x931_rng/x931_rng.h
+++ b/src/rng/x931_rng/x931_rng.h
@@ -19,14 +19,14 @@ namespace Botan {
class BOTAN_DLL ANSI_X931_RNG : public RandomNumberGenerator
{
public:
- void randomize(byte[], u32bit);
+ void randomize(byte[], size_t);
bool is_seeded() const;
void clear();
std::string name() const;
- void reseed(u32bit poll_bits);
+ void reseed(size_t poll_bits);
void add_entropy_source(EntropySource*);
- void add_entropy(const byte[], u32bit);
+ void add_entropy(const byte[], size_t);
/**
* @param cipher the block cipher to use in this PRNG
@@ -43,7 +43,7 @@ class BOTAN_DLL ANSI_X931_RNG : public RandomNumberGenerator
BlockCipher* cipher;
RandomNumberGenerator* prng;
SecureVector<byte> V, R;
- u32bit position;
+ size_t position;
};
}