Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

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

Public Types | Public Member Functions | Protected Attributes | List of all members
Botan::XMSS_Address Class Reference

`#include <xmss_address.h>`

## Public Types
enum | Key_Mask : uint8_t { Key_Mask::Key_Mode = 0, Key_Mask::Mask_Mode = 1, Key_Mask::Mask_MSB_Mode = 1, Key_Mask::Mask_LSB_Mode = 2 }
enum | Type : uint8_t { Type::None = 255, Type::OTS_Hash_Address = 0, Type::LTree_Address = 1, Type::Hash_Tree_Address = 2 }

## Public Member Functions
const secure_vector< uint8_t > & | bytes () const
secure_vector< uint8_t > & | bytes ()
uint32_t | get_chain_address () const
uint32_t | get_hash_address () const
Key_Mask | get_key_mask_mode () const
uint8_t | get_layer_addr () const
uint32_t | get_ltree_address () const
uint32_t | get_ots_address () const
uint64_t | get_tree_addr () const
uint32_t | get_tree_height () const
uint32_t | get_tree_index () const
Type | get_type () const
void | set_chain_address (uint32_t value)
void | set_hash_address (uint32_t value)
void | set_key_mask_mode (Key_Mask value)
void | set_layer_addr ()
void | set_ltree_address (uint32_t value)
void | set_ots_address (uint32_t value)
void | set_tree_addr ()
void | set_tree_height (uint32_t value)
void | set_tree_index (uint32_t value)
void | set_type (Type type)
size_t | size () const
| XMSS_Address ()
| XMSS_Address (Type type)
| XMSS_Address (const secure_vector< uint8_t > &data)
| XMSS_Address (secure_vector< uint8_t > &&data)

## Protected Attributes
secure_vector< uint8_t > | m_data

## Detailed Description

Generic XMSS Address type holding 256 Bits of data. Properties of all three address formats L-Tree-Address, Hash-Tree-Address, OTS-Hash-Address can be called depending on the type currently assigned to the XMSS address using set_type().

Definition at line 23 of file xmss_address.h.

## Member Enumeration Documentation

enum Botan::XMSS_Address::Key_Mask : uint8_t
| strong

The available modes for an XMSS Address:

- Key_Mode: Used to generate the key.
- Mask_Mode: Sets the n-byte bitmask (OTS-Hash-Address)
- Mask_MSB_Mode: Used to generate the b most significant bytes of the 2n-byte bitmask (LTree Address and Hash Tree Address).
- Mask_LSB_Mode: Used to generated the b least significant bytes of the 2n-byte bitmask. (LTree Address and Hash Tree Address).

Enumerator
Key_Mode |
Mask_Mode |
Mask_MSB_Mode |
Mask_LSB_Mode |

Definition at line 47 of file xmss_address.h.

47 : uint8_t
48 {
49 Key_Mode = 0,
50 Mask_Mode = 1,
51 Mask_MSB_Mode = 1,
52 Mask_LSB_Mode = 2
53 };

enum Botan::XMSS_Address::Type : uint8_t
| strong

Distinct types an XMSS_Address can represent. The available types are specified in [1] - 2.5 Hash Function Address Scheme.

Enumerator
None |
OTS_Hash_Address |
LTree_Address |
Hash_Tree_Address |

Definition at line 30 of file xmss_address.h.

30 : uint8_t
31 {
32 None = 255,
33 OTS_Hash_Address = 0,
34 LTree_Address = 1,
35 Hash_Tree_Address = 2
36 };
Botan::PKCS11::Flag::None

## Constructor & Destructor Documentation

Botan::XMSS_Address::XMSS_Address | ( |  | ) |
| inline

Definition at line 344 of file xmss_address.h.

References None, and set_type().

345 : m_data(m_address_size)
346 {
347 set_type(Type::None);
348 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369
Botan::XMSS_Address::Type::None
Botan::XMSS_Address::set_type
void set_type(Type type)
Definition: xmss_address.h:113

Botan::XMSS_Address::XMSS_Address | ( | Type | type | ) |
| inline

Definition at line 350 of file xmss_address.h.

References set_type().

351 : m_data(m_address_size)
352 {
353 set_type(type);
354 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369
type
MechanismType type
Definition: p11_mechanism.cpp:43
Botan::XMSS_Address::set_type
void set_type(Type type)
Definition: xmss_address.h:113

Botan::XMSS_Address::XMSS_Address | ( | const secure_vector< uint8_t > & | data | ) |
| inline

Definition at line 356 of file xmss_address.h.

References BOTAN_ASSERT, and m_data.

356 : m_data(data)
357 {
358 BOTAN_ASSERT(m_data.size() == m_address_size,
359 "XMSS_Address must be of 256 bits size.");
360 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27

Botan::XMSS_Address::XMSS_Address | ( | secure_vector< uint8_t > && | data | ) |
| inline

Definition at line 362 of file xmss_address.h.

References BOTAN_ASSERT, and m_data.

362 : m_data(std::move(data))
363 {
364 BOTAN_ASSERT(m_data.size() == m_address_size,
365 "XMSS_Address must be of 256 bits size.");
366 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27

## Member Function Documentation

const secure_vector<uint8_t>& Botan::XMSS_Address::bytes | ( |  | ) | const
| inline

Definition at line 326 of file xmss_address.h.

References m_data.

Referenced by Botan::XMSS_WOTS_Common_Ops::chain(), Botan::XMSS_WOTS_PublicKey::chain(), Botan::XMSS_WOTS_PrivateKey::operator[](), and Botan::XMSS_Common_Ops::randomize_tree_hash().

327 {
328 return m_data;
329 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369

secure_vector<uint8_t>& Botan::XMSS_Address::bytes | ( |  | ) |
| inline

Definition at line 331 of file xmss_address.h.

References m_data.

332 {
333 return m_data;
334 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369

uint32_t Botan::XMSS_Address::get_chain_address | ( |  | ) | const
| inline

Retrieve the chain address. A call to this method is only valid, if the address type is set to Type::OTS_Hash_Address.

Returns
  chain address.

Definition at line 210 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

211 {
212 BOTAN_ASSERT(get_type() == Type::OTS_Hash_Address,
213 "get_chain_address() requires XMSS_Address::Type::"
214 "OTS_Hash_Address.");
215 return get_lo32(2);
216 }
Botan::XMSS_Address::Type::OTS_Hash_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

uint32_t Botan::XMSS_Address::get_hash_address | ( |  | ) | const
| inline

Retrieves the address of the hash function call within the chain. A call to this method is only valid, if the address type is set to Type::OTS_Hash_Address.

Returns
  address of the hash function call within chain.

Definition at line 271 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

272 {
273 BOTAN_ASSERT(get_type() == Type::OTS_Hash_Address,
274 "get_hash_address() requires XMSS_Address::Type::"
275 "OTS_Hash_Address.");
276 return get_hi32(3);
277 }
Botan::XMSS_Address::Type::OTS_Hash_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

Key_Mask Botan::XMSS_Address::get_key_mask_mode | ( |  | ) | const
| inline

Retrieves the mode the address os currently set to. (See XMSS_Address::Key_Mask for details.)

Returns
  currently active mode

Definition at line 125 of file xmss_address.h.

References m_data.

126 {
127 return Key_Mask(m_data[31]);
128 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369
Botan::XMSS_Address::Key_Mask
Key_Mask
Definition: xmss_address.h:47

uint8_t Botan::XMSS_Address::get_layer_addr | ( |  | ) | const
| inline

Layer Address for XMSS is constantly zero and can not be changed this property is only of relevance to XMSS_MT.

Returns
  Layer address, which is constant 0 for XMSS.

Definition at line 61 of file xmss_address.h.

61 { return 0; }

uint32_t Botan::XMSS_Address::get_ltree_address | ( |  | ) | const
| inline

Retrieves the index of the leaf computed with this LTree. A call to this method is only valid, if the address type is set to Type::LTree_Address.

Returns
  index of the leaf.

Definition at line 181 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and LTree_Address.

182 {
183 BOTAN_ASSERT(get_type() == Type::LTree_Address,
184 "set_ltree_address() requires XMSS_Address::Type::"
185 "LTree_Address.");
186 return get_hi32(2);
187 }
Botan::XMSS_Address::Type::LTree_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

uint32_t Botan::XMSS_Address::get_ots_address | ( |  | ) | const
| inline

Retrieve the index of the OTS key pair within the tree. A call to this method is only valid, if the address type is set to Type::OTS_Hash_Address.

Returns
  index of OTS key pair.

Definition at line 151 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

152 {
153 BOTAN_ASSERT(get_type() == Type::OTS_Hash_Address,
154 "get_ots_address() requires XMSS_Address::Type::"
155 "OTS_Hash_Address.");
156 return get_hi32(2);
157 }
Botan::XMSS_Address::Type::OTS_Hash_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

uint64_t Botan::XMSS_Address::get_tree_addr | ( |  | ) | const
| inline

Tree Address for XMSS is constantly zero and can not be changed this property is only of relevance to XMSS_MT.

Returns
  Tree address, which is constant 0 for XMSS.

Definition at line 79 of file xmss_address.h.

79 { return 0; }

uint32_t Botan::XMSS_Address::get_tree_height | ( |  | ) | const
| inline

Retrieves the height of the tree node to be computed within the tree. A call to this method is only valid, if the address type is set to Type::LTree_Address or Type::Hash_Tree_Address.

Returns
  height of the tree node.

Definition at line 239 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), Hash_Tree_Address, and LTree_Address.

Referenced by Botan::XMSS_Common_Ops::create_l_tree(), and Botan::XMSS_PrivateKey::tree_hash().

240 {
241 BOTAN_ASSERT(get_type() == Type::LTree_Address ||
242 get_type() == Type::Hash_Tree_Address,
243 "get_tree_height() requires XMSS_Address::Type::"
244 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
245 return get_lo32(2);
246 }
Botan::XMSS_Address::Type::LTree_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::Type::Hash_Tree_Address
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

uint32_t Botan::XMSS_Address::get_tree_index | ( |  | ) | const
| inline

Retrieves the index of the tree node at current tree height in the tree. A call to this method is only valid, if the address type is set to Type::LTree_Address or Type::Hash_Tree_Address.

Returns
  index of the tree node at current height.

Definition at line 301 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), Hash_Tree_Address, and LTree_Address.

Referenced by Botan::XMSS_PrivateKey::tree_hash().

302 {
303 BOTAN_ASSERT(get_type() == Type::LTree_Address ||
304 get_type() == Type::Hash_Tree_Address,
305 "get_tree_index() requires XMSS_Address::Type::"
306 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
307 return get_hi32(3);
308 }
Botan::XMSS_Address::Type::LTree_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::Type::Hash_Tree_Address
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

Type Botan::XMSS_Address::get_type | ( |  | ) | const
| inline

retrieves the logical type currently assigned to the XMSS Address instance.

Returns
  Type of the address (OTS_Hash_Address, LTree_Address or Hash_Tree_Address)

Definition at line 98 of file xmss_address.h.

References m_data.

Referenced by get_chain_address(), get_hash_address(), get_ltree_address(), get_ots_address(), get_tree_height(), get_tree_index(), set_chain_address(), set_hash_address(), set_key_mask_mode(), set_ltree_address(), set_ots_address(), set_tree_height(), and set_tree_index().

99 {
100 return static_cast<Type>(m_data[15]);
101 }
Botan::XMSS_Address::Type
Type
Definition: xmss_address.h:30
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369

void Botan::XMSS_Address::set_chain_address | ( | uint32_t | value | ) |
| inline

Set the chain address. A call to this method is only valid, if the address type is set to Type::OTS_Hash_Address.

Returns
  chain address.

Definition at line 224 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

Referenced by Botan::XMSS_WOTS_PrivateKey::generate_public_key(), and Botan::XMSS_WOTS_PrivateKey::sign().

225 {
226 BOTAN_ASSERT(get_type() == Type::OTS_Hash_Address,
227 "set_chain_address() requires XMSS_Address::Type::"
228 "OTS_Hash_Address.");
229 set_lo32(2, value);
230 }
Botan::XMSS_Address::Type::OTS_Hash_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

void Botan::XMSS_Address::set_hash_address | ( | uint32_t | value | ) |
| inline

Sets the address of the hash function call within the chain. A call to this method is only valid, if the address type is set to Type::OTS_Hash_Address.

Parameters

  value | address of the hash function call within chain.

Definition at line 286 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

Referenced by Botan::XMSS_WOTS_Common_Ops::chain(), and Botan::XMSS_WOTS_PublicKey::chain().

287 {
288 BOTAN_ASSERT(get_type() == Type::OTS_Hash_Address,
289 "set_hash_address() requires XMSS_Address::Type::"
290 "OTS_Hash_Address.");
291 set_hi32(3, value);
292 }
Botan::XMSS_Address::Type::OTS_Hash_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

void Botan::XMSS_Address::set_key_mask_mode | ( | Key_Mask | value | ) |
| inline

Changes the mode the address currently used address mode. (XMSS_Address::Key_Mask for details.)

Parameters

  value | Target mode.

Definition at line 136 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), m_data, Mask_LSB_Mode, and OTS_Hash_Address.

Referenced by Botan::XMSS_WOTS_Common_Ops::chain(), Botan::XMSS_WOTS_PublicKey::chain(), and Botan::XMSS_Common_Ops::randomize_tree_hash().

137 {
138 BOTAN_ASSERT(value != Key_Mask::Mask_LSB_Mode ||
139 get_type() != Type::OTS_Hash_Address,
140 "Invalid Key_Mask for current XMSS_Address::Type.");
141 m_data[31] = static_cast<uint8_t>(value);
142 }
Botan::XMSS_Address::Type::OTS_Hash_Address
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::Key_Mask::Mask_LSB_Mode
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

void Botan::XMSS_Address::set_layer_addr | ( |  | ) |
| inline

Layer Address for XMSS is constantly zero and can not be changed this property is only of relevance to XMSS_MT. Calling this method for XMSS will result in an error.

Definition at line 68 of file xmss_address.h.

References BOTAN_ASSERT.

69 {
70 BOTAN_ASSERT(false, "Only available in XMSS_MT.");
71 }
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27

void Botan::XMSS_Address::set_ltree_address | ( | uint32_t | value | ) |
| inline

Sets the index of the leaf computed with this LTree. A call to this method is only valid, if the address type is set to Type::LTree_Address.

Parameters

  value | index of the leaf.

Definition at line 196 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and LTree_Address.

Referenced by Botan::XMSS_PrivateKey::tree_hash().

197 {
198 BOTAN_ASSERT(get_type() == Type::LTree_Address,
199 "set_ltree_address() requires XMSS_Address::Type::"
200 "LTree_Address.");
201 set_hi32(2, value);
202 }
Botan::XMSS_Address::Type::LTree_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

void Botan::XMSS_Address::set_ots_address | ( | uint32_t | value | ) |
| inline

Sets the index of the OTS key pair within the tree. A call to this method is only valid, if the address type is set to Type::OTS_Hash_Address.

Parameters

  value | index of OTS key pair.

Definition at line 166 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

Referenced by Botan::XMSS_PrivateKey::tree_hash().

167 {
168 BOTAN_ASSERT(get_type() == Type::OTS_Hash_Address,
169 "set_ots_address() requires XMSS_Address::Type::"
170 "OTS_Hash_Address.");
171 set_hi32(2, value);
172 }
Botan::XMSS_Address::Type::OTS_Hash_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

void Botan::XMSS_Address::set_tree_addr | ( |  | ) |
| inline

Tree Address for XMSS is constantly zero and can not be changed this property is only of relevance to XMSS_MT. Calling this method for XMSS will result in an error.

Definition at line 86 of file xmss_address.h.

References BOTAN_ASSERT.

87 {
88 BOTAN_ASSERT(false, "Only available in XMSS_MT.");
89 }
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27

void Botan::XMSS_Address::set_tree_height | ( | uint32_t | value | ) |
| inline

Sets the height of the tree node to be computed within the tree. A call to this method is only valid, if the address type is set to Type::LTree_Address or Type::Hash_Tree_Address.

Parameters

  value | height of the tree node.

Definition at line 255 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), Hash_Tree_Address, and LTree_Address.

Referenced by Botan::XMSS_Common_Ops::create_l_tree(), and Botan::XMSS_PrivateKey::tree_hash().

256 {
257 BOTAN_ASSERT(get_type() == Type::LTree_Address ||
258 get_type() == Type::Hash_Tree_Address,
259 "set_tree_height() requires XMSS_Address::Type::"
260 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
261 set_lo32(2, value);
262 }
Botan::XMSS_Address::Type::LTree_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::Type::Hash_Tree_Address
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

void Botan::XMSS_Address::set_tree_index | ( | uint32_t | value | ) |
| inline

Sets the index of the tree node at current tree height in the tree. A call to this method is only valid, if the address type is set to Type::LTree_Address or Type::Hash_Tree_Address.

Parameters

  value | index of the tree node at current height.

Definition at line 317 of file xmss_address.h.

References BOTAN_ASSERT, get_type(), Hash_Tree_Address, and LTree_Address.

Referenced by Botan::XMSS_Common_Ops::create_l_tree(), and Botan::XMSS_PrivateKey::tree_hash().

318 {
319 BOTAN_ASSERT(get_type() == Type::LTree_Address ||
320 get_type() == Type::Hash_Tree_Address,
321 "set_tree_index() requires XMSS_Address::Type::"
322 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
323 set_hi32(3, value);
324 }
Botan::XMSS_Address::Type::LTree_Address
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Address::Type::Hash_Tree_Address
Botan::XMSS_Address::get_type
Type get_type() const
Definition: xmss_address.h:98

void Botan::XMSS_Address::set_type | ( | Type | type | ) |
| inline

Changes the logical type currently assigned to the XMSS Address instance. Please note that changing the type will automatically reset the 128 LSBs of the Address to zero. This affects the key_mask_mode property as well as all properties identified by XMSS_Address::Property.

Parameters

  type | Type that shall be assigned to the address (OTS_Hash_Address, LTree_Address or Hash_Tree_Address)

Definition at line 113 of file xmss_address.h.

References m_data, and type.

Referenced by Botan::XMSS_PrivateKey::tree_hash(), and XMSS_Address().

114 {
115 m_data[15] = static_cast<uint8_t>(type);
116 std::fill(m_data.begin() + 16, m_data.end(), 0);
117 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369
type
MechanismType type
Definition: p11_mechanism.cpp:43

size_t Botan::XMSS_Address::size | ( |  | ) | const
| inline

Returns
  the size of an XMSS_Address

Definition at line 339 of file xmss_address.h.

References m_data.

340 {
341 return m_data.size();
342 }
Botan::XMSS_Address::m_data
secure_vector< uint8_t > m_data
Definition: xmss_address.h:369

## Member Data Documentation

secure_vector<uint8_t> Botan::XMSS_Address::m_data
| protected

Definition at line 369 of file xmss_address.h.

Referenced by bytes(), get_key_mask_mode(), get_type(), set_key_mask_mode(), set_type(), size(), and XMSS_Address().

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

- src/lib/pubkey/xmss/xmss_address.h