Botan
3.5.0
Crypto and TLS for C&
src
lib
pubkey
dilithium
dilithium
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
22
namespace
Botan
{
23
24
class
Dilithium_Common_Symmetric_Primitives
:
public
Dilithium_Symmetric_Primitives
{
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
35
BOTAN_ASSERT_UNREACHABLE
();
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
BOTAN_ASSERT_UNREACHABLE
#define BOTAN_ASSERT_UNREACHABLE()
Definition
assert.h:137
Botan::Dilithium_Common_Symmetric_Primitives
Definition
dilithium_modern.h:24
Botan::Dilithium_Common_Symmetric_Primitives::XOF
std::unique_ptr< Botan::XOF > XOF(XofType type, std::span< const uint8_t > seed, uint16_t nonce) const override
Definition
dilithium_modern.h:26
Botan::Dilithium_Symmetric_Primitives
Definition
dilithium_symmetric_primitives.h:28
Botan::Dilithium_Symmetric_Primitives::XofType
XofType
Definition
dilithium_symmetric_primitives.h:30
Botan::Dilithium_Symmetric_Primitives::XofType::k128
@ k128
Botan::Dilithium_Symmetric_Primitives::XofType::k256
@ k256
Botan::XOF::create_or_throw
static std::unique_ptr< XOF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition
xof.cpp:42
Botan
Definition
alg_id.cpp:13
Botan::store_le
constexpr auto store_le(ParamTs &&... params)
Definition
loadstor.h:698
Generated by
1.11.0