Botan 3.5.0
Crypto and TLS for C&
kyber_constants.cpp
Go to the documentation of this file.
1/*
2 * Crystals Kyber Constants
3 *
4 * (C) 2021-2024 Jack Lloyd
5 * (C) 2021-2022 Manuel Glaser and Michael Boric, Rohde & Schwarz Cybersecurity
6 * (C) 2021-2022 René Meusel and Hannes Rantzsch, neXenio GmbH
7 * (C) 2024 René Meusel, Rohde & Schwarz Cybersecurity
8 *
9 * Botan is released under the Simplified BSD License (see license.txt)
10 */
11
12#include <botan/internal/kyber_constants.h>
13
14#if defined(BOTAN_HAS_KYBER)
15 #include <botan/internal/kyber_modern.h>
16#endif
17
18#if defined(BOTAN_HAS_KYBER_90S)
19 #include <botan/internal/kyber_90s.h>
20#endif
21
22namespace Botan {
23
25 switch(mode.mode()) {
28 m_nist_strength = 128;
29 m_k = 2;
30 m_eta1 = 3;
31 break;
32
35 m_nist_strength = 192;
36 m_k = 3;
37 m_eta1 = 2;
38 break;
39
42 m_nist_strength = 256;
43 m_k = 4;
44 m_eta1 = 2;
45 break;
46
47 default:
49 }
50
51#ifdef BOTAN_HAS_KYBER_90S
52 if(mode.is_kyber_round3() && mode.is_90s()) {
53 m_symmetric_primitives = std::make_unique<Kyber_90s_Symmetric_Primitives>();
54 }
55#endif
56
57#ifdef BOTAN_HAS_KYBER
59 m_symmetric_primitives = std::make_unique<Kyber_Modern_Symmetric_Primitives>();
60 }
61#endif
62
63 if(!m_symmetric_primitives) {
64 throw Not_Implemented("requested Kyber mode is not enabled in this build");
65 }
66}
67
69
70} // namespace Botan
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137
KyberConstants(KyberMode mode)
KyberMode mode() const
bool is_kyber_round3() const
Definition kyber.cpp:112
bool is_modern() const
Definition kyber.cpp:108
bool is_90s() const
Definition kyber.cpp:104
Mode mode() const
Definition kyber.h:56