Botan  2.4.0
Crypto and TLS for C++11
xmss_common_ops.h
Go to the documentation of this file.
1 /*
2  * XMSS Common Ops
3  * (C) 2016,2017 Matthias Gierlings
4  *
5  * Botan is released under the Simplified BSD License (see license.txt)
6  **/
7 
8 #ifndef BOTAN_XMSS_COMMON_OPS_H_
9 #define BOTAN_XMSS_COMMON_OPS_H_
10 
11 #include <vector>
12 #include <botan/secmem.h>
13 #include <botan/xmss_parameters.h>
14 #include <botan/xmss_address.h>
15 #include <botan/xmss_hash.h>
16 
17 namespace Botan {
18 
19 typedef std::vector<secure_vector<uint8_t>> wots_keysig_t;
20 
21 /**
22  * Operations shared by XMSS signature generation and verification operations.
23  **/
25  {
26  public:
28  : m_xmss_params(oid), m_hash(m_xmss_params.hash_function_name()) {}
29 
30  protected:
31  /**
32  * Algorithm 7: "RAND_HASH"
33  *
34  * Generates a randomized hash.
35  *
36  * This overload is used in multithreaded scenarios, where it is
37  * required to provide seperate instances of XMSS_Hash to each
38  * thread.
39  *
40  * @param[out] result The resulting randomized hash.
41  * @param[in] left Left half of the hash function input.
42  * @param[in] right Right half of the hash function input.
43  * @param[in] adrs Adress of the hash function call.
44  * @param[in] seed The seed for G.
45  * @param[in] hash Instance of XMSS_Hash, that may only by the thead
46  * executing generate_public_key.
47  **/
49  secure_vector<uint8_t>& result,
50  const secure_vector<uint8_t>& left,
51  const secure_vector<uint8_t>& right,
52  XMSS_Address& adrs,
53  const secure_vector<uint8_t>& seed,
54  XMSS_Hash& hash);
55 
56  /**
57  * Algorithm 7: "RAND_HASH"
58  *
59  * Generates a randomized hash.
60  *
61  * @param[out] result The resulting randomized hash.
62  * @param[in] left Left half of the hash function input.
63  * @param[in] right Right half of the hash function input.
64  * @param[in] adrs Adress of the hash function call.
65  * @param[in] seed The seed for G.
66  **/
67  inline void randomize_tree_hash(
68  secure_vector<uint8_t>& result,
69  const secure_vector<uint8_t>& left,
70  const secure_vector<uint8_t>& right,
71  XMSS_Address& adrs,
72  const secure_vector<uint8_t>& seed)
73  {
74  randomize_tree_hash(result, left, right, adrs, seed, m_hash);
75  }
76 
77  /**
78  * Algorithm 8: "ltree"
79  * Create an L-tree used to compute the leaves of the binary hash tree.
80  * Takes a WOTS+ public key and compresses it to a single n-byte value.
81  *
82  * This overload is used in multithreaded scenarios, where it is
83  * required to provide seperate instances of XMSS_Hash to each thread.
84  *
85  * @param[out] result Public key compressed to a single n-byte value
86  * pk[0].
87  * @param[in] pk Winternitz One Time Signatures+ public key.
88  * @param[in] adrs Address encoding the address of the L-Tree
89  * @param[in] seed The seed generated during the public key generation.
90  * @param[in] hash Instance of XMSS_Hash, that may only be used by the
91  * thead executing create_l_tree.
92  **/
94  wots_keysig_t pk,
95  XMSS_Address& adrs,
96  const secure_vector<uint8_t>& seed,
97  XMSS_Hash& hash);
98 
99  /**
100  * Algorithm 8: "ltree"
101  * Create an L-tree used to compute the leaves of the binary hash tree.
102  * Takes a WOTS+ public key and compresses it to a single n-byte value.
103  *
104  * @param[out] result Public key compressed to a single n-byte value
105  * pk[0].
106  * @param[in] pk Winternitz One Time Signatures+ public key.
107  * @param[in] adrs Address encoding the address of the L-Tree
108  * @param[in] seed The seed generated during the public key generation.
109  **/
111  wots_keysig_t pk,
112  XMSS_Address& adrs,
113  const secure_vector<uint8_t>& seed)
114  {
115  create_l_tree(result, pk, adrs, seed, m_hash);
116  }
117 
118  protected:
121 
122  };
123 
124 }
125 
126 #endif
XMSS_Common_Ops(XMSS_Parameters::xmss_algorithm_t oid)
void create_l_tree(secure_vector< uint8_t > &result, wots_keysig_t pk, XMSS_Address &adrs, const secure_vector< uint8_t > &seed)
void create_l_tree(secure_vector< uint8_t > &result, wots_keysig_t pk, XMSS_Address &adrs, const secure_vector< uint8_t > &seed, XMSS_Hash &hash)
XMSS_Parameters m_xmss_params
void randomize_tree_hash(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &left, const secure_vector< uint8_t > &right, XMSS_Address &adrs, const secure_vector< uint8_t > &seed)
Definition: alg_id.cpp:13
std::vector< secure_vector< uint8_t > > wots_keysig_t
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
void randomize_tree_hash(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &left, const secure_vector< uint8_t > &right, XMSS_Address &adrs, const secure_vector< uint8_t > &seed, XMSS_Hash &hash)
MechanismType hash