Botan 3.5.0
Crypto and TLS for C&
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 <botan/exceptn.h>
12#include <botan/secmem.h>
13#include <botan/types.h>
14#include <botan/xmss_parameters.h>
15#include <botan/internal/xmss_wots.h>
16#include <cstddef>
17
18namespace Botan {
19
20/**
21 * Helper class for marshalling an XMSS signature
22 */
24 public:
30
31 public:
32 /**
33 * Creates a signature from an XMSS signature method and a uint8_t sequence
34 * representing a raw signature.
35 *
36 * @param oid XMSS signature method
37 * @param raw_sig An XMSS signature serialized using
38 * XMSS_Signature::bytes().
39 **/
41
42 /**
43 * Creates an XMSS Signature from a leaf index used for signature
44 * generation, a random value and a tree signature.
45 *
46 * @param leaf_idx Leaf index used to generate the signature.
47 * @param randomness A random value.
48 * @param tree_sig A tree signature.
49 **/
51 m_leaf_idx(leaf_idx), m_randomness(std::move(randomness)), m_tree_sig(std::move(tree_sig)) {}
52
53 size_t unused_leaf_index() const { return m_leaf_idx; }
54
55 const secure_vector<uint8_t>& randomness() const { return m_randomness; }
56
57 const XMSS_Signature::TreeSignature& tree() const { return m_tree_sig; }
58
59 // These mutating operations should be removed:
60 void set_unused_leaf_idx(size_t idx) { m_leaf_idx = idx; }
61
62 secure_vector<uint8_t>& randomness() { return m_randomness; }
63
64 void set_randomness(secure_vector<uint8_t> randomness) { m_randomness = std::move(randomness); }
65
66 XMSS_Signature::TreeSignature& tree() { return m_tree_sig; }
67
68 void set_tree(XMSS_Signature::TreeSignature tree_sig) { m_tree_sig = std::move(tree_sig); }
69
70 /**
71 * Generates a serialized representation of XMSS Signature by
72 * concatenating the following elements in order:
73 * 4-byte leaf index, n-bytes randomness, ots_signature,
74 * authentication path.
75 *
76 * n is the element_size(), len equal to len(), h the tree height
77 * defined by the chosen XMSS signature method.
78 *
79 * @return serialized signature, a sequence of
80 * 4+(len + h + 1)n bytes.
81 **/
83
84 private:
85 size_t m_leaf_idx;
86 secure_vector<uint8_t> m_randomness;
88};
89
90} // namespace Botan
91
92#endif
void set_unused_leaf_idx(size_t idx)
void set_tree(XMSS_Signature::TreeSignature tree_sig)
const XMSS_Signature::TreeSignature & tree() const
XMSS_Signature(size_t leaf_idx, secure_vector< uint8_t > randomness, XMSS_Signature::TreeSignature tree_sig)
secure_vector< uint8_t > & randomness()
const secure_vector< uint8_t > & randomness() const
size_t unused_leaf_index() const
secure_vector< uint8_t > bytes() const
XMSS_Signature::TreeSignature & tree()
void set_randomness(secure_vector< uint8_t > randomness)
XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid, const secure_vector< uint8_t > &raw_sig)
int(* final)(unsigned char *, CTX *)
std::vector< secure_vector< uint8_t > > wots_keysig_t
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61