aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/xmss
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-01-17 09:16:50 -0500
committerJack Lloyd <[email protected]>2019-01-17 09:16:50 -0500
commit377ed5445083af5703fe8b0411ad162af1766012 (patch)
tree77936fb806a62f37508803651b7d73bb8af3b11c /src/lib/pubkey/xmss
parent4c3016578da7b9840bb77563f4257df11c9f1de9 (diff)
Fix some warnings from PVS-Studio
No real bugs, but pointed out some odd constructs and duplicated logic
Diffstat (limited to 'src/lib/pubkey/xmss')
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.cpp8
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_parameters.cpp2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.cpp b/src/lib/pubkey/xmss/xmss_privatekey.cpp
index 426ebeb61..05d61981e 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_privatekey.cpp
@@ -112,9 +112,9 @@ XMSS_PrivateKey::tree_hash(size_t start_idx,
#if defined(BOTAN_TARGET_OS_HAS_THREADS)
}
- size_t subtrees = 1 << split_level;
- size_t last_idx = static_cast<size_t>(1 << (target_node_height)) + start_idx;
- size_t offs = (last_idx - start_idx) / subtrees;
+ const size_t subtrees = static_cast<size_t>(1) << split_level;
+ const size_t last_idx = (static_cast<size_t>(1) << (target_node_height)) + start_idx;
+ const size_t offs = (last_idx - start_idx) / subtrees;
uint8_t level = split_level; // current level in the tree
BOTAN_ASSERT((last_idx - start_idx) % subtrees == 0,
@@ -230,7 +230,7 @@ XMSS_PrivateKey::tree_hash_subtree(secure_vector<uint8_t>& result,
uint8_t level = 0; // current level on the node stack.
XMSS_WOTS_PublicKey pk(m_wots_priv_key.wots_parameters().oid(), seed);
- size_t last_idx = static_cast<size_t>(1 << target_node_height) + start_idx;
+ const size_t last_idx = (static_cast<size_t>(1) << target_node_height) + start_idx;
for(size_t i = start_idx; i < last_idx; i++)
{
diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
index c2a324475..e5e334bf9 100644
--- a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
@@ -79,7 +79,7 @@ XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(ots_algorithm_t oid)
break;
}
- m_w == 16 ? m_lg_w = 4 : m_lg_w = 2;
+ m_lg_w = (m_w == 16) ? 4 : 2;
m_len_1 = static_cast<size_t>(std::ceil((8 * element_size()) / m_lg_w));
m_len_2 = static_cast<size_t>(
floor(log2(m_len_1 * (wots_parameter() - 1)) / m_lg_w) + 1);