Botan 3.5.0
Crypto and TLS for C&
Botan::PseudorandomKeyGeneration Class Reference

Helper class used to derive secret values based in the pseudorandom key generation described in RFC 8554 Appendix A. More...

#include <hss_lms_utils.h>

Public Member Functions

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T gen (HashFunction &hash, std::span< const uint8_t > seed) const
 Create a hash value using the preconfigured prefix and a seed.
 
void gen (std::span< uint8_t > out, HashFunction &hash, std::span< const uint8_t > seed) const
 Create a hash value using the preconfigured prefix and a seed.
 
 PseudorandomKeyGeneration (std::span< const uint8_t > identifier)
 Create a PseudorandomKeyGeneration instance for a fixed identifier.
 
void set_i (uint16_t i)
 Specify the value for the u16str(i) hash input field.
 
void set_j (uint8_t j)
 Specify the value for the u8str(j) hash input field.
 
void set_q (uint32_t q)
 Specify the value for the u32str(q) hash input field.
 

Detailed Description

Helper class used to derive secret values based in the pseudorandom key generation described in RFC 8554 Appendix A.

This generation computes the following:

Result = Hash( identifier || u32str(q) || u16str(i) || u8str(j) || SEED )

This Key Generation procedure is also used for the seed derivation function of SECRET_METHOD 2 defined in https://github.com/cisco/hash-sigs,

Definition at line 28 of file hss_lms_utils.h.

Constructor & Destructor Documentation

◆ PseudorandomKeyGeneration()

Botan::PseudorandomKeyGeneration::PseudorandomKeyGeneration ( std::span< const uint8_t > identifier)

Create a PseudorandomKeyGeneration instance for a fixed identifier.

Definition at line 18 of file hss_lms_utils.cpp.

18 :
19 m_input_buffer(identifier.size() + 7),
20 m_q(std::span(m_input_buffer).last<7>().first<4>()),
21 m_i(std::span(m_input_buffer).last<3>().first<2>()),
22 m_j(std::span(m_input_buffer).last<1>()) {
23 copy_mem(std::span(m_input_buffer).first(identifier.size()), identifier);
24}
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:146

References Botan::copy_mem().

Member Function Documentation

◆ gen() [1/2]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::PseudorandomKeyGeneration::gen ( HashFunction & hash,
std::span< const uint8_t > seed ) const
inline

Create a hash value using the preconfigured prefix and a seed.

Definition at line 54 of file hss_lms_utils.h.

54 {
55 T output(hash.output_length());
56 gen(output, hash, seed);
57 return output;
58 }
T gen(HashFunction &hash, std::span< const uint8_t > seed) const
Create a hash value using the preconfigured prefix and a seed.
FE_25519 T
Definition ge.cpp:34

References gen(), Botan::Buffered_Computation::output_length(), and T.

Referenced by gen(), and Botan::LMOTS_Private_Key::LMOTS_Private_Key().

◆ gen() [2/2]

void Botan::PseudorandomKeyGeneration::gen ( std::span< uint8_t > out,
HashFunction & hash,
std::span< const uint8_t > seed ) const

Create a hash value using the preconfigured prefix and a seed.

Definition at line 26 of file hss_lms_utils.cpp.

26 {
27 hash.update(m_input_buffer);
28 hash.update(seed);
29 hash.final(out);
30}

References Botan::Buffered_Computation::final(), and Botan::Buffered_Computation::update().

◆ set_i()

void Botan::PseudorandomKeyGeneration::set_i ( uint16_t i)
inline

Specify the value for the u16str(i) hash input field.

Definition at line 43 of file hss_lms_utils.h.

43{ store_be(m_i, i); }
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:707

References Botan::store_be().

Referenced by Botan::LMOTS_Private_Key::LMOTS_Private_Key().

◆ set_j()

void Botan::PseudorandomKeyGeneration::set_j ( uint8_t j)
inline

Specify the value for the u8str(j) hash input field.

Definition at line 48 of file hss_lms_utils.h.

48{ store_be(m_j, j); }

References Botan::store_be().

Referenced by Botan::LMOTS_Private_Key::LMOTS_Private_Key().

◆ set_q()

void Botan::PseudorandomKeyGeneration::set_q ( uint32_t q)
inline

Specify the value for the u32str(q) hash input field.

Definition at line 38 of file hss_lms_utils.h.

38{ store_be(m_q, q); }

References Botan::store_be().

Referenced by Botan::LMOTS_Private_Key::LMOTS_Private_Key().


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