aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/xmss/xmss_privatekey.cpp
diff options
context:
space:
mode:
authorMatthias Gierlings <[email protected]>2019-04-20 09:45:59 +0200
committerMatthias Gierlings <[email protected]>2019-05-06 10:00:20 +0200
commit6bbccffa70ac2e7764c0ea8f0d7c87880b9dc109 (patch)
tree4f8a3671aa567e914f55440a4d4635d0a4619f55 /src/lib/pubkey/xmss/xmss_privatekey.cpp
parentb1976eb32b89e0dc88d2c9a760aefa4bafaf5cbe (diff)
Serialize XMSS leaf index as four bytes
Internally XMSS uses a 64 Bit type for the leaf index. This patch removes the four leading zero bytes from the XMSS leaf index and serializes it as a four byte value as described in RFC 8391. Test cases are adjusted accordingly. The 64 Bit type is kept internally which potentially allows for code reuse when implementing XMSS^MT on top of the current XMSS code.
Diffstat (limited to 'src/lib/pubkey/xmss/xmss_privatekey.cpp')
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.cpp b/src/lib/pubkey/xmss/xmss_privatekey.cpp
index 6559f5204..ee6a605f6 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_privatekey.cpp
@@ -48,7 +48,7 @@ XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<uint8_t>& raw_key)
// extract & copy unused leaf index from raw_key.
uint64_t unused_leaf = 0;
auto begin = (raw_key.begin() + XMSS_PublicKey::size());
- auto end = raw_key.begin() + XMSS_PublicKey::size() + sizeof(uint64_t);
+ auto end = raw_key.begin() + XMSS_PublicKey::size() + sizeof(uint32_t);
for(auto& i = begin; i != end; i++)
{
@@ -294,7 +294,7 @@ secure_vector<uint8_t> XMSS_PrivateKey::raw_private_key() const
secure_vector<uint8_t> result(pk.begin(), pk.end());
result.reserve(size());
- for(int i = 7; i >= 0; i--)
+ for(int i = 3; i >= 0; i--)
{
result.push_back(
static_cast<uint8_t>(