8 #ifndef BOTAN_XMSS_PRIVATEKEY_H_
9 #define BOTAN_XMSS_PRIVATEKEY_H_
14 #include <botan/alg_id.h>
15 #include <botan/exceptn.h>
16 #include <botan/pk_keys.h>
17 #include <botan/types.h>
18 #include <botan/xmss_parameters.h>
19 #include <botan/xmss_publickey.h>
20 #include <botan/atomic.h>
21 #include <botan/xmss_common_ops.h>
22 #include <botan/xmss_wots_privatekey.h>
23 #include <botan/xmss_index_registry.h>
91 set_unused_leaf_index(idx_leaf);
105 return *recover_global_leaf_index();
119 throw Decoding_Error(
"XMSS private key leaf index out of bounds");
123 std::atomic<size_t>& index =
124 static_cast<std::atomic<size_t>&
>(*recover_global_leaf_index());
129 current = index.load();
133 while(!index.compare_exchange_strong(current, idx));
139 size_t idx = (
static_cast<std::atomic<size_t>&
>(
140 *recover_global_leaf_index())).fetch_add(1);
143 throw Decoding_Error(
"XMSS private key, one time signatures exhaused");
156 return m_wots_priv_key;
167 return m_wots_priv_key;
183 m_public_seed = public_seed;
184 m_wots_priv_key.set_public_seed(public_seed);
189 m_public_seed = std::move(public_seed);
190 m_wots_priv_key.set_public_seed(m_public_seed);
195 return m_public_seed;
198 std::unique_ptr<PK_Ops::Signature>
201 const std::string& provider)
const override;
238 size_t target_node_height,
245 std::shared_ptr<Atomic<size_t>> recover_global_leaf_index()
const;
249 size_t target_node_height,
252 return tree_hash_subtree(result, start_idx, target_node_height, adrs,
m_hash);
259 void tree_hash_subtree(secure_vector<uint8_t>& result,
261 size_t target_node_height,
265 XMSS_WOTS_PrivateKey m_wots_priv_key;
266 secure_vector<uint8_t> m_prf;
267 XMSS_Index_Registry& m_index_reg;
const secure_vector< uint8_t > & public_seed() const override
void set_public_seed(const secure_vector< uint8_t > &public_seed) override
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
secure_vector< uint8_t > get_contents()
void set_unused_leaf_index(size_t idx)
size_t reserve_unused_leaf_index()
DER_Encoder & encode(bool b)
secure_vector< uint8_t > private_key_bits() const override
std::vector< T, secure_allocator< T >> secure_vector
size_t size() const override
void set_public_seed(secure_vector< uint8_t > &&public_seed) override
virtual size_t size() const
XMSS_PrivateKey(XMSS_Parameters::xmss_algorithm_t xmss_algo_id, size_t idx_leaf, const secure_vector< uint8_t > &wots_priv_seed, const secure_vector< uint8_t > &prf, const secure_vector< uint8_t > &root, const secure_vector< uint8_t > &public_seed)
bool stateful_operation() const override
const secure_vector< uint8_t > & prf() const
XMSS_Parameters m_xmss_params
std::unique_ptr< HashFunction > m_hash
XMSS_WOTS_PrivateKey & wots_private_key()
size_t unused_leaf_index() const
const XMSS_WOTS_PrivateKey & wots_private_key() const
secure_vector< uint8_t > & prf()