Botan 2.19.5 Crypto and TLS for C&

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

`#include <xmss_common_ops.h>`

## Static Public Member Functions
static void | create_l_tree (secure_vector< uint8_t > &result, wots_keysig_t pk, XMSS_Address &adrs, const secure_vector< uint8_t > &seed, XMSS_Hash &hash, const XMSS_Parameters &params)
static void | randomize_tree_hash (secure_vector< uint8_t > &result, const secure_vector< uint8_t > &left, const secure_vector< uint8_t > &right, XMSS_Address &adrs, const secure_vector< uint8_t > &seed, XMSS_Hash &hash, const XMSS_Parameters &params)

## Detailed Description

Operations shared by XMSS signature generation and verification operations.

Definition at line 26 of file xmss_common_ops.h.

## Member Function Documentation

## ◆ create_l_tree()

void Botan::XMSS_Common_Ops::create_l_tree | ( | secure_vector< uint8_t > & | result,
|  | wots_keysig_t | pk,
|  | XMSS_Address & | adrs,
|  | const secure_vector< uint8_t > & | seed,
|  | XMSS_Hash & | hash,
|  | const XMSS_Parameters & | params
| ) |  |
| static

Algorithm 8: "ltree" Create an L-tree used to compute the leaves of the binary hash tree. Takes a WOTS+ public key and compresses it to a single n-byte value.

This overload is used in multithreaded scenarios, where it is required to provide seperate instances of XMSS_Hash to each thread.

Parameters

  [out] | result | Public key compressed to a single n-byte value pk[0].
  [in] | pk | Winternitz One Time Signatures+ public key.
  [in] | adrs | Address encoding the address of the L-Tree
  [in] | seed | The seed generated during the public key generation.
  [in] | hash | Instance of XMSS_Hash, that may only be used by the thead executing create_l_tree.
  [in] | params | algorithm parameters

Definition at line 47 of file xmss_common_ops.cpp.

53 {
54 size_t l = params.len();
55 adrs.set_tree_height(0);
56
57 while(l > 1)
58 {
59 for(size_t i = 0; i < l >> 1; i++)
60 {
61 adrs.set_tree_index(static_cast<uint32_t>(i));
62 randomize_tree_hash(pk[i], pk[2 * i], pk[2 * i + 1], adrs, seed, hash, params);
63 }
64 if(l & 0x01)
65 {
66 pk[l >> 1] = pk[l - 1];
67 }
68 l = (l >> 1) + (l & 0x01);
69 adrs.set_tree_height(adrs.get_tree_height() + 1);
70 }
71 result = pk[0];
72 }
Botan::XMSS_Common_Ops::randomize_tree_hash
static void randomize_tree_hash(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &left, const secure_vector< uint8_t > &right, XMSS_Address &adrs, const secure_vector< uint8_t > &seed, XMSS_Hash &hash, const XMSS_Parameters &params)
Definition: xmss_common_ops.cpp:14
hash
MechanismType hash
Definition: p11_mechanism.cpp:64

References Botan::XMSS_Address::get_tree_height(), hash, Botan::XMSS_Parameters::len(), randomize_tree_hash(), Botan::XMSS_Address::set_tree_height(), and Botan::XMSS_Address::set_tree_index().

## ◆ randomize_tree_hash()

void Botan::XMSS_Common_Ops::randomize_tree_hash | ( | secure_vector< uint8_t > & | result,
|  | const secure_vector< uint8_t > & | left,
|  | const secure_vector< uint8_t > & | right,
|  | XMSS_Address & | adrs,
|  | const secure_vector< uint8_t > & | seed,
|  | XMSS_Hash & | hash,
|  | const XMSS_Parameters & | params
| ) |  |
| static

Algorithm 7: "RAND_HASH"

Generates a randomized hash.

This overload is used in multithreaded scenarios, where it is required to provide seperate instances of XMSS_Hash to each thread.

Parameters

  [out] | result | The resulting randomized hash.
  [in] | left | Left half of the hash function input.
  [in] | right | Right half of the hash function input.
  [in] | adrs | Adress of the hash function call.
  [in] | seed | The seed for G.
  [in] | hash | Instance of XMSS_Hash, that may only by the thead executing generate_public_key.
  [in] | params | algorithm parameters

Definition at line 14 of file xmss_common_ops.cpp.

21 {
22 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode);
23 secure_vector<uint8_t> key { hash.prf(seed, adrs.bytes()) };
24
25 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_MSB_Mode);
26 secure_vector<uint8_t> bitmask_l { hash.prf(seed, adrs.bytes()) };
27
28 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_LSB_Mode);
29 secure_vector<uint8_t> bitmask_r { hash.prf(seed, adrs.bytes()) };
30
31 BOTAN_ASSERT(bitmask_l.size() == left.size() &&
32 bitmask_r.size() == right.size(),
33 "Bitmask size doesn't match node size.");
34
35 secure_vector<uint8_t> concat_xor(params.element_size() * 2);
36 for(size_t i = 0; i < left.size(); i++)
37 {
38 concat_xor[i] = left[i] ^ bitmask_l[i];
39 concat_xor[i + left.size()] = right[i] ^ bitmask_r[i];
40 }
41
42 hash.h(result, key, concat_xor);
43 }
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:55
Botan::XMSS_Address::Key_Mask::Mask_MSB_Mode
@ Mask_MSB_Mode
Botan::XMSS_Address::Key_Mask::Key_Mode
@ Key_Mode
Botan::XMSS_Address::Key_Mask::Mask_LSB_Mode
@ Mask_LSB_Mode

References BOTAN_ASSERT, Botan::XMSS_Address::bytes(), Botan::XMSS_Parameters::element_size(), hash, Botan::XMSS_Address::Key_Mode, Botan::XMSS_Address::Mask_LSB_Mode, Botan::XMSS_Address::Mask_MSB_Mode, and Botan::XMSS_Address::set_key_mask_mode().

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

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

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