diff options
author | Jack Lloyd <[email protected]> | 2019-12-06 11:05:16 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-12-06 11:11:56 -0500 |
commit | bbc71ebaa1573290f38273ca80b563d272c0917c (patch) | |
tree | 33e5a0eecb8db399b259d19283e3c8364cd27e02 /src | |
parent | 9f3dbac2eb28906e53808682222aef4eb90f4c15 (diff) |
Fix MSVC "optimization" warning about bool conversions
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/math/numbertheory/numthry.cpp | 2 | ||||
-rw-r--r-- | src/lib/math/numbertheory/primality.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/aead/gcm/ghash.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/cfb/cfb.cpp | 6 | ||||
-rw-r--r-- | src/tests/test_ocsp.cpp | 12 | ||||
-rw-r--r-- | src/tests/unit_ecc.cpp | 2 | ||||
-rw-r--r-- | src/tests/unit_ecdsa.cpp | 12 |
7 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/math/numbertheory/numthry.cpp b/src/lib/math/numbertheory/numthry.cpp index 0d21f0237..90f1279b6 100644 --- a/src/lib/math/numbertheory/numthry.cpp +++ b/src/lib/math/numbertheory/numthry.cpp @@ -93,7 +93,7 @@ BigInt gcd(const BigInt& a, const BigInt& b) f.shrink_to_fit(); sub_abs(newg, f, g); - const uint8_t need_swap = (g.is_odd() && delta > 0); + const bool need_swap = (g.is_odd() && delta > 0); // if(need_swap) delta *= -1 delta *= CT::Mask<uint8_t>::expand(need_swap).select(0, 2) - 1; diff --git a/src/lib/math/numbertheory/primality.cpp b/src/lib/math/numbertheory/primality.cpp index 5e683c1ff..028e2a7ef 100644 --- a/src/lib/math/numbertheory/primality.cpp +++ b/src/lib/math/numbertheory/primality.cpp @@ -62,7 +62,7 @@ bool is_lucas_probable_prime(const BigInt& C, const Modular_Reducer& mod_C) for(size_t i = 0; i != K_bits; ++i) { - const uint8_t k_bit = K.get_bit(K_bits - 1 - i); + const bool k_bit = K.get_bit(K_bits - 1 - i); Ut = mod_C.multiply(U, V); diff --git a/src/lib/modes/aead/gcm/ghash.cpp b/src/lib/modes/aead/gcm/ghash.cpp index 3a4301113..43772803b 100644 --- a/src/lib/modes/aead/gcm/ghash.cpp +++ b/src/lib/modes/aead/gcm/ghash.cpp @@ -96,7 +96,7 @@ void GHASH::gcm_multiply(secure_vector<uint8_t>& x, void GHASH::ghash_update(secure_vector<uint8_t>& ghash, const uint8_t input[], size_t length) { - verify_key_set(m_HM.size()); + verify_key_set(!m_HM.empty()); /* This assumes if less than block size input then we're just on the diff --git a/src/lib/modes/cfb/cfb.cpp b/src/lib/modes/cfb/cfb.cpp index e1bee0427..0c619e322 100644 --- a/src/lib/modes/cfb/cfb.cpp +++ b/src/lib/modes/cfb/cfb.cpp @@ -82,7 +82,7 @@ void CFB_Mode::start_msg(const uint8_t nonce[], size_t nonce_len) if(!valid_nonce_length(nonce_len)) throw Invalid_IV_Length(name(), nonce_len); - verify_key_set(m_keystream.size()); + verify_key_set(!m_keystream.empty()); if(nonce_len == 0) { @@ -116,7 +116,7 @@ void CFB_Mode::shift_register() size_t CFB_Encryption::process(uint8_t buf[], size_t sz) { - verify_key_set(m_keystream.size()); + verify_key_set(!m_keystream.empty()); BOTAN_STATE_CHECK(m_state.empty() == false); const size_t shift = feedback(); @@ -181,7 +181,7 @@ inline void xor_copy(uint8_t buf[], uint8_t key_buf[], size_t len) size_t CFB_Decryption::process(uint8_t buf[], size_t sz) { - verify_key_set(m_keystream.size()); + verify_key_set(!m_keystream.empty()); BOTAN_STATE_CHECK(m_state.empty() == false); const size_t shift = feedback(); diff --git a/src/tests/test_ocsp.cpp b/src/tests/test_ocsp.cpp index 5ccebdb41..94da76c95 100644 --- a/src/tests/test_ocsp.cpp +++ b/src/tests/test_ocsp.cpp @@ -151,7 +151,7 @@ class OCSP_Tests final : public Test return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) && result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) && result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'", - ocsp_status[0].count(expected)); + ocsp_status[0].count(expected) > 0); }; check_ocsp(Botan::calendar_point(2016, 11, 11, 12, 30, 0).to_std_timepoint(), @@ -192,7 +192,7 @@ class OCSP_Tests final : public Test return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) && result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) && result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'", - ocsp_status[0].count(expected)); + ocsp_status[0].count(expected) > 0); }; check_ocsp(Botan::calendar_point(2016, 11, 11, 12, 30, 0).to_std_timepoint(), @@ -233,7 +233,7 @@ class OCSP_Tests final : public Test return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) && result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) && result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'", - ocsp_status[0].count(expected)); + ocsp_status[0].count(expected) > 0); }; check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 0, 0).to_std_timepoint(), @@ -269,7 +269,7 @@ class OCSP_Tests final : public Test return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) && result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) && result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'", - ocsp_status[0].count(expected)); + ocsp_status[0].count(expected) > 0); }; check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 0, 0).to_std_timepoint(), @@ -306,7 +306,7 @@ class OCSP_Tests final : public Test { if(result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1)) { - result.confirm("Status warning", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_NO_REVOCATION_URL)); + result.confirm("Status warning", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_NO_REVOCATION_URL) > 0); } } @@ -335,7 +335,7 @@ class OCSP_Tests final : public Test { if(result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1)) { - result.confirm("Status ok", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD)); + result.confirm("Status ok", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD) > 0); } } diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp index 14236d8ae..459d6a594 100644 --- a/src/tests/unit_ecc.cpp +++ b/src/tests/unit_ecc.cpp @@ -52,7 +52,7 @@ Botan::BigInt test_integer(Botan::RandomNumberGenerator& rng, size_t bits, BigIn return .01; }; - bool active = rng.next_byte() % 2; + bool active = (rng.next_byte() > 128) ? true : false; for(size_t i = 0; i != bits; ++i) { x <<= 1; diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp index a103e67b0..23d03768a 100644 --- a/src/tests/unit_ecdsa.cpp +++ b/src/tests/unit_ecdsa.cpp @@ -215,7 +215,7 @@ Test::Result test_ecdsa_create_save_load() Botan::DataSource_Memory pem_src(ecc_private_key_pem); std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(pem_src, Test::rng())); Botan::ECDSA_PrivateKey* loaded_ec_key = dynamic_cast<Botan::ECDSA_PrivateKey*>(loaded_key.get()); - result.confirm("the loaded key could be converted into an ECDSA_PrivateKey", loaded_ec_key); + result.confirm("the loaded key could be converted into an ECDSA_PrivateKey", loaded_ec_key != nullptr); if(loaded_ec_key) { @@ -257,7 +257,7 @@ Test::Result test_unusual_curve() Botan::DataSource_Memory key_data_src(key_odd_curve_str); std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(key_data_src, Test::rng())); - result.confirm("reloaded key", loaded_key.get()); + result.confirm("reloaded key", loaded_key.get() != nullptr); return result; } @@ -365,9 +365,9 @@ Test::Result test_ecc_key_with_rfc5915_extensions() std::unique_ptr<Botan::Private_Key> pkcs8( Botan::PKCS8::load_key(Test::data_file("x509/ecc/ecc_private_with_rfc5915_ext.pem"), Test::rng())); - result.confirm("loaded RFC 5915 key", pkcs8.get()); + result.confirm("loaded RFC 5915 key", pkcs8.get() != nullptr); result.test_eq("key is ECDSA", pkcs8->algo_name(), "ECDSA"); - result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get())); + result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get()) != nullptr); } catch(std::exception& e) { @@ -386,9 +386,9 @@ Test::Result test_ecc_key_with_rfc5915_parameters() std::unique_ptr<Botan::Private_Key> pkcs8( Botan::PKCS8::load_key(Test::data_file("x509/ecc/ecc_private_with_rfc5915_parameters.pem"), Test::rng())); - result.confirm("loaded RFC 5915 key", pkcs8.get()); + result.confirm("loaded RFC 5915 key", pkcs8.get() != nullptr); result.test_eq("key is ECDSA", pkcs8->algo_name(), "ECDSA"); - result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get())); + result.confirm("key type is ECDSA", dynamic_cast<Botan::ECDSA_PrivateKey*>(pkcs8.get()) != nullptr); } catch(std::exception& e) { |