aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/block/rc5/rc5.cpp3
-rw-r--r--src/block/rc6/rc6.cpp2
-rw-r--r--src/filters/algo_filt.cpp6
-rw-r--r--src/filters/data_src.cpp2
-rw-r--r--src/filters/hex_filt/hex_filt.cpp2
-rw-r--r--src/filters/modes/cts/cts.cpp4
-rw-r--r--src/filters/modes/eax/eax.cpp2
-rw-r--r--src/filters/modes/eax/eax_dec.cpp4
-rw-r--r--src/filters/secqueue.cpp2
-rw-r--r--src/kdf/kdf2/kdf2.cpp2
-rw-r--r--src/kdf/mgf1/mgf1.cpp2
-rw-r--r--src/pbkdf/pbkdf1/pbkdf1.cpp2
-rw-r--r--src/rng/hmac_rng/hmac_rng.cpp2
-rw-r--r--src/rng/randpool/randpool.cpp2
-rw-r--r--src/rng/x931_rng/x931_rng.cpp8
15 files changed, 22 insertions, 23 deletions
diff --git a/src/block/rc5/rc5.cpp b/src/block/rc5/rc5.cpp
index ded0f961d..ff0250d32 100644
--- a/src/block/rc5/rc5.cpp
+++ b/src/block/rc5/rc5.cpp
@@ -77,7 +77,8 @@ void RC5::decrypt_n(const byte in[], byte out[], u32bit blocks) const
void RC5::key_schedule(const byte key[], u32bit length)
{
const u32bit WORD_KEYLENGTH = (((length - 1) / 4) + 1),
- MIX_ROUNDS = 3*std::max(WORD_KEYLENGTH, S.size());
+ MIX_ROUNDS = 3*std::max<u32bit>(WORD_KEYLENGTH, S.size());
+
S[0] = 0xB7E15163;
for(u32bit j = 1; j != S.size(); ++j)
S[j] = S[j-1] + 0x9E3779B9;
diff --git a/src/block/rc6/rc6.cpp b/src/block/rc6/rc6.cpp
index 5f88d1d0b..291d3b97e 100644
--- a/src/block/rc6/rc6.cpp
+++ b/src/block/rc6/rc6.cpp
@@ -114,7 +114,7 @@ void RC6::decrypt_n(const byte in[], byte out[], u32bit blocks) const
void RC6::key_schedule(const byte key[], u32bit length)
{
const u32bit WORD_KEYLENGTH = (((length - 1) / 4) + 1),
- MIX_ROUNDS = 3*std::max(WORD_KEYLENGTH, S.size());
+ MIX_ROUNDS = 3*std::max<u32bit>(WORD_KEYLENGTH, S.size());
S[0] = 0xB7E15163;
for(u32bit j = 1; j != S.size(); ++j)
S[j] = S[j-1] + 0x9E3779B9;
diff --git a/src/filters/algo_filt.cpp b/src/filters/algo_filt.cpp
index 88550d764..4407fc892 100644
--- a/src/filters/algo_filt.cpp
+++ b/src/filters/algo_filt.cpp
@@ -68,7 +68,7 @@ void StreamCipher_Filter::write(const byte input[], u32bit length)
{
while(length)
{
- u32bit copied = std::min(length, buffer.size());
+ u32bit copied = std::min<u32bit>(length, buffer.size());
cipher->cipher(input, &buffer[0], copied);
send(buffer, copied);
input += copied;
@@ -94,7 +94,7 @@ void Hash_Filter::end_msg()
{
SecureVector<byte> output = hash->final();
if(OUTPUT_LENGTH)
- send(output, std::min(OUTPUT_LENGTH, output.size()));
+ send(output, std::min<u32bit>(OUTPUT_LENGTH, output.size()));
else
send(output);
}
@@ -127,7 +127,7 @@ void MAC_Filter::end_msg()
{
SecureVector<byte> output = mac->final();
if(OUTPUT_LENGTH)
- send(output, std::min(OUTPUT_LENGTH, output.size()));
+ send(output, std::min<u32bit>(OUTPUT_LENGTH, output.size()));
else
send(output);
}
diff --git a/src/filters/data_src.cpp b/src/filters/data_src.cpp
index 2ca96ac6e..596e98ffd 100644
--- a/src/filters/data_src.cpp
+++ b/src/filters/data_src.cpp
@@ -46,7 +46,7 @@ u32bit DataSource::discard_next(u32bit n)
*/
u32bit DataSource_Memory::read(byte out[], u32bit length)
{
- u32bit got = std::min(source.size() - offset, length);
+ u32bit got = std::min<u32bit>(source.size() - offset, length);
copy_mem(out, &source[offset], got);
offset += got;
return got;
diff --git a/src/filters/hex_filt/hex_filt.cpp b/src/filters/hex_filt/hex_filt.cpp
index 441598946..51b8c1fd6 100644
--- a/src/filters/hex_filt/hex_filt.cpp
+++ b/src/filters/hex_filt/hex_filt.cpp
@@ -121,7 +121,7 @@ void Hex_Decoder::write(const byte input[], u32bit length)
{
while(length)
{
- u32bit to_copy = std::min(length, in.size() - position);
+ u32bit to_copy = std::min<u32bit>(length, in.size() - position);
copy_mem(&in[position], input, to_copy);
position += to_copy;
diff --git a/src/filters/modes/cts/cts.cpp b/src/filters/modes/cts/cts.cpp
index fd118bc3b..8504bbc0d 100644
--- a/src/filters/modes/cts/cts.cpp
+++ b/src/filters/modes/cts/cts.cpp
@@ -66,7 +66,7 @@ void CTS_Encryption::encrypt(const byte block[])
*/
void CTS_Encryption::write(const byte input[], u32bit length)
{
- u32bit copied = std::min(buffer.size() - position, length);
+ u32bit copied = std::min<u32bit>(buffer.size() - position, length);
buffer.copy(position, input, copied);
length -= copied;
input += copied;
@@ -169,7 +169,7 @@ void CTS_Decryption::decrypt(const byte block[])
*/
void CTS_Decryption::write(const byte input[], u32bit length)
{
- u32bit copied = std::min(buffer.size() - position, length);
+ u32bit copied = std::min<u32bit>(buffer.size() - position, length);
buffer.copy(position, input, copied);
length -= copied;
input += copied;
diff --git a/src/filters/modes/eax/eax.cpp b/src/filters/modes/eax/eax.cpp
index 2cb700daa..aa1fce507 100644
--- a/src/filters/modes/eax/eax.cpp
+++ b/src/filters/modes/eax/eax.cpp
@@ -115,7 +115,7 @@ void EAX_Encryption::write(const byte input[], u32bit length)
{
while(length)
{
- u32bit copied = std::min(length, ctr_buf.size());
+ u32bit copied = std::min<u32bit>(length, ctr_buf.size());
ctr->cipher(input, ctr_buf, copied);
cmac->update(ctr_buf, copied);
diff --git a/src/filters/modes/eax/eax_dec.cpp b/src/filters/modes/eax/eax_dec.cpp
index 998773697..71b676ae3 100644
--- a/src/filters/modes/eax/eax_dec.cpp
+++ b/src/filters/modes/eax/eax_dec.cpp
@@ -45,7 +45,7 @@ void EAX_Decryption::write(const byte input[], u32bit length)
{
while(length)
{
- const u32bit copied = std::min(length, queue.size() - queue_end);
+ const u32bit copied = std::min<u32bit>(length, queue.size() - queue_end);
queue.copy(queue_end, input, copied);
input += copied;
@@ -78,7 +78,7 @@ void EAX_Decryption::do_write(const byte input[], u32bit length)
{
while(length)
{
- u32bit copied = std::min(length, ctr_buf.size());
+ u32bit copied = std::min<u32bit>(length, ctr_buf.size());
/*
Process same block with cmac and ctr at the same time to
diff --git a/src/filters/secqueue.cpp b/src/filters/secqueue.cpp
index bfe02b0d3..0c45e81be 100644
--- a/src/filters/secqueue.cpp
+++ b/src/filters/secqueue.cpp
@@ -23,7 +23,7 @@ class SecureQueueNode
u32bit write(const byte input[], u32bit length)
{
- u32bit copied = std::min(length, buffer.size() - end);
+ u32bit copied = std::min<u32bit>(length, buffer.size() - end);
copy_mem(buffer + end, input, copied);
end += copied;
return copied;
diff --git a/src/kdf/kdf2/kdf2.cpp b/src/kdf/kdf2/kdf2.cpp
index 7cc1d7416..b9e785942 100644
--- a/src/kdf/kdf2/kdf2.cpp
+++ b/src/kdf/kdf2/kdf2.cpp
@@ -28,7 +28,7 @@ SecureVector<byte> KDF2::derive(u32bit out_len,
hash->update(P, P_len);
SecureVector<byte> hash_result = hash->final();
- u32bit added = std::min(hash_result.size(), out_len);
+ u32bit added = std::min<u32bit>(hash_result.size(), out_len);
output.append(hash_result, added);
out_len -= added;
diff --git a/src/kdf/mgf1/mgf1.cpp b/src/kdf/mgf1/mgf1.cpp
index 509a411fa..c79ae44bb 100644
--- a/src/kdf/mgf1/mgf1.cpp
+++ b/src/kdf/mgf1/mgf1.cpp
@@ -29,7 +29,7 @@ void MGF1::mask(const byte in[], u32bit in_len, byte out[],
hash->update(get_byte(j, counter));
SecureVector<byte> buffer = hash->final();
- u32bit xored = std::min(buffer.size(), out_len);
+ u32bit xored = std::min<u32bit>(buffer.size(), out_len);
xor_buf(out, &buffer[0], xored);
out += xored;
out_len -= xored;
diff --git a/src/pbkdf/pbkdf1/pbkdf1.cpp b/src/pbkdf/pbkdf1/pbkdf1.cpp
index 02d2c6cc0..d9bdf1b1f 100644
--- a/src/pbkdf/pbkdf1/pbkdf1.cpp
+++ b/src/pbkdf/pbkdf1/pbkdf1.cpp
@@ -34,7 +34,7 @@ OctetString PKCS5_PBKDF1::derive_key(u32bit key_len,
hash->final(key);
}
- return OctetString(key, std::min(key_len, key.size()));
+ return OctetString(key, std::min<u32bit>(key_len, key.size()));
}
}
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);