Botan 3.13.0
Crypto and TLS for C&
Botan::PseudorandomKeyGeneration Class Referencefinal

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>>
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.
PseudorandomKeyGenerationoperator= (const PseudorandomKeyGeneration &)=delete
PseudorandomKeyGenerationoperator= (PseudorandomKeyGeneration &&)=delete
 PseudorandomKeyGeneration (const PseudorandomKeyGeneration &)=delete
 PseudorandomKeyGeneration (PseudorandomKeyGeneration &&)=delete
 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.
 ~PseudorandomKeyGeneration ()=default

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() [1/3]

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

Create a PseudorandomKeyGeneration instance for a fixed identifier.

Definition at line 16 of file hss_lms_utils.cpp.

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

References Botan::copy_mem().

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

◆ PseudorandomKeyGeneration() [2/3]

Botan::PseudorandomKeyGeneration::PseudorandomKeyGeneration ( const PseudorandomKeyGeneration & )
delete

◆ PseudorandomKeyGeneration() [3/3]

Botan::PseudorandomKeyGeneration::PseudorandomKeyGeneration ( PseudorandomKeyGeneration && )
delete

◆ ~PseudorandomKeyGeneration()

Botan::PseudorandomKeyGeneration::~PseudorandomKeyGeneration ( )
default

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 62 of file hss_lms_utils.h.

62 {
63 T output(hash.output_length());
64 gen(output, hash, seed);
65 return output;
66 }
T gen(HashFunction &hash, std::span< const uint8_t > seed) const
Create a hash value using the preconfigured prefix and a seed.

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

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 24 of file hss_lms_utils.cpp.

24 {
25 hash.update(m_input_buffer);
26 hash.update(seed);
27 hash.final(out);
28}

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

◆ operator=() [1/2]

PseudorandomKeyGeneration & Botan::PseudorandomKeyGeneration::operator= ( const PseudorandomKeyGeneration & )
delete

◆ operator=() [2/2]

PseudorandomKeyGeneration & Botan::PseudorandomKeyGeneration::operator= ( PseudorandomKeyGeneration && )
delete

◆ set_i()

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

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

Definition at line 51 of file hss_lms_utils.h.

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

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 56 of file hss_lms_utils.h.

56{ 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 46 of file hss_lms_utils.h.

46{ 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: