Botan 3.14.1
Crypto and TLS for C&
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

std::span< const uint8_t > bytes () const
uint32_t get_chain_address () const
uint32_t get_hash_address () const
Key_Mask get_key_mask_mode () const
uint32_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
XMSS_Address & operator= (const XMSS_Address &other)=default
XMSS_Address & operator= (XMSS_Address &&other)=default
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 (uint32_t value)
void set_ltree_address (uint32_t value)
void set_ots_address (uint32_t value)
void set_tree_addr (uint64_t value)
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 (const XMSS_Address &other)=default
 XMSS_Address (Type type)
 XMSS_Address (XMSS_Address &&other)=default
 ~XMSS_Address ()=default

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

42: uint8_t { Key_Mode = 0, Mask_Mode = 1, Mask_MSB_Mode = 1, Mask_LSB_Mode = 2 };

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

31: uint8_t { None = 255, OTS_Hash_Address = 0, LTree_Address = 1, Hash_Tree_Address = 2 };

Constructor & Destructor Documentation

◆ XMSS_Address() [1/4]

Botan::XMSS_Address::XMSS_Address ( )
inline

Definition at line 301 of file xmss_address.h.

301: m_data{} { set_type(Type::None); }
void set_type(Type type)

References None, and set_type().

Referenced by operator=(), operator=(), XMSS_Address(), and XMSS_Address().

◆ ~XMSS_Address()

Botan::XMSS_Address::~XMSS_Address ( )
default

◆ XMSS_Address() [2/4]

Botan::XMSS_Address::XMSS_Address ( const XMSS_Address & other)
default

References XMSS_Address().

◆ XMSS_Address() [3/4]

Botan::XMSS_Address::XMSS_Address ( XMSS_Address && other)
default

References XMSS_Address().

◆ XMSS_Address() [4/4]

Botan::XMSS_Address::XMSS_Address ( Type type)
inlineexplicit

Definition at line 310 of file xmss_address.h.

310: m_data() { set_type(type); }

References set_type().

Member Function Documentation

◆ bytes()

std::span< const uint8_t > Botan::XMSS_Address::bytes ( ) const
inline

Definition at line 294 of file xmss_address.h.

294{ return std::span{m_data}; }

Referenced by Botan::XMSS_Common_Ops::randomize_tree_hash(), and Botan::XMSS_WOTS_PrivateKey::XMSS_WOTS_PrivateKey().

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

192 {
194 "get_chain_address() requires XMSS_Address::Type::"
195 "OTS_Hash_Address.");
196 return get_lo32(2);
197 }
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:69
Type get_type() const

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

245 {
247 "get_hash_address() requires XMSS_Address::Type::"
248 "OTS_Hash_Address.");
249 return get_hi32(3);
250 }

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

116{ return Key_Mask(m_data[31]); }

◆ get_layer_addr()

uint32_t Botan::XMSS_Address::get_layer_addr ( ) const
inline

retrieves the Layer Address. A call to this method is only required by XMSS_MT. The Layer Address is constantly zero for XMSS. For XMSS_MT it describes the height of the tree in the multi-tree structure.

Returns
Layer address.

Definition at line 51 of file xmss_address.h.

51{ return get_hi32(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 165 of file xmss_address.h.

165 {
167 "set_ltree_address() requires XMSS_Address::Type::"
168 "LTree_Address.");
169 return get_hi32(2);
170 }

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

137 {
139 "get_ots_address() requires XMSS_Address::Type::"
140 "OTS_Hash_Address.");
141 return get_hi32(2);
142 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

◆ get_tree_addr()

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

retrieves the Tree Address. A call to this method is only required by XMSS_MT. The Tree Address is constantly zero for XMSS. For XMSS_MT it describes the position of the tree within its layer.

Returns
Tree address.

Definition at line 67 of file xmss_address.h.

67 {
68 const uint64_t high = static_cast<uint64_t>(get_lo32(0));
69 const uint64_t low = static_cast<uint64_t>(get_hi32(1));
70 return (high << 32) | low;
71 }

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

217 {
219 "get_tree_height() requires XMSS_Address::Type::"
220 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
221 return get_lo32(2);
222 }

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

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

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

273 {
275 "get_tree_index() requires XMSS_Address::Type::"
276 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
277 return get_hi32(3);
278 }

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

Referenced by Botan::XMSS_Common_Ops::root_from_signature(), and Botan::XMSS_Tree_Builder::tree_hash().

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

91{ return static_cast<Type>(m_data[15]); }

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

◆ operator=() [1/2]

XMSS_Address & Botan::XMSS_Address::operator= ( const XMSS_Address & other)
default

References XMSS_Address().

◆ operator=() [2/2]

XMSS_Address & Botan::XMSS_Address::operator= ( XMSS_Address && other)
default

References XMSS_Address().

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

203 {
205 "set_chain_address() requires XMSS_Address::Type::"
206 "OTS_Hash_Address.");
207 set_lo32(2, value);
208 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

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

259 {
261 "set_hash_address() requires XMSS_Address::Type::"
262 "OTS_Hash_Address.");
263 set_hi32(3, value);
264 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

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

124 {
126 "Invalid Key_Mask for current XMSS_Address::Type.");
127 m_data[31] = static_cast<uint8_t>(value);
128 }

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

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

◆ set_layer_addr()

void Botan::XMSS_Address::set_layer_addr ( uint32_t value)
inline

sets the Layer Address. A call to this method is only required by XMSS_MT. The Layer Address is constantly zero for XMSS. For XMSS_MT it describes the height of the tree in the multi-tree structure.

Definition at line 58 of file xmss_address.h.

58{ set_hi32(0, value); }

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

179 {
181 "set_ltree_address() requires XMSS_Address::Type::"
182 "LTree_Address.");
183 set_hi32(2, value);
184 }

References BOTAN_ASSERT, get_type(), and LTree_Address.

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

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

151 {
153 "set_ots_address() requires XMSS_Address::Type::"
154 "OTS_Hash_Address.");
155 set_hi32(2, value);
156 }

References BOTAN_ASSERT, get_type(), and OTS_Hash_Address.

Referenced by Botan::XMSS_Common_Ops::root_from_signature(), and Botan::XMSS_Signature_Operation::sign().

◆ set_tree_addr()

void Botan::XMSS_Address::set_tree_addr ( uint64_t value)
inline

sets the Tree Address. A call to this method is only required by XMSS_MT. The Tree Address is constantly zero for XMSS. For XMSS_MT it describes the position of the tree within its layer.

Definition at line 79 of file xmss_address.h.

79 {
80 set_lo32(0, static_cast<uint32_t>(value >> 32));
81 set_hi32(1, static_cast<uint32_t>(value));
82 }

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

231 {
233 "set_tree_height() requires XMSS_Address::Type::"
234 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
235 set_lo32(2, value);
236 }

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

Referenced by Botan::XMSS_Common_Ops::root_from_signature(), and Botan::XMSS_Tree_Builder::tree_hash().

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

287 {
289 "set_tree_index() requires XMSS_Address::Type::"
290 "LTree_Address or XMSS_Address::Type::Hash_Tree_Address.");
291 set_hi32(3, value);
292 }

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

Referenced by Botan::XMSS_Common_Ops::root_from_signature(), and Botan::XMSS_Tree_Builder::tree_hash().

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

103 {
104 m_data[15] = static_cast<uint8_t>(type);
105 for(size_t i = 16; i != m_data.size(); ++i) {
106 m_data[i] = 0;
107 }
108 }

Referenced by Botan::XMSS_Common_Ops::root_from_signature(), Botan::XMSS_Signature_Operation::sign(), Botan::XMSS_Tree_Builder::tree_hash(), XMSS_Address(), and XMSS_Address().

◆ size()

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

Definition at line 299 of file xmss_address.h.

299{ return m_data.size(); }

Referenced by Botan::XMSS_WOTS_PrivateKey::XMSS_WOTS_PrivateKey().


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