Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::XMSS_Signature Class Reference

`#include <xmss_signature.h>`

## Public Member Functions
secure_vector< uint8_t > | bytes () const
const secure_vector< uint8_t > | randomness () const
secure_vector< uint8_t > & | randomness ()
void | set_randomness (const secure_vector< uint8_t > &randomness)
void | set_randomness (secure_vector< uint8_t > &&randomness)
void | set_tree (const XMSS_WOTS_PublicKey::TreeSignature &tree_sig)
void | set_tree (XMSS_WOTS_PublicKey::TreeSignature &&tree_sig)
void | set_unused_leaf_idx (size_t idx)
const XMSS_WOTS_PublicKey::TreeSignature & | tree () const
XMSS_WOTS_PublicKey::TreeSignature & | tree ()
size_t | unused_leaf_index () const
| XMSS_Signature (XMSS_Parameters::xmss_algorithm_t oid, const secure_vector< uint8_t > &raw_sig)
| XMSS_Signature (size_t leaf_idx, const secure_vector< uint8_t > &randomness, const XMSS_WOTS_PublicKey::TreeSignature &tree_sig)
| XMSS_Signature (size_t leaf_idx, secure_vector< uint8_t > &&randomness, XMSS_WOTS_PublicKey::TreeSignature &&tree_sig)

## Detailed Description

Definition at line 21 of file xmss_signature.h.

## Constructor & Destructor Documentation

Botan::XMSS_Signature::XMSS_Signature | ( | XMSS_Parameters::xmss_algorithm_t | oid,
|  | const secure_vector< uint8_t > & | raw_sig
| ) |  |

Creates a signature from an XMSS signature method and a uint8_t sequence representing a raw signature.

Parameters

  oid | XMSS signature method
  raw_sig | An XMSS signature serialized using XMSS_Signature::bytes().

Definition at line 12 of file xmss_signature.cpp.

References Botan::XMSS_WOTS_PublicKey::TreeSignature::authentication_path(), BOTAN_ASSERT, Botan::XMSS_Parameters::element_size(), Botan::XMSS_Parameters::len(), Botan::XMSS_WOTS_PublicKey::TreeSignature::ots_signature(), and Botan::XMSS_Parameters::tree_height().

14 : m_leaf_idx(0), m_randomness(0, 0x00), m_tree_sig()
15 {
16 BOTAN_ASSERT(sizeof(size_t) >= ceil(static_cast<float>(
17 (XMSS_Parameters(oid)).tree_height()) / 8.f),
18 "System type \"size_t\" not big enough to support"
19 " leaf index.");
20
21 XMSS_Parameters xmss_params(oid);
22 uint64_t leaf_idx = 0;
23 for(size_t i = 0; i < 8; i++)
24 leaf_idx = ((leaf_idx << 8) | raw_sig[i]);
25
26 if(leaf_idx >= (1ull << (xmss_params.tree_height() - 1)))
27 {
28 throw Integrity_Failure("XMSS signature leaf index out of "
29 "bounds.");
30 }
31 m_leaf_idx = static_cast<size_t>(leaf_idx);
32
33 auto begin = raw_sig.begin() + sizeof(uint64_t);
34 auto end = begin + xmss_params.element_size();
35 std::copy(begin, end, std::back_inserter(m_randomness));
36
37 for(size_t i = 0; i < xmss_params.len(); i++)
38 {
39 begin = end;
40 end = begin + xmss_params.element_size();
41 m_tree_sig.ots_signature().push_back(secure_vector<uint8_t>(0));
42 m_tree_sig.ots_signature().back().reserve(
43 xmss_params.element_size());
44 std::copy(begin,
45 end,
46 std::back_inserter(m_tree_sig.ots_signature().back()));
47 }
48
49 for(size_t i = 0; i < xmss_params.tree_height(); i++)
50 {
51 begin = end;
52 end = begin + xmss_params.element_size();
53 m_tree_sig.authentication_path().push_back(secure_vector<uint8_t>(0));
54 m_tree_sig.authentication_path().back().reserve(
55 xmss_params.element_size());
56 std::copy(begin,
57 end,
58 std::back_inserter(m_tree_sig.authentication_path().back()));
59 }
60 }
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_WOTS_PublicKey::TreeSignature::ots_signature
const wots_keysig_t & ots_signature() const
Definition: xmss_wots_publickey.h:51
Botan::XMSS_WOTS_PublicKey::TreeSignature::authentication_path
const wots_keysig_t & authentication_path() const
Definition: xmss_wots_publickey.h:61

Botan::XMSS_Signature::XMSS_Signature | ( | size_t | leaf_idx,
|  | const secure_vector< uint8_t > & | randomness,
|  | const XMSS_WOTS_PublicKey::TreeSignature & | tree_sig
| ) |  |
| inline

Creates an XMSS Signature from a leaf index used for signature generation, a random value and a tree signature.

Parameters

  leaf_idx | Leaf index used to generate the signature.
  randomness | A random value.
  tree_sig | A tree signature.

Definition at line 43 of file xmss_signature.h.

46 : m_leaf_idx(leaf_idx), m_randomness(randomness),
47 m_tree_sig(tree_sig) {}
Botan::XMSS_Signature::randomness
const secure_vector< uint8_t > randomness() const
Definition: xmss_signature.h:66

Botan::XMSS_Signature::XMSS_Signature | ( | size_t | leaf_idx,
|  | secure_vector< uint8_t > && | randomness,
|  | XMSS_WOTS_PublicKey::TreeSignature && | tree_sig
| ) |  |
| inline

Creates an XMSS Signature from a leaf index used for signature generation, a random value and a tree signature.

Parameters

  leaf_idx | Leaf index used to generate the signature.
  randomness | A random value.
  tree_sig | A tree signature.

Definition at line 57 of file xmss_signature.h.

60 : m_leaf_idx(leaf_idx), m_randomness(std::move(randomness)),
61 m_tree_sig(std::move(tree_sig)) {}
Botan::XMSS_Signature::randomness
const secure_vector< uint8_t > randomness() const
Definition: xmss_signature.h:66

## Member Function Documentation

secure_vector< uint8_t > Botan::XMSS_Signature::bytes | ( |  | ) | const

Generates a serialized representation of XMSS Signature by concatenating the following elements in order: 8-byte leaf index, n-bytes randomness, ots_signature, authentication path.

n is the element_size(), len equal to len(), h the tree height defined by the chosen XMSS signature method.

Returns
  serialized signature, a sequence of (len + h + 1)n bytes.

Definition at line 62 of file xmss_signature.cpp.

References Botan::XMSS_WOTS_PublicKey::TreeSignature::authentication_path(), Botan::XMSS_WOTS_PublicKey::TreeSignature::ots_signature(), and tree().

63 {
64 secure_vector<uint8_t> result
65 {
66 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 56U),
67 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 48U),
68 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 40U),
69 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 32U),
70 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 24U),
71 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 16U),
72 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 8U),
73 static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) )
74 };
75
76 std::copy(m_randomness.begin(),
77 m_randomness.end(),
78 std::back_inserter(result));
79
80 for(const auto& sig : tree().ots_signature())
81 {
82 std::copy(sig.begin(),
83 sig.end(),
84 std::back_inserter(result));
85 }
86
87 for(const auto& auth : tree().authentication_path())
88 {
89 std::copy(auth.begin(),
90 auth.end(),
91 std::back_inserter(result));
92 }
93 return result;
94 }
Botan::XMSS_WOTS_PublicKey::TreeSignature::ots_signature
const wots_keysig_t & ots_signature() const
Definition: xmss_wots_publickey.h:51
Botan::XMSS_Signature::tree
const XMSS_WOTS_PublicKey::TreeSignature & tree() const
Definition: xmss_signature.h:86
Botan::XMSS_WOTS_PublicKey::TreeSignature::authentication_path
const wots_keysig_t & authentication_path() const
Definition: xmss_wots_publickey.h:61

const secure_vector<uint8_t> Botan::XMSS_Signature::randomness | ( |  | ) | const
| inline

Definition at line 66 of file xmss_signature.h.

Referenced by set_randomness().

67 {
68 return m_randomness;
69 }

secure_vector<uint8_t>& Botan::XMSS_Signature::randomness | ( |  | ) |
| inline

Definition at line 71 of file xmss_signature.h.

72 {
73 return m_randomness;
74 }

void Botan::XMSS_Signature::set_randomness | ( | const secure_vector< uint8_t > & | randomness | ) |
| inline

Definition at line 76 of file xmss_signature.h.

References randomness().

77 {
78 m_randomness = randomness;
79 }
Botan::XMSS_Signature::randomness
const secure_vector< uint8_t > randomness() const
Definition: xmss_signature.h:66

void Botan::XMSS_Signature::set_randomness | ( | secure_vector< uint8_t > && | randomness | ) |
| inline

Definition at line 81 of file xmss_signature.h.

References randomness().

82 {
83 m_randomness = std::move(randomness);
84 }
Botan::XMSS_Signature::randomness
const secure_vector< uint8_t > randomness() const
Definition: xmss_signature.h:66

void Botan::XMSS_Signature::set_tree | ( | const XMSS_WOTS_PublicKey::TreeSignature & | tree_sig | ) |
| inline

Definition at line 96 of file xmss_signature.h.

97 {
98 m_tree_sig = tree_sig;
99 }

void Botan::XMSS_Signature::set_tree | ( | XMSS_WOTS_PublicKey::TreeSignature && | tree_sig | ) |
| inline

Definition at line 101 of file xmss_signature.h.

102 {
103 m_tree_sig = std::move(tree_sig);
104 }

void Botan::XMSS_Signature::set_unused_leaf_idx | ( | size_t | idx | ) |
| inline

Definition at line 64 of file xmss_signature.h.

64 { m_leaf_idx = idx; }

const XMSS_WOTS_PublicKey::TreeSignature& Botan::XMSS_Signature::tree | ( |  | ) | const
| inline

Definition at line 86 of file xmss_signature.h.

Referenced by bytes().

87 {
88 return m_tree_sig;
89 }

XMSS_WOTS_PublicKey::TreeSignature& Botan::XMSS_Signature::tree | ( |  | ) |
| inline

Definition at line 91 of file xmss_signature.h.

92 {
93 return m_tree_sig;
94 }

size_t Botan::XMSS_Signature::unused_leaf_index | ( |  | ) | const
| inline

Definition at line 63 of file xmss_signature.h.

63 { return m_leaf_idx; }

The documentation for this class was generated from the following files:

- src/lib/pubkey/xmss/xmss_signature.h
- src/lib/pubkey/xmss/xmss_signature.cpp