aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-12-10 11:51:48 -0500
committerJack Lloyd <[email protected]>2018-12-10 11:52:05 -0500
commit162e102cb3d2a1ca0f750341dea634b6434139c0 (patch)
tree4af3d141f8cb6f67cb34b0fa849267d14fc2e41f
parente4704821ab5ad67ff78d99e05ad2b1955b1e2e20 (diff)
Fix more MSVC warnings
-rw-r--r--src/cli/speed.cpp4
-rw-r--r--src/cli/x509.cpp4
-rw-r--r--src/lib/hash/mdx_hash/mdx_hash.cpp2
-rw-r--r--src/lib/tls/tls_cbc/tls_cbc.cpp7
4 files changed, 9 insertions, 8 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 518601a81..5ba73820b 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -2121,13 +2121,13 @@ class Speed final : public Command
if(Botan::is_passhash9_alg_supported(alg) == false)
continue;
- for(uint8_t work_factor : { 10, 15 })
+ for(auto work_factor : { 10, 15 })
{
std::unique_ptr<Timer> timer = make_timer("passhash9 alg=" + std::to_string(alg) +
" wf=" + std::to_string(work_factor));
timer->run([&] {
- Botan::generate_passhash9(password, rng(), work_factor, alg);
+ Botan::generate_passhash9(password, rng(), static_cast<uint8_t>(work_factor), alg);
});
record_result(timer);
diff --git a/src/cli/x509.cpp b/src/cli/x509.cpp
index d894b99a4..e2b99a494 100644
--- a/src/cli/x509.cpp
+++ b/src/cli/x509.cpp
@@ -262,9 +262,9 @@ class Gen_Self_Signed final : public Command
throw CLI_Error("Failed to load key from " + get_arg("key"));
}
- const size_t days = get_arg_sz("days");
+ const uint32_t lifetime = static_cast<uint32_t>(get_arg_sz("days") * 24 * 60 * 60);
- Botan::X509_Cert_Options opts("", days * 24 * 60 * 60);
+ Botan::X509_Cert_Options opts("", lifetime);
opts.common_name = get_arg("CN");
opts.country = get_arg("country");
diff --git a/src/lib/hash/mdx_hash/mdx_hash.cpp b/src/lib/hash/mdx_hash/mdx_hash.cpp
index 1dd631d04..5e58155ec 100644
--- a/src/lib/hash/mdx_hash/mdx_hash.cpp
+++ b/src/lib/hash/mdx_hash/mdx_hash.cpp
@@ -21,7 +21,7 @@ MDx_HashFunction::MDx_HashFunction(size_t block_len,
uint8_t cnt_size) :
m_pad_char(bit_big_endian == true ? 0x80 : 0x01),
m_counter_size(cnt_size),
- m_block_bits(static_cast<size_t>(ceil_log2(block_len))),
+ m_block_bits(static_cast<uint8_t>(ceil_log2(block_len))),
m_count_big_endian(byte_big_endian),
m_count(0),
m_buffer(block_len),
diff --git a/src/lib/tls/tls_cbc/tls_cbc.cpp b/src/lib/tls/tls_cbc/tls_cbc.cpp
index 7f67c400b..d63729611 100644
--- a/src/lib/tls/tls_cbc/tls_cbc.cpp
+++ b/src/lib/tls/tls_cbc/tls_cbc.cpp
@@ -369,7 +369,7 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<uint8_t>& buffer, size_t
BOTAN_ASSERT_NOMSG(enc_iv_size <= 0xFFFF);
- mac().update(assoc_data_with_len(enc_iv_size));
+ mac().update(assoc_data_with_len(static_cast<uint16_t>(enc_iv_size)));
if(iv_size() > 0)
{
mac().update(cbc_state());
@@ -391,7 +391,7 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<uint8_t>& buffer, size_t
cbc_decrypt_record(record_contents, enc_size);
// 0 if padding was invalid, otherwise 1 + padding_bytes
- uint16_t pad_size = check_tls_cbc_padding(record_contents, enc_size);
+ const uint16_t pad_size = check_tls_cbc_padding(record_contents, enc_size);
// No oracle here, whoever sent us this had the key since MAC check passed
if(pad_size == 0)
@@ -423,7 +423,8 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<uint8_t>& buffer, size_t
// We know the cast cannot overflow as pad_size <= 256 && tag_size <= 32
const auto size_ok_mask = CT::Mask<uint16_t>::is_lte(
- static_cast<uint16_t>(tag_size() + pad_size), record_len);
+ static_cast<uint16_t>(tag_size() + pad_size),
+ static_cast<uint16_t>(record_len));
pad_size = size_ok_mask.if_set_return(pad_size);