Botan 3.0.0-alpha0
Crypto and TLS for C&
Public Types | Public Member Functions | Protected Attributes | List of all members
Botan::XMSS_Address Class Referencefinal

#include <xmss_address.h>

Public Types

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

Public Member Functions

secure_vector< uint8_t > & bytes ()
 
const secure_vector< uint8_t > & bytes () const
 
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 (secure_vector< uint8_t > data)
 
 XMSS_Address (Type type)
 

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 22 of file xmss_address.h.

Member Enumeration Documentation

◆ Key_Mask

enum class 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 46 of file xmss_address.h.

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

◆ Type

enum class 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 29 of file xmss_address.h.

30 {
31 None = 255,
32 OTS_Hash_Address = 0,
33 LTree_Address = 1,
34 Hash_Tree_Address = 2
35 };

Constructor & Destructor Documentation

◆ XMSS_Address() [1/3]

Botan::XMSS_Address::XMSS_Address ( )
inline

Definition at line 341 of file xmss_address.h.

342 : m_data(m_address_size)
343 {
345 }
secure_vector< uint8_t > m_data
Definition: xmss_address.h:360
void set_type(Type type)
Definition: xmss_address.h:112

References None, and set_type().

◆ XMSS_Address() [2/3]

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

Definition at line 347 of file xmss_address.h.

348 : m_data(m_address_size)
349 {
350 set_type(type);
351 }
MechanismType type

References set_type(), and type.

◆ XMSS_Address() [3/3]

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

Definition at line 353 of file xmss_address.h.

353 : m_data(std::move(data))
354 {
355 BOTAN_ASSERT(m_data.size() == m_address_size,
356 "XMSS_Address must be of 256 bits size.");
357 }
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:54

References BOTAN_ASSERT, and m_data.

Member Function Documentation

◆ bytes() [1/2]

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

Definition at line 328 of file xmss_address.h.

329 {
330 return m_data;
331 }

References m_data.

◆ bytes() [2/2]

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

◆ get_chain_address()

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 209 of file xmss_address.h.

210 {
212 "get_chain_address() requires XMSS_Address::Type::"
213 "OTS_Hash_Address.");
214 return get_lo32(2);
215 }
Type get_type() const
Definition: xmss_address.h:97

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

◆ get_hash_address()

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 268 of file xmss_address.h.

269 {
271 "get_hash_address() requires XMSS_Address::Type::"
272 "OTS_Hash_Address.");
273 return get_hi32(3);
274 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

◆ get_key_mask_mode()

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

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

Returns
currently active mode

Definition at line 124 of file xmss_address.h.

125 {
126 return Key_Mask(m_data[31]);
127 }

References m_data.

◆ get_layer_addr()

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 60 of file xmss_address.h.

60{ return 0; }

◆ get_ltree_address()

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 180 of file xmss_address.h.

181 {
183 "set_ltree_address() requires XMSS_Address::Type::"
184 "LTree_Address.");
185 return get_hi32(2);
186 }

References BOTAN_ASSERT, get_type(), and LTree_Address.

◆ get_ots_address()

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 150 of file xmss_address.h.

151 {
153 "get_ots_address() requires XMSS_Address::Type::"
154 "OTS_Hash_Address.");
155 return get_hi32(2);
156 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

◆ get_tree_addr()

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 78 of file xmss_address.h.

78{ return 0; }

◆ get_tree_height()

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 236 of file xmss_address.h.

237 {
240 "get_tree_height() requires XMSS_Address::Type::"
241 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
242 return get_lo32(2);
243 }

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

Referenced by Botan::XMSS_Common_Ops::create_l_tree().

◆ get_tree_index()

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 298 of file xmss_address.h.

299 {
302 "get_tree_index() requires XMSS_Address::Type::"
303 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
304 return get_hi32(3);
305 }

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

◆ get_type()

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 97 of file xmss_address.h.

98 {
99 return static_cast<Type>(m_data[15]);
100 }

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().

◆ set_chain_address()

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.

Definition at line 221 of file xmss_address.h.

222 {
224 "set_chain_address() requires XMSS_Address::Type::"
225 "OTS_Hash_Address.");
226 set_lo32(2, value);
227 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

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

◆ set_hash_address()

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
valueaddress of the hash function call within chain.

Definition at line 283 of file xmss_address.h.

284 {
286 "set_hash_address() requires XMSS_Address::Type::"
287 "OTS_Hash_Address.");
288 set_hi32(3, value);
289 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

Referenced by Botan::XMSS_WOTS_PublicKey::chain().

◆ set_key_mask_mode()

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
valueTarget mode.

Definition at line 135 of file xmss_address.h.

136 {
139 "Invalid Key_Mask for current XMSS_Address::Type.");
140 m_data[31] = static_cast<uint8_t>(value);
141 }

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

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

◆ set_layer_addr()

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 67 of file xmss_address.h.

68 {
69 BOTAN_ASSERT(false, "Only available in XMSS_MT.");
70 }

References BOTAN_ASSERT.

◆ set_ltree_address()

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
valueindex of the leaf.

Definition at line 195 of file xmss_address.h.

196 {
198 "set_ltree_address() requires XMSS_Address::Type::"
199 "LTree_Address.");
200 set_hi32(2, value);
201 }

References BOTAN_ASSERT, get_type(), and LTree_Address.

◆ set_ots_address()

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
valueindex of OTS key pair.

Definition at line 165 of file xmss_address.h.

166 {
168 "set_ots_address() requires XMSS_Address::Type::"
169 "OTS_Hash_Address.");
170 set_hi32(2, value);
171 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

◆ set_tree_addr()

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 85 of file xmss_address.h.

86 {
87 BOTAN_ASSERT(false, "Only available in XMSS_MT.");
88 }

References BOTAN_ASSERT.

◆ set_tree_height()

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
valueheight of the tree node.

Definition at line 252 of file xmss_address.h.

253 {
256 "set_tree_height() requires XMSS_Address::Type::"
257 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
258 set_lo32(2, value);
259 }

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

Referenced by Botan::XMSS_Common_Ops::create_l_tree().

◆ set_tree_index()

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
valueindex of the tree node at current height.

Definition at line 314 of file xmss_address.h.

315 {
318 "set_tree_index() requires XMSS_Address::Type::"
319 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
320 set_hi32(3, value);
321 }

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

Referenced by Botan::XMSS_Common_Ops::create_l_tree().

◆ set_type()

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
typeType that shall be assigned to the address (OTS_Hash_Address, LTree_Address or Hash_Tree_Address)

Definition at line 112 of file xmss_address.h.

113 {
114 m_data[15] = static_cast<uint8_t>(type);
115 std::fill(m_data.begin() + 16, m_data.end(), static_cast<uint8_t>(0));
116 }

References m_data, and type.

Referenced by XMSS_Address().

◆ size()

size_t Botan::XMSS_Address::size ( ) const
inline
Returns
the size of an XMSS_Address

Definition at line 336 of file xmss_address.h.

337 {
338 return m_data.size();
339 }

References m_data.

Member Data Documentation

◆ m_data

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

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