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 | List of all members
Botan::XMSS_Hash Class Reference

`#include <xmss_hash.h>`

## Public Member Functions
void | f (secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
void | h (secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
secure_vector< uint8_t > | h_msg (const secure_vector< uint8_t > &randomness, const secure_vector< uint8_t > &root, const secure_vector< uint8_t > &index_bytes, const secure_vector< uint8_t > &data)
secure_vector< uint8_t > | h_msg_final ()
void | h_msg_init (const secure_vector< uint8_t > &randomness, const secure_vector< uint8_t > &root, const secure_vector< uint8_t > &index_bytes)
void | h_msg_update (const secure_vector< uint8_t > &data)
void | h_msg_update (const uint8_t data[], size_t size)
size_t | output_length () const
void | prf (secure_vector< uint8_t > &result, const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
secure_vector< uint8_t > | prf (const secure_vector< uint8_t > &key, const secure_vector< uint8_t > &data)
| XMSS_Hash (const std::string &h_func_name)
| XMSS_Hash (const XMSS_Hash &hash)

## Detailed Description

A collection of pseudorandom hash functions required for XMSS and WOTS computations.

Definition at line 24 of file xmss_hash.h.

## Constructor & Destructor Documentation

Botan::XMSS_Hash::XMSS_Hash | ( | const std::string & | h_func_name | ) |

Definition at line 20 of file xmss_hash.cpp.

References BOTAN_ASSERT.

20 :
21 m_hash_func_name(h_func_name),
22 m_hash(HashFunction::create(h_func_name))
23 {
24 if(!m_hash)
25 throw Lookup_Error("XMSS cannot use hash " + h_func_name +
26 " because it is unavailable");
27
28 m_output_length = m_hash->output_length();
29 BOTAN_ASSERT(m_output_length > 0, "Hash output length of zero is invalid.");
30
31 m_zero_padding.resize(m_output_length - 1);
32 m_msg_hash.reset(m_hash->clone());
33 }
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27
Botan::HashFunction::create
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:93

Botan::XMSS_Hash::XMSS_Hash | ( | const XMSS_Hash & | hash | ) |

Definition at line 15 of file xmss_hash.cpp.

16 : XMSS_Hash(hash.m_hash_func_name)
17 {
18 }
Botan::XMSS_Hash::XMSS_Hash
XMSS_Hash(const std::string &h_func_name)
Definition: xmss_hash.cpp:20
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

## Member Function Documentation

void Botan::XMSS_Hash::f | ( | secure_vector< uint8_t > & | result,
|  | const secure_vector< uint8_t > & | key,
|  | const secure_vector< uint8_t > & | data
| ) |  |
| inline

F is a keyed cryptographic hash function used by the WOTS+ algorithm.

Parameters

  [out] | result | The hash calculated using key and data.
  [in] | key | key of length n bytes.
  [in] | data | string of arbitrary length.

Definition at line 74 of file xmss_hash.h.

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

77 {
78 m_hash->update(m_zero_padding);
79 m_hash->update(m_id_f);
80 m_hash->update(key);
81 m_hash->update(data);
82 m_hash->final(result);
83 }

void Botan::XMSS_Hash::h | ( | secure_vector< uint8_t > & | result,
|  | const secure_vector< uint8_t > & | key,
|  | const secure_vector< uint8_t > & | data
| ) |  |

Cryptographic hash function h accepting n byte keys and 2n byte strings of data.

Parameters

  [out] | result | The hash calculated using key and data.
  [in] | key | key of length n bytes.
  [in] | data | string of 2n bytes length.

Definition at line 36 of file xmss_hash.cpp.

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

39 {
40 m_hash->update(m_zero_padding);
41 m_hash->update(m_id_h);
42 m_hash->update(key);
43 m_hash->update(data);
44 m_hash->final(result);
45 }

secure_vector< uint8_t > Botan::XMSS_Hash::h_msg | ( | const secure_vector< uint8_t > & | randomness,
|  | const secure_vector< uint8_t > & | root,
|  | const secure_vector< uint8_t > & | index_bytes,
|  | const secure_vector< uint8_t > & | data
| ) |  |

Cryptographic hash function h accepting 3n byte keys and data strings of arbitrary length.

Parameters

  randomness | n-byte value.
  root | n-byte root node.
  index_bytes | Index value padded with leading zeros.
  data | string of arbitrary length.

Returns
  hash value of n-bytes length.

Definition at line 75 of file xmss_hash.cpp.

References h_msg_init().

79 {
80 h_msg_init(randomness, root, index_bytes);
81 m_msg_hash->update(data);
82 return m_msg_hash->final();
83 }
Botan::XMSS_Hash::h_msg_init
void h_msg_init(const secure_vector< uint8_t > &randomness, const secure_vector< uint8_t > &root, const secure_vector< uint8_t > &index_bytes)
Definition: xmss_hash.cpp:47

secure_vector< uint8_t > Botan::XMSS_Hash::h_msg_final | ( |  | ) |

Finalizes buffered h_msg computation and retrieves the result.

Returns
  Hash calculated using the prefix set by h_msg_init() and message blocks provided through calls to h_msg_update().

Definition at line 69 of file xmss_hash.cpp.

Referenced by Botan::XMSS_Signature_Operation::sign().

70 {
71 return m_msg_hash->final();
72 }

void Botan::XMSS_Hash::h_msg_init | ( | const secure_vector< uint8_t > & | randomness,
|  | const secure_vector< uint8_t > & | root,
|  | const secure_vector< uint8_t > & | index_bytes
| ) |  |

Initializes buffered h_msg computation with prefix data.

Parameters

  randomness | random n-byte value.
  root | n-byte root node.
  index_bytes | Index value padded with leading zeros.

Definition at line 47 of file xmss_hash.cpp.

Referenced by h_msg().

50 {
51 m_msg_hash->clear();
52 m_msg_hash->update(m_zero_padding);
53 m_msg_hash->update(m_id_hmsg);
54 m_msg_hash->update(randomness);
55 m_msg_hash->update(root);
56 m_msg_hash->update(index_bytes);
57 }

void Botan::XMSS_Hash::h_msg_update | ( | const secure_vector< uint8_t > & | data | ) |

Adds a message block to buffered h_msg computation.

Parameters

  data | A message block

Definition at line 59 of file xmss_hash.cpp.

Referenced by Botan::XMSS_Signature_Operation::update().

60 {
61 m_msg_hash->update(data);
62 }

void Botan::XMSS_Hash::h_msg_update | ( | const uint8_t | data[],
|  | size_t | size
| ) |  |

Adds a message block to buffered h_msg computation.

Parameters

  data | A message block
  size | Length of the message block in bytes.

Definition at line 64 of file xmss_hash.cpp.

65 {
66 m_msg_hash->update(data, size);
67 }

size_t Botan::XMSS_Hash::output_length | ( |  | ) | const
| inline

Definition at line 147 of file xmss_hash.h.

147 { return m_output_length; }

void Botan::XMSS_Hash::prf | ( | secure_vector< uint8_t > & | result,
|  | const secure_vector< uint8_t > & | key,
|  | const secure_vector< uint8_t > & | data
| ) |  |
| inline

Pseudoranom function creating a hash out of a key and data using a cryptographic hash function.

Parameters

  [out] | result | The hash calculated using key and data.
  [in] | key | An n-byte key value.
  [in] | data | A 32-byte XMSS_Address data value

Definition at line 38 of file xmss_hash.h.

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

41 {
42 m_hash->update(m_zero_padding);
43 m_hash->update(m_id_prf);
44 m_hash->update(key);
45 m_hash->update(data);
46 m_hash->final(result);
47 }

secure_vector<uint8_t> Botan::XMSS_Hash::prf | ( | const secure_vector< uint8_t > & | key,
|  | const secure_vector< uint8_t > & | data
| ) |  |
| inline

Pseudoranom function creating a hash out of a key and data using a cryptographic hash function.

Parameters

  [in] | key | An n-byte key value.
  [in] | data | A 32-byte XMSS_Address data value

Returns
  result The hash calculated using key and data.

Definition at line 57 of file xmss_hash.h.

59 {
60 m_hash->update(m_zero_padding);
61 m_hash->update(m_id_prf);
62 m_hash->update(key);
63 m_hash->update(data);
64 return m_hash->final();
65 }

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

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