aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-09-30 16:45:20 -0400
committerJack Lloyd <[email protected]>2018-09-30 16:45:20 -0400
commit38f053a5f8cb1ca351ba52d76c15491d63fd3eb0 (patch)
tree13c06b095059af302b8e0d9562a4aa7a9a6e73b1 /src
parente9ba0d9cdf0726b357d7aeca14ef43f1d10be1e8 (diff)
Fix some MSVC warnings
Diffstat (limited to 'src')
-rw-r--r--src/lib/block/idea/idea.cpp4
-rw-r--r--src/lib/math/numbertheory/monty_exp.cpp8
-rw-r--r--src/lib/math/numbertheory/nistp_redc.cpp2
-rw-r--r--src/lib/math/numbertheory/powm_fw.cpp2
-rw-r--r--src/lib/modes/aead/ocb/ocb.cpp6
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.cpp2
-rw-r--r--src/lib/pubkey/ec_group/point_mul.cpp8
-rw-r--r--src/lib/utils/timer.h4
8 files changed, 18 insertions, 18 deletions
diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp
index de153e2c5..d6380368d 100644
--- a/src/lib/block/idea/idea.cpp
+++ b/src/lib/block/idea/idea.cpp
@@ -197,7 +197,7 @@ void IDEA::key_schedule(const uint8_t key[], size_t)
for(size_t off = 0; off != 48; off += 8)
{
for(size_t i = 0; i != 8; ++i)
- m_EK[off+i] = K[i/4] >> (48-16*(i % 4));
+ m_EK[off+i] = static_cast<uint16_t>(K[i/4] >> (48-16*(i % 4)));
const uint64_t Kx = (K[0] >> 39);
const uint64_t Ky = (K[1] >> 39);
@@ -207,7 +207,7 @@ void IDEA::key_schedule(const uint8_t key[], size_t)
}
for(size_t i = 0; i != 4; ++i)
- m_EK[48+i] = K[i/4] >> (48-16*(i % 4));
+ m_EK[48+i] = static_cast<uint16_t>(K[i/4] >> (48-16*(i % 4)));
m_DK[0] = mul_inv(m_EK[48]);
m_DK[1] = -m_EK[49];
diff --git a/src/lib/math/numbertheory/monty_exp.cpp b/src/lib/math/numbertheory/monty_exp.cpp
index 567492091..2b5bbd81d 100644
--- a/src/lib/math/numbertheory/monty_exp.cpp
+++ b/src/lib/math/numbertheory/monty_exp.cpp
@@ -44,7 +44,7 @@ Montgomery_Exponentation_State::Montgomery_Exponentation_State(std::shared_ptr<c
if(m_window_bits < 1 || m_window_bits > 12) // really even 8 is too large ...
throw Invalid_Argument("Invalid window bits for Montgomery exponentiation");
- const size_t window_size = (1U << m_window_bits);
+ const size_t window_size = (static_cast<size_t>(1) << m_window_bits);
m_g.reserve(window_size);
@@ -233,10 +233,10 @@ BigInt monty_multi_exp(std::shared_ptr<const Montgomery_Params> params_p,
H.square_this(ws);
}
- const uint8_t z1_b = z1.get_substring(z_bits - i - 2, 2);
- const uint8_t z2_b = z2.get_substring(z_bits - i - 2, 2);
+ const uint32_t z1_b = z1.get_substring(z_bits - i - 2, 2);
+ const uint32_t z2_b = z2.get_substring(z_bits - i - 2, 2);
- const uint8_t z12 = (4*z2_b) + z1_b;
+ const uint32_t z12 = (4*z2_b) + z1_b;
H.mul_by(*M[z12], ws);
}
diff --git a/src/lib/math/numbertheory/nistp_redc.cpp b/src/lib/math/numbertheory/nistp_redc.cpp
index 1c2855784..ba0c5142d 100644
--- a/src/lib/math/numbertheory/nistp_redc.cpp
+++ b/src/lib/math/numbertheory/nistp_redc.cpp
@@ -43,7 +43,7 @@ void redc_p521(BigInt& x, secure_vector<word>& ws)
BOTAN_ASSERT_EQUAL(carry, 0, "Final carry in P-521 reduction");
// Now find the actual carry in bit 522
- const uint8_t bit_522_set = x.word_at(p_full_words) >> (p_top_bits);
+ const word bit_522_set = x.word_at(p_full_words) >> p_top_bits;
#if (BOTAN_MP_WORD_BITS == 64)
static const word p521_words[9] = {
diff --git a/src/lib/math/numbertheory/powm_fw.cpp b/src/lib/math/numbertheory/powm_fw.cpp
index 85a0364b5..c326ffa44 100644
--- a/src/lib/math/numbertheory/powm_fw.cpp
+++ b/src/lib/math/numbertheory/powm_fw.cpp
@@ -25,7 +25,7 @@ void Fixed_Window_Exponentiator::set_base(const BigInt& base)
{
m_window_bits = Power_Mod::window_bits(m_exp.bits(), base.bits(), m_hints);
- m_g.resize(1U << m_window_bits);
+ m_g.resize(static_cast<size_t>(1) << m_window_bits);
m_g[0] = 1;
m_g[1] = base;
diff --git a/src/lib/modes/aead/ocb/ocb.cpp b/src/lib/modes/aead/ocb/ocb.cpp
index cfc805e72..866527800 100644
--- a/src/lib/modes/aead/ocb/ocb.cpp
+++ b/src/lib/modes/aead/ocb/ocb.cpp
@@ -69,7 +69,7 @@ class L_computer final
// ntz(4*i+2) == 1
// ntz(4*i+3) == 0
block_index += 4;
- const size_t ntz4 = ctz<uint32_t>(block_index);
+ const size_t ntz4 = ctz<uint32_t>(static_cast<uint32_t>(block_index));
xor_buf(offsets, m_offset.data(), L0.data(), m_BS);
offsets += m_BS;
@@ -91,7 +91,7 @@ class L_computer final
for(size_t i = 0; i != blocks; ++i)
{ // could be done in parallel
- const size_t ntz = ctz<uint32_t>(block_index + i + 1);
+ const size_t ntz = ctz<uint32_t>(static_cast<uint32_t>(block_index + i + 1));
xor_buf(m_offset.data(), get(ntz).data(), m_BS);
copy_mem(offsets, m_offset.data(), m_BS);
offsets += m_BS;
@@ -136,7 +136,7 @@ secure_vector<uint8_t> ocb_hash(const L_computer& L,
for(size_t i = 0; i != ad_blocks; ++i)
{
// this loop could run in parallel
- offset ^= L.get(ctz<uint32_t>(i+1));
+ offset ^= L.get(ctz<uint32_t>(static_cast<uint32_t>(i+1)));
buf = offset;
xor_buf(buf.data(), &ad[BS*i], BS);
cipher.encrypt(buf);
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
index 65e8a9503..6fc007bf3 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
@@ -178,7 +178,7 @@ PBKDF* PKCS5_PBKDF2::clone() const
PBKDF2::PBKDF2(const MessageAuthenticationCode& prf, size_t olen, std::chrono::milliseconds msec) :
m_prf(prf.clone()),
- m_iterations(tune_pbkdf2(*m_prf, olen, msec.count()))
+ m_iterations(tune_pbkdf2(*m_prf, olen, static_cast<uint32_t>(msec.count())))
{}
std::string PBKDF2::to_string() const
diff --git a/src/lib/pubkey/ec_group/point_mul.cpp b/src/lib/pubkey/ec_group/point_mul.cpp
index 760f060ce..da3abaacc 100644
--- a/src/lib/pubkey/ec_group/point_mul.cpp
+++ b/src/lib/pubkey/ec_group/point_mul.cpp
@@ -170,7 +170,7 @@ PointGFp_Var_Point_Precompute::PointGFp_Var_Point_Precompute(const PointGFp& poi
if(ws.size() < PointGFp::WORKSPACE_SIZE)
ws.resize(PointGFp::WORKSPACE_SIZE);
- std::vector<PointGFp> U(1U << m_window_bits);
+ std::vector<PointGFp> U(static_cast<size_t>(1) << m_window_bits);
U[0] = point.zero();
U[1] = point;
@@ -354,10 +354,10 @@ PointGFp PointGFp_Multi_Point_Precompute::multi_exp(const BigInt& z1,
H.mult2i(2, ws);
}
- const uint8_t z1_b = z1.get_substring(z_bits - i - 2, 2);
- const uint8_t z2_b = z2.get_substring(z_bits - i - 2, 2);
+ const uint32_t z1_b = z1.get_substring(z_bits - i - 2, 2);
+ const uint32_t z2_b = z2.get_substring(z_bits - i - 2, 2);
- const uint8_t z12 = (4*z2_b) + z1_b;
+ const uint32_t z12 = (4*z2_b) + z1_b;
// This function is not intended to be const time
if(z12)
diff --git a/src/lib/utils/timer.h b/src/lib/utils/timer.h
index 6a6b807db..86a17b462 100644
--- a/src/lib/utils/timer.h
+++ b/src/lib/utils/timer.h
@@ -33,7 +33,7 @@ class BOTAN_TEST_API Timer final
{}
Timer(const std::string& name, size_t buf_size = 0) :
- Timer(name, "", "", 1, buf_size, 0.0, 0.0)
+ Timer(name, "", "", 1, buf_size, 0.0, 0)
{}
Timer(const Timer& other) = default;
@@ -122,7 +122,7 @@ class BOTAN_TEST_API Timer final
{
if(m_clock_speed != 0)
{
- return (static_cast<double>(m_clock_speed) * value()) / 1000;
+ return static_cast<uint64_t>((m_clock_speed * value()) / 1000.0);
}
return m_cpu_cycles_used;
}