diff options
author | lloyd <[email protected]> | 2010-09-14 01:31:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-14 01:31:38 +0000 |
commit | 59a9b0ef260b010606edc3384035b6aa12dd6415 (patch) | |
tree | 6d643130be0e6eac2d8120da90ad03a3b5cdff4e /src/rng | |
parent | ae59295ea945fdcc482df2233409a5f878fa20c7 (diff) |
Handle the case that container size() returns something other than u32bit
Diffstat (limited to 'src/rng')
-rw-r--r-- | src/rng/hmac_rng/hmac_rng.cpp | 2 | ||||
-rw-r--r-- | src/rng/randpool/randpool.cpp | 2 | ||||
-rw-r--r-- | src/rng/x931_rng/x931_rng.cpp | 8 |
3 files changed, 5 insertions, 7 deletions
diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp index eb67c7f4e..ff7326336 100644 --- a/src/rng/hmac_rng/hmac_rng.cpp +++ b/src/rng/hmac_rng/hmac_rng.cpp @@ -46,7 +46,7 @@ void HMAC_RNG::randomize(byte out[], u32bit length) { hmac_prf(prf, K, counter, "rng"); - const u32bit copied = std::min(K.size(), length); + const u32bit copied = std::min<u32bit>(K.size(), length); copy_mem(out, &K[0], copied); out += copied; diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp index b5e2e2748..713b5b416 100644 --- a/src/rng/randpool/randpool.cpp +++ b/src/rng/randpool/randpool.cpp @@ -37,7 +37,7 @@ void Randpool::randomize(byte out[], u32bit length) update_buffer(); while(length) { - const u32bit copied = std::min(length, buffer.size()); + const u32bit copied = std::min<u32bit>(length, buffer.size()); copy_mem(out, &buffer[0], copied); out += copied; length -= copied; diff --git a/src/rng/x931_rng/x931_rng.cpp b/src/rng/x931_rng/x931_rng.cpp index f92f5ae99..ddb7c138c 100644 --- a/src/rng/x931_rng/x931_rng.cpp +++ b/src/rng/x931_rng/x931_rng.cpp @@ -24,9 +24,9 @@ void ANSI_X931_RNG::randomize(byte out[], u32bit length) if(position == R.size()) update_buffer(); - const u32bit copied = std::min(length, R.size() - position); + const u32bit copied = std::min<u32bit>(length, R.size() - position); - copy_mem(out, R + position, copied); + copy_mem(out, &R[position], copied); out += copied; length -= copied; position += copied; @@ -38,9 +38,7 @@ void ANSI_X931_RNG::randomize(byte out[], u32bit length) */ void ANSI_X931_RNG::update_buffer() { - SecureVector<byte> DT(cipher->BLOCK_SIZE); - - prng->randomize(DT, DT.size()); + SecureVector<byte> DT = prng->random_vec(cipher->BLOCK_SIZE); cipher->encrypt(DT); xor_buf(R, V, DT, cipher->BLOCK_SIZE); |