Botan  2.1.0
Crypto and TLS for C++11
xmss_signature.h
Go to the documentation of this file.
1 /*
2  * XMSS Signature
3  * (C) 2016 Matthias Gierlings
4  *
5  * Botan is released under the Simplified BSD License (see license.txt)
6  **/
7 
8 #ifndef BOTAN_XMSS_SIGNATURE_H__
9 #define BOTAN_XMSS_SIGNATURE_H__
10 
11 #include <cstddef>
12 #include <iterator>
13 #include <botan/exceptn.h>
14 #include <botan/types.h>
15 #include <botan/secmem.h>
16 #include <botan/xmss_parameters.h>
17 #include <botan/xmss_wots_publickey.h>
18 
19 namespace Botan {
20 
22  {
23  public:
24  /**
25  * Creates a signature from an XMSS signature method and a uint8_t sequence
26  * representing a raw signature.
27  *
28  * @param oid XMSS signature method
29  * @param raw_sig An XMSS signature serialized using
30  * XMSS_Signature::bytes().
31  **/
33  const secure_vector<uint8_t>& raw_sig);
34 
35  /**
36  * Creates an XMSS Signature from a leaf index used for signature
37  * generation, a random value and a tree signature.
38  *
39  * @param leaf_idx Leaf index used to generate the signature.
40  * @param randomness A random value.
41  * @param tree_sig A tree signature.
42  **/
43  XMSS_Signature(size_t leaf_idx,
45  const XMSS_WOTS_PublicKey::TreeSignature& tree_sig)
46  : m_leaf_idx(leaf_idx), m_randomness(randomness),
47  m_tree_sig(tree_sig) {}
48 
49  /**
50  * Creates an XMSS Signature from a leaf index used for signature
51  * generation, a random value and a tree signature.
52  *
53  * @param leaf_idx Leaf index used to generate the signature.
54  * @param randomness A random value.
55  * @param tree_sig A tree signature.
56  **/
57  XMSS_Signature(size_t leaf_idx,
60  : m_leaf_idx(leaf_idx), m_randomness(std::move(randomness)),
61  m_tree_sig(std::move(tree_sig)) {}
62 
63  size_t unused_leaf_index() const { return m_leaf_idx; }
64  void set_unused_leaf_idx(size_t idx) { m_leaf_idx = idx; }
65 
67  {
68  return m_randomness;
69  }
70 
72  {
73  return m_randomness;
74  }
75 
77  {
78  m_randomness = randomness;
79  }
80 
82  {
83  m_randomness = std::move(randomness);
84  }
85 
87  {
88  return m_tree_sig;
89  }
90 
92  {
93  return m_tree_sig;
94  }
95 
97  {
98  m_tree_sig = tree_sig;
99  }
100 
102  {
103  m_tree_sig = std::move(tree_sig);
104  }
105 
106  /**
107  * Generates a serialized representation of XMSS Signature by
108  * concatenating the following elements in order:
109  * 8-byte leaf index, n-bytes randomness, ots_signature,
110  * authentication path.
111  *
112  * n is the element_size(), len equal to len(), h the tree height
113  * defined by the chosen XMSS signature method.
114  *
115  * @return serialized signature, a sequence of
116  * (len + h + 1)n bytes.
117  **/
119 
120  private:
121  size_t m_leaf_idx;
122  secure_vector<uint8_t> m_randomness;
124  };
125 
126 }
127 
128 #endif
XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid, const secure_vector< uint8_t > &raw_sig)
size_t unused_leaf_index() const
Definition: bigint.h:619
void set_unused_leaf_idx(size_t idx)
secure_vector< uint8_t > & randomness()
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
void set_tree(XMSS_WOTS_PublicKey::TreeSignature &&tree_sig)
XMSS_Signature(size_t leaf_idx, const secure_vector< uint8_t > &randomness, const XMSS_WOTS_PublicKey::TreeSignature &tree_sig)
void set_randomness(const secure_vector< uint8_t > &randomness)
XMSS_WOTS_PublicKey::TreeSignature & tree()
void set_tree(const XMSS_WOTS_PublicKey::TreeSignature &tree_sig)
Definition: alg_id.cpp:13
void set_randomness(secure_vector< uint8_t > &&randomness)
const XMSS_WOTS_PublicKey::TreeSignature & tree() const
XMSS_Signature(size_t leaf_idx, secure_vector< uint8_t > &&randomness, XMSS_WOTS_PublicKey::TreeSignature &&tree_sig)
secure_vector< uint8_t > bytes() const
const secure_vector< uint8_t > randomness() const