Botan 3.6.1
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
11#include <botan/internal/stl_util.h>
12
13namespace Botan {
14
15// The magic numbers in the initializer list below reflect the structure of the
16// m_input_buffer member and must be updated if any of the pre-defined
17// std::span<>s are changed.
18PseudorandomKeyGeneration::PseudorandomKeyGeneration(std::span<const uint8_t> identifier) :
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}
25
26void PseudorandomKeyGeneration::gen(std::span<uint8_t> out, HashFunction& hash, std::span<const uint8_t> seed) const {
27 hash.update(m_input_buffer);
28 hash.update(seed);
29 hash.final(out);
30}
31
32} // namespace Botan
void update(const uint8_t in[], size_t length)
Definition buf_comp.h:35
void final(uint8_t out[])
Definition buf_comp.h:70
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:146