aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-26 09:12:53 -0400
committerJack Lloyd <[email protected]>2018-05-26 09:12:53 -0400
commitf256e603ab93e2587fe0e38bcf06c437fcd41abf (patch)
treefb147905449928c78e6915b008e70aa79db03be2
parent501e524c886cdafd797a81c5c11410c71426e225 (diff)
parent154b1cb7326f70ad5f9692c004f0711ca0c4e2b1 (diff)
Merge GH #1582 Fix XMSS leaf index (max signature count) check
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.cpp3
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.h4
-rw-r--r--src/lib/pubkey/xmss/xmss_signature.cpp2
3 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.cpp b/src/lib/pubkey/xmss/xmss_privatekey.cpp
index 37dbd61e3..426ebeb61 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_privatekey.cpp
@@ -50,8 +50,7 @@ XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<uint8_t>& raw_key)
unused_leaf = ((unused_leaf << 8) | *i);
}
- if(unused_leaf >= (1ull << (XMSS_PublicKey::m_xmss_params.tree_height() -
- 1)))
+ if(unused_leaf >= (1ull << XMSS_PublicKey::m_xmss_params.tree_height()))
{
throw Integrity_Failure("XMSS private key leaf index out of "
"bounds.");
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.h b/src/lib/pubkey/xmss/xmss_privatekey.h
index 3cd9f75f4..d66933724 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_privatekey.h
@@ -113,7 +113,7 @@ class BOTAN_PUBLIC_API(2,0) XMSS_PrivateKey final : public virtual XMSS_PublicKe
**/
void set_unused_leaf_index(size_t idx)
{
- if(idx >= (1ull << (XMSS_PublicKey::m_xmss_params.tree_height() - 1)))
+ if(idx >= (1ull << XMSS_PublicKey::m_xmss_params.tree_height()))
{
throw Integrity_Failure("XMSS private key leaf index out of "
"bounds.");
@@ -138,7 +138,7 @@ class BOTAN_PUBLIC_API(2,0) XMSS_PrivateKey final : public virtual XMSS_PublicKe
{
size_t idx = (static_cast<std::atomic<size_t>&>(
*recover_global_leaf_index())).fetch_add(1);
- if(idx >= (1ull << (XMSS_PublicKey::m_xmss_params.tree_height() - 1)))
+ if(idx >= (1ull << XMSS_PublicKey::m_xmss_params.tree_height()))
{
throw Integrity_Failure("XMSS private key, one time signatures "
"exhausted.");
diff --git a/src/lib/pubkey/xmss/xmss_signature.cpp b/src/lib/pubkey/xmss/xmss_signature.cpp
index 88809cf7b..f2d1ba4f1 100644
--- a/src/lib/pubkey/xmss/xmss_signature.cpp
+++ b/src/lib/pubkey/xmss/xmss_signature.cpp
@@ -25,7 +25,7 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
for(size_t i = 0; i < 8; i++)
{ m_leaf_idx = ((m_leaf_idx << 8) | raw_sig[i]); }
- if(m_leaf_idx >= (1ull << (xmss_params.tree_height() - 1)))
+ if(m_leaf_idx >= (1ull << xmss_params.tree_height()))
{
throw Integrity_Failure("XMSS signature leaf index out of bounds.");
}