Botan 3.10.0
Crypto and TLS for C&
hss_lms_utils.cpp
Go to the documentation of this file.
1/**
2 * Utils for HSS/LMS
3 * (C) 2023 Jack Lloyd
4 * 2023 Fabian Albert, Philippe Lieser - Rohde & Schwarz Cybersecurity GmbH
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9#include <botan/internal/hss_lms_utils.h>
10
11namespace Botan {
12
13// The magic numbers in the initializer list below reflect the structure of the
14// m_input_buffer member and must be updated if any of the pre-defined
15// std::span<>s are changed.
16PseudorandomKeyGeneration::PseudorandomKeyGeneration(std::span<const uint8_t> identifier) :
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}
23
24void PseudorandomKeyGeneration::gen(std::span<uint8_t> out, HashFunction& hash, std::span<const uint8_t> seed) const {
25 hash.update(m_input_buffer);
26 hash.update(seed);
27 hash.final(out);
28}
29
30} // namespace Botan
void update(const uint8_t in[], size_t length)
Definition buf_comp.h:34
void final(uint8_t out[])
Definition buf_comp.h:69
PseudorandomKeyGeneration(std::span< const uint8_t > identifier)
Create a PseudorandomKeyGeneration instance for a fixed identifier.
T gen(HashFunction &hash, std::span< const uint8_t > seed) const
Create a hash value using the preconfigured prefix and a seed.
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:145