Botan 3.4.0
Crypto and TLS for C&
frodo_constants.h
Go to the documentation of this file.
1/*
2 * FrodoKEM constants
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_CONSTANTS_H_
12#define BOTAN_FRODOKEM_CONSTANTS_H_
13
14#include <botan/frodo_mode.h>
15#include <botan/internal/frodo_types.h>
16
17#include <memory>
18#include <string>
19#include <vector>
20
21namespace Botan {
22
23class XOF;
24
26 public:
28
30
31 FrodoKEMConstants(const FrodoKEMConstants& other) : FrodoKEMConstants(other.m_mode) {}
32
36
37 FrodoKEMMode mode() const { return m_mode; }
38
39 size_t cdf_table_len() const { return m_cdf_table.size(); }
40
41 uint16_t cdf_table_at(size_t i) const { return m_cdf_table.at(i); }
42
43 size_t estimated_strength() const { return m_nist_strength; }
44
45 size_t n() const { return m_n; }
46
47 size_t b() const { return m_b; } // extracted bits
48
49 size_t d() const { return m_d; } // D = logq
50
51 size_t n_bar() const { return m_n_bar; }
52
53 size_t len_a_bytes() const { return m_len_a / 8; } // len of seed_a in bytes
54
55 size_t len_se_bytes() const { return m_len_se / 8; }
56
57 size_t len_sec_bytes() const { return m_nist_strength / 8; }
58
59 size_t len_salt_bytes() const { return m_len_salt / 8; }
60
61 size_t len_ct_bytes() const {
62 return (m_d * m_n * m_n_bar + m_d * m_n_bar * m_n_bar + m_len_salt) / 8;
63 } // Ciphertext length in bytes
64
65 size_t len_public_key_bytes() const { return (m_len_a + (m_d * m_n * m_n_bar)) / 8; }
66
67 size_t len_private_key_bytes() const {
68 return (m_nist_strength + m_len_a + (m_d * m_n * m_n_bar) + (m_n_bar * m_n * 16) + m_nist_strength) / 8;
69 }
70
71 size_t len_packed_b_bytes() const { return (m_d * m_n * m_n_bar) / 8; }
72
73 size_t len_packed_c_bytes() const { return (m_d * m_n_bar * m_n_bar) / 8; }
74
76
78
79 // TODO: those aren't actually const. We worked around some constness
80 // issues when playing with the XOFs that are residing in this class.
81 XOF& SHAKE_XOF() const;
82
83 private:
84 FrodoKEMMode m_mode;
85 size_t m_nist_strength;
86 size_t m_len_salt;
87 size_t m_len_se;
88 size_t m_len_a;
89 size_t m_b;
90 size_t m_n;
91 size_t m_n_bar;
92 size_t m_d;
93
94 std::vector<uint16_t> m_cdf_table; // Distribution table T_chi
95
96 mutable std::unique_ptr<XOF> m_shake_xof;
97
98 std::string m_shake;
99};
100
101} // namespace Botan
102
103#endif
size_t estimated_strength() const
FrodoDomainSeparator keygen_domain_separator() const
size_t len_private_key_bytes() const
FrodoKEMConstants & operator=(FrodoKEMConstants &&other)=default
FrodoKEMConstants & operator=(const FrodoKEMConstants &other)=delete
size_t len_public_key_bytes() const
FrodoKEMConstants(const FrodoKEMConstants &other)
FrodoKEMMode mode() const
FrodoKEMConstants(FrodoKEMConstants &&other)=default
uint16_t cdf_table_at(size_t i) const
size_t len_salt_bytes() const
size_t len_packed_c_bytes() const
size_t len_packed_b_bytes() const
FrodoDomainSeparator encapsulation_domain_separator() const
#define BOTAN_TEST_API
Definition compiler.h:51