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 | Protected Member Functions | Protected Attributes | List of all members
Botan::XMSS_Signature_Operation Class Reference

`#include <xmss_signature_operation.h>`

Inheritance diagram for Botan::XMSS_Signature_Operation:

## Public Member Functions
secure_vector< uint8_t > | sign (RandomNumberGenerator &) override
void | update (const uint8_t msg[], size_t msg_len) override
| XMSS_Signature_Operation (const XMSS_PrivateKey &private_key)
virtual | ~XMSS_Signature_Operation ()=default

## Protected Member Functions
void | create_l_tree (secure_vector< uint8_t > &result, wots_keysig_t pk, XMSS_Address &adrs, const secure_vector< uint8_t > &seed)
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)

## Protected Attributes
XMSS_Hash | m_hash
XMSS_Parameters | m_xmss_params

## Detailed Description

Signature generation operation for Extended Hash-Based Signatures (XMSS) as defined in:

[1] XMSS: Extended Hash-Based Signatures, draft-itrf-cfrg-xmss-hash-based-signatures-06 Release: July 2016. https://datatracker.ietf.org/doc/ draft-irtf-cfrg-xmss-hash-based-signatures/?include_text=1

Definition at line 36 of file xmss_signature_operation.h.

## Constructor & Destructor Documentation

Botan::XMSS_Signature_Operation::XMSS_Signature_Operation | ( | const XMSS_PrivateKey & | private_key | ) |

Definition at line 21 of file xmss_signature_operation.cpp.

23 : XMSS_Common_Ops(private_key.xmss_oid()),
24 m_priv_key(private_key),
25 m_randomness(0),
26 m_leaf_idx(0),
27 m_is_initialized(false)
28 {}
Botan::XMSS_Common_Ops::XMSS_Common_Ops
XMSS_Common_Ops(XMSS_Parameters::xmss_algorithm_t oid)
Definition: xmss_common_ops.h:28

virtual Botan::XMSS_Signature_Operation::~XMSS_Signature_Operation | ( |  | ) |
| virtual default

## Member Function Documentation

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
| ) |  |
| protected inherited

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.

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.

Definition at line 45 of file xmss_common_ops.cpp.

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

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

49 {
50 size_t l = m_xmss_params.len();
51 adrs.set_tree_height(0);
52
53 while(l > 1)
54 {
55 for(size_t i = 0; i < l >> 1; i++)
56 {
57 adrs.set_tree_index(i);
58 randomize_tree_hash(pk[i], pk[2 * i], pk[2 * i + 1], adrs, seed);
59 }
60 if(l & 0x01)
61 {
62 pk[l >> 1] = pk[l - 1];
63 }
64 l = (l >> 1) + (l & 0x01);
65 adrs.set_tree_height(adrs.get_tree_height() + 1);
66 }
67 result = pk[0];
68 }
Botan::XMSS_Common_Ops::m_xmss_params
XMSS_Parameters m_xmss_params
Definition: xmss_common_ops.h:68
Botan::XMSS_Common_Ops::randomize_tree_hash
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)
Definition: xmss_common_ops.cpp:14
Botan::XMSS_Parameters::len
size_t len() const
Definition: xmss_parameters.h:87

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
| ) |  |
| protected inherited

Algorithm 7: "RAND_HASH"

Generates a randomized hash.

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.

Definition at line 14 of file xmss_common_ops.cpp.

References BOTAN_ASSERT, Botan::XMSS_Address::bytes(), Botan::XMSS_Parameters::element_size(), Botan::XMSS_Hash::h(), Botan::XMSS_Address::Key_Mode, Botan::XMSS_Common_Ops::m_hash, Botan::XMSS_Common_Ops::m_xmss_params, Botan::XMSS_Address::Mask_LSB_Mode, Botan::XMSS_Address::Mask_MSB_Mode, Botan::XMSS_Hash::prf(), and Botan::XMSS_Address::set_key_mask_mode().

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

19 {
20 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode);
21 secure_vector<uint8_t> key { m_hash.prf(seed, adrs.bytes()) };
22
23 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_MSB_Mode);
24 secure_vector<uint8_t> bitmask_l { m_hash.prf(seed, adrs.bytes()) };
25
26 adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_LSB_Mode);
27 secure_vector<uint8_t> bitmask_r { m_hash.prf(seed, adrs.bytes()) };
28
29 BOTAN_ASSERT(bitmask_l.size() == left.size() &&
30 bitmask_r.size() == right.size(),
31 "Bitmask size doesn't match node size.");
32
33 secure_vector<uint8_t> concat_xor(m_xmss_params.element_size() * 2);
34 for(size_t i = 0; i < left.size(); i++)
35 {
36 concat_xor[i] = left[i] ^ bitmask_l[i];
37 concat_xor[i + left.size()] = right[i] ^ bitmask_r[i];
38 }
39
40 m_hash.h(result, key, concat_xor);
41 }
Botan::XMSS_Address::Key_Mask::Mask_MSB_Mode
Botan::XMSS_Parameters::element_size
size_t element_size() const
Definition: xmss_parameters.h:72
Botan::XMSS_Hash::h
void h(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
Definition: xmss_hash.cpp:36
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::XMSS_Hash::prf
void prf(secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
Definition: xmss_hash.h:38
Botan::XMSS_Common_Ops::m_xmss_params
XMSS_Parameters m_xmss_params
Definition: xmss_common_ops.h:68
Botan::XMSS_Common_Ops::m_hash
XMSS_Hash m_hash
Definition: xmss_common_ops.h:69
Botan::XMSS_Address::Key_Mask::Mask_LSB_Mode
Botan::XMSS_Address::Key_Mask::Key_Mode

secure_vector< uint8_t > Botan::XMSS_Signature_Operation::sign | ( | RandomNumberGenerator & |  | ) |
| override virtual

Creates an XMSS signature for the message provided through call to update().

Returns
  serialized XMSS signature.

Implements Botan::PK_Ops::Signature.

Definition at line 79 of file xmss_signature_operation.cpp.

References Botan::XMSS_Hash::h_msg_final(), and Botan::XMSS_Common_Ops::m_hash.

80 {
81 initialize();
82 secure_vector<uint8_t> signature(sign(m_hash.h_msg_final(),
83 m_priv_key).bytes());
84 m_is_initialized = false;
85 return signature;
86 }
Botan::XMSS_Hash::h_msg_final
secure_vector< uint8_t > h_msg_final()
Definition: xmss_hash.cpp:69
Botan::XMSS_Common_Ops::m_hash
XMSS_Hash m_hash
Definition: xmss_common_ops.h:69
Botan::XMSS_Signature_Operation::sign
secure_vector< uint8_t > sign(RandomNumberGenerator &) override
Definition: xmss_signature_operation.cpp:79

void Botan::XMSS_Signature_Operation::update | ( | const uint8_t | msg[],
|  | size_t | msg_len
| ) |  |
| override virtual

Implements Botan::PK_Ops::Signature.

Definition at line 71 of file xmss_signature_operation.cpp.

References Botan::XMSS_Hash::h_msg_update(), and Botan::XMSS_Common_Ops::m_hash.

72 {
73 initialize();
74 m_hash.h_msg_update(msg, msg_len);
75 }
Botan::XMSS_Hash::h_msg_update
void h_msg_update(const secure_vector< uint8_t > &data)
Definition: xmss_hash.cpp:59
Botan::XMSS_Common_Ops::m_hash
XMSS_Hash m_hash
Definition: xmss_common_ops.h:69

## Member Data Documentation

XMSS_Hash Botan::XMSS_Common_Ops::m_hash
| protected inherited

Definition at line 69 of file xmss_common_ops.h.

Referenced by Botan::XMSS_Common_Ops::randomize_tree_hash(), sign(), and update().

XMSS_Parameters Botan::XMSS_Common_Ops::m_xmss_params
| protected inherited

Definition at line 68 of file xmss_common_ops.h.

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

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

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