Botan 3.4.0
Crypto and TLS for C&
dilithium_modern.h
Go to the documentation of this file.
1/*
2* Asymmetric primitives for dilithium
3* (C) 2022 Jack Lloyd
4* (C) 2022 Manuel Glaser, Michael Boric, René Meusel - Rohde & Schwarz Cybersecurity
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_DILITHIUM_COMMON_SYM_PRIMITIVES_H_
10#define BOTAN_DILITHIUM_COMMON_SYM_PRIMITIVES_H_
11
12#include <botan/internal/dilithium_symmetric_primitives.h>
13
14#include <botan/internal/loadstor.h>
15#include <botan/internal/shake.h>
16#include <botan/internal/shake_xof.h>
17
18#include <array>
19#include <memory>
20#include <vector>
21
22namespace Botan {
23
25 public:
26 std::unique_ptr<Botan::XOF> XOF(XofType type, std::span<const uint8_t> seed, uint16_t nonce) const override {
27 const auto xof_type = [&] {
28 switch(type) {
29 case XofType::k128:
30 return "SHAKE-128";
31 case XofType::k256:
32 return "SHAKE-256";
33 }
34
36 }();
37
38 std::array<uint8_t, sizeof(nonce)> nonce_buffer;
39 store_le(nonce, nonce_buffer.data());
40
41 auto xof = Botan::XOF::create_or_throw(xof_type);
42 xof->update(seed);
43 xof->update(nonce_buffer);
44 return xof;
45 }
46};
47
48} // namespace Botan
49
50#endif
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137
std::unique_ptr< Botan::XOF > XOF(XofType type, std::span< const uint8_t > seed, uint16_t nonce) const override
static std::unique_ptr< XOF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition xof.cpp:42
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:702