Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
21 class XMSS_Signature
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 **/
32 XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
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,
44 const secure_vector<uint8_t>& randomness,
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,
58 secure_vector<uint8_t>&& randomness,
59 XMSS_WOTS_PublicKey::TreeSignature&& tree_sig)
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
66 const secure_vector<uint8_t> randomness() const
67 {
68 return m_randomness;
69 }
70
71 secure_vector<uint8_t>& randomness()
72 {
73 return m_randomness;
74 }
75
76 void set_randomness(const secure_vector<uint8_t>& randomness)
77 {
78 m_randomness = randomness;
79 }
80
81 void set_randomness(secure_vector<uint8_t>&& randomness)
82 {
83 m_randomness = std::move(randomness);
84 }
85
86 const XMSS_WOTS_PublicKey::TreeSignature& tree() const
87 {
88 return m_tree_sig;
89 }
90
91 XMSS_WOTS_PublicKey::TreeSignature& tree()
92 {
93 return m_tree_sig;
94 }
95
96 void set_tree(const XMSS_WOTS_PublicKey::TreeSignature& tree_sig)
97 {
98 m_tree_sig = tree_sig;
99 }
100
101 void set_tree(XMSS_WOTS_PublicKey::TreeSignature&& tree_sig)
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 **/
118 secure_vector<uint8_t> bytes() const;
119
120 private:
121 size_t m_leaf_idx;
122 secure_vector<uint8_t> m_randomness;
123 XMSS_WOTS_PublicKey::TreeSignature m_tree_sig;
124 };
125
126 }
127
128 #endif
Botan::XMSS_Signature::XMSS_Signature
XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid, const secure_vector< uint8_t > &raw_sig)
Definition: xmss_signature.cpp:12
Botan::XMSS_Signature::unused_leaf_index
size_t unused_leaf_index() const
Definition: xmss_signature.h:63
std
Definition: bigint.h:619
Botan::XMSS_Signature::set_unused_leaf_idx
void set_unused_leaf_idx(size_t idx)
Definition: xmss_signature.h:64
Botan::XMSS_Signature::randomness
secure_vector< uint8_t > & randomness()
Definition: xmss_signature.h:71
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::XMSS_Signature::set_tree
void set_tree(XMSS_WOTS_PublicKey::TreeSignature &&tree_sig)
Definition: xmss_signature.h:101
Botan::XMSS_Signature::XMSS_Signature
XMSS_Signature(size_t leaf_idx, const secure_vector< uint8_t > &randomness, const XMSS_WOTS_PublicKey::TreeSignature &tree_sig)
Definition: xmss_signature.h:43
Botan::XMSS_Signature::set_randomness
void set_randomness(const secure_vector< uint8_t > &randomness)
Definition: xmss_signature.h:76
Botan::XMSS_Signature::tree
XMSS_WOTS_PublicKey::TreeSignature & tree()
Definition: xmss_signature.h:91
Botan::XMSS_WOTS_PublicKey::TreeSignature
Definition: xmss_wots_publickey.h:35
Botan::XMSS_Signature::set_tree
void set_tree(const XMSS_WOTS_PublicKey::TreeSignature &tree_sig)
Definition: xmss_signature.h:96
Botan
Definition: alg_id.cpp:13
Botan::XMSS_Signature::set_randomness
void set_randomness(secure_vector< uint8_t > &&randomness)
Definition: xmss_signature.h:81
Botan::XMSS_Signature::tree
const XMSS_WOTS_PublicKey::TreeSignature & tree() const
Definition: xmss_signature.h:86
Botan::XMSS_Signature::XMSS_Signature
XMSS_Signature(size_t leaf_idx, secure_vector< uint8_t > &&randomness, XMSS_WOTS_PublicKey::TreeSignature &&tree_sig)
Definition: xmss_signature.h:57
Botan::XMSS_Parameters::xmss_algorithm_t
xmss_algorithm_t
Definition: xmss_parameters.h:31
Botan::XMSS_Signature::bytes
secure_vector< uint8_t > bytes() const
Definition: xmss_signature.cpp:62
Botan::XMSS_Signature
Definition: xmss_signature.h:21
Botan::XMSS_Signature::randomness
const secure_vector< uint8_t > randomness() const
Definition: xmss_signature.h:66