aboutsummaryrefslogtreecommitdiffstats
path: root/src/rng/hmac_rng
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-12 20:23:47 +0000
committerlloyd <[email protected]>2010-10-12 20:23:47 +0000
commit6385602fcccfd9c561b1c097095ddd2edf1a2357 (patch)
tree63374ebafd20b09ff4ad77d624a4b27c87b1062c /src/rng/hmac_rng
parentab1f661083053df745daf1e1b8f4859f5a92065d (diff)
Use size_t instead of u32bit in entropy and rng
Diffstat (limited to 'src/rng/hmac_rng')
-rw-r--r--src/rng/hmac_rng/hmac_rng.cpp13
-rw-r--r--src/rng/hmac_rng/hmac_rng.h9
2 files changed, 11 insertions, 11 deletions
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;
};
}