Botan 3.4.0
Crypto and TLS for C&
frodo_shake_generator.h
Go to the documentation of this file.
1/*
2 * FrodoKEM matrix generator based on SHAKE
3 *
4 * The Fellowship of the FrodoKEM:
5 * (C) 2023 Jack Lloyd
6 * 2023 René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity
7 *
8 * Botan is released under the Simplified BSD License (see license.txt)
9 */
10
11#ifndef BOTAN_FRODOKEM_SHAKE_GENERATOR_H_
12#define BOTAN_FRODOKEM_SHAKE_GENERATOR_H_
13
14#include <botan/internal/frodo_constants.h>
15#include <botan/internal/frodo_types.h>
16#include <botan/internal/loadstor.h>
17#include <botan/internal/shake_xof.h>
18
19#include <span>
20
21namespace Botan {
22
24 BOTAN_ASSERT_NOMSG(constants.mode().is_shake());
25
26 return [xof = SHAKE_128_XOF(), a = FrodoSeedA(seed_a)](std::span<uint8_t> out, uint16_t i) mutable {
27 xof.clear();
28 // TODO: update that once #3707 is merged
29 // potentially add a new method: std::array<uint8_t, XX> as_le(uintXX_t)
30 std::array<uint8_t, 2> le;
31 store_le(i, le.data());
32 xof.update(le);
33 xof.update(a);
34 xof.output(out);
35 };
36}
37
38} // namespace Botan
39
40#endif
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59
FrodoKEMMode mode() const
bool is_shake() const
Definition frodo_mode.h:56
auto create_shake_row_generator(const FrodoKEMConstants &constants, StrongSpan< const FrodoSeedA > seed_a)
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:702
Strong< std::vector< uint8_t >, struct FrodoSeedA_ > FrodoSeedA
Definition frodo_types.h:23