Botan 3.5.0
Crypto and TLS for C&
Botan::FrodoKEMConstants Class Reference

#include <frodo_constants.h>

Public Member Functions

size_t b () const
 
uint16_t cdf_table_at (size_t i) const
 
size_t cdf_table_len () const
 
size_t d () const
 
FrodoDomainSeparator encapsulation_domain_separator () const
 
size_t estimated_strength () const
 
 FrodoKEMConstants (const FrodoKEMConstants &other)
 
 FrodoKEMConstants (FrodoKEMConstants &&other)=default
 
 FrodoKEMConstants (FrodoKEMMode mode)
 
FrodoDomainSeparator keygen_domain_separator () const
 
size_t len_a_bytes () const
 
size_t len_ct_bytes () const
 
size_t len_packed_b_bytes () const
 
size_t len_packed_c_bytes () const
 
size_t len_private_key_bytes () const
 
size_t len_public_key_bytes () const
 
size_t len_salt_bytes () const
 
size_t len_se_bytes () const
 
size_t len_sec_bytes () const
 
FrodoKEMMode mode () const
 
size_t n () const
 
size_t n_bar () const
 
FrodoKEMConstantsoperator= (const FrodoKEMConstants &other)=delete
 
FrodoKEMConstantsoperator= (FrodoKEMConstants &&other)=default
 
XOFSHAKE_XOF () const
 
 ~FrodoKEMConstants ()
 

Detailed Description

Definition at line 25 of file frodo_constants.h.

Constructor & Destructor Documentation

◆ FrodoKEMConstants() [1/3]

Botan::FrodoKEMConstants::FrodoKEMConstants ( FrodoKEMMode mode)

Definition at line 17 of file frodo_constants.cpp.

17 : m_mode(mode), m_len_a(128), m_n_bar(8) {
18 BOTAN_ASSERT(m_mode.is_available(), "Mode is not available.");
19
20 if(mode.is_ephemeral()) {
21 m_len_salt = 0;
22 }
23
24 switch(mode.mode()) {
29 m_nist_strength = 128;
30 m_d = 15;
31 m_n = 640;
32 m_b = 2;
33 if(mode.is_static()) {
34 m_len_salt = 256;
35 m_len_se = 256;
36 } else if(mode.is_ephemeral()) {
37 m_len_se = 128;
38 } else {
40 }
41
42 m_cdf_table = {4643, 13363, 20579, 25843, 29227, 31145, 32103, 32525, 32689, 32745, 32762, 32766, 32767};
43
44 m_shake = "SHAKE-128";
45 break;
46
51 m_nist_strength = 192;
52 m_d = 16;
53 m_n = 976;
54 m_b = 3;
55 if(mode.is_static()) {
56 m_len_salt = 384;
57 m_len_se = 384;
58 } else if(mode.is_ephemeral()) {
59 m_len_se = 192;
60 } else {
62 }
63
64 m_cdf_table = {5638, 15915, 23689, 28571, 31116, 32217, 32613, 32731, 32760, 32766, 32767};
65
66 m_shake = "SHAKE-256";
67 break;
68
73 m_nist_strength = 256;
74 m_d = 16;
75 m_n = 1344;
76 m_b = 4;
77 if(mode.is_static()) {
78 m_len_salt = 512;
79 m_len_se = 512;
80 } else if(mode.is_ephemeral()) {
81 m_len_se = 256;
82 } else {
84 }
85
86 m_cdf_table = {9142, 23462, 30338, 32361, 32725, 32765, 32767};
87
88 m_shake = "SHAKE-256";
89 break;
90 }
91
92 m_shake_xof = XOF::create_or_throw(m_shake);
93}
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:50
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137
FrodoKEMMode mode() const
bool is_static() const
Definition frodo_mode.h:51
bool is_available() const
Definition frodo_mode.h:66
Mode mode() const
Definition frodo_mode.h:44
bool is_ephemeral() const
Definition frodo_mode.h:46
static std::unique_ptr< XOF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition xof.cpp:42

References BOTAN_ASSERT, BOTAN_ASSERT_UNREACHABLE, Botan::XOF::create_or_throw(), Botan::FrodoKEMMode::eFrodoKEM1344_AES, Botan::FrodoKEMMode::eFrodoKEM1344_SHAKE, Botan::FrodoKEMMode::eFrodoKEM640_AES, Botan::FrodoKEMMode::eFrodoKEM640_SHAKE, Botan::FrodoKEMMode::eFrodoKEM976_AES, Botan::FrodoKEMMode::eFrodoKEM976_SHAKE, Botan::FrodoKEMMode::FrodoKEM1344_AES, Botan::FrodoKEMMode::FrodoKEM1344_SHAKE, Botan::FrodoKEMMode::FrodoKEM640_AES, Botan::FrodoKEMMode::FrodoKEM640_SHAKE, Botan::FrodoKEMMode::FrodoKEM976_AES, Botan::FrodoKEMMode::FrodoKEM976_SHAKE, Botan::FrodoKEMMode::is_available(), Botan::FrodoKEMMode::is_ephemeral(), Botan::FrodoKEMMode::is_static(), mode(), and Botan::FrodoKEMMode::mode().

◆ ~FrodoKEMConstants()

Botan::FrodoKEMConstants::~FrodoKEMConstants ( )
default

◆ FrodoKEMConstants() [2/3]

Botan::FrodoKEMConstants::FrodoKEMConstants ( const FrodoKEMConstants & other)
inline

Definition at line 31 of file frodo_constants.h.

31: FrodoKEMConstants(other.m_mode) {}
FrodoKEMConstants(FrodoKEMMode mode)

◆ FrodoKEMConstants() [3/3]

Botan::FrodoKEMConstants::FrodoKEMConstants ( FrodoKEMConstants && other)
default

Member Function Documentation

◆ b()

size_t Botan::FrodoKEMConstants::b ( ) const
inline

Definition at line 47 of file frodo_constants.h.

47{ return m_b; } // extracted bits

Referenced by Botan::FrodoMatrix::decode(), and Botan::FrodoMatrix::encode().

◆ cdf_table_at()

uint16_t Botan::FrodoKEMConstants::cdf_table_at ( size_t i) const
inline

Definition at line 41 of file frodo_constants.h.

41{ return m_cdf_table.at(i); }

Referenced by Botan::FrodoMatrix::sample().

◆ cdf_table_len()

size_t Botan::FrodoKEMConstants::cdf_table_len ( ) const
inline

Definition at line 39 of file frodo_constants.h.

39{ return m_cdf_table.size(); }

Referenced by Botan::FrodoMatrix::sample().

◆ d()

◆ encapsulation_domain_separator()

FrodoDomainSeparator Botan::FrodoKEMConstants::encapsulation_domain_separator ( ) const
inline

Definition at line 75 of file frodo_constants.h.

75{ return FrodoDomainSeparator({0x96}); }
Strong< std::array< uint8_t, 1 >, struct FrodoDoaminSeparator_ > FrodoDomainSeparator
Definition frodo_types.h:47

◆ estimated_strength()

size_t Botan::FrodoKEMConstants::estimated_strength ( ) const
inline

Definition at line 43 of file frodo_constants.h.

43{ return m_nist_strength; }

◆ keygen_domain_separator()

FrodoDomainSeparator Botan::FrodoKEMConstants::keygen_domain_separator ( ) const
inline

Definition at line 77 of file frodo_constants.h.

77{ return FrodoDomainSeparator({0x5F}); }

Referenced by Botan::FrodoKEM_PrivateKey::FrodoKEM_PrivateKey().

◆ len_a_bytes()

size_t Botan::FrodoKEMConstants::len_a_bytes ( ) const
inline

◆ len_ct_bytes()

size_t Botan::FrodoKEMConstants::len_ct_bytes ( ) const
inline

Definition at line 61 of file frodo_constants.h.

61 {
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

◆ len_packed_b_bytes()

size_t Botan::FrodoKEMConstants::len_packed_b_bytes ( ) const
inline

Definition at line 71 of file frodo_constants.h.

71{ return (m_d * m_n * m_n_bar) / 8; }

◆ len_packed_c_bytes()

size_t Botan::FrodoKEMConstants::len_packed_c_bytes ( ) const
inline

Definition at line 73 of file frodo_constants.h.

73{ return (m_d * m_n_bar * m_n_bar) / 8; }

◆ len_private_key_bytes()

size_t Botan::FrodoKEMConstants::len_private_key_bytes ( ) const
inline

Definition at line 67 of file frodo_constants.h.

67 {
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 }

Referenced by Botan::FrodoKEM_PrivateKey::FrodoKEM_PrivateKey().

◆ len_public_key_bytes()

size_t Botan::FrodoKEMConstants::len_public_key_bytes ( ) const
inline

Definition at line 65 of file frodo_constants.h.

65{ return (m_len_a + (m_d * m_n * m_n_bar)) / 8; }

Referenced by Botan::FrodoKEM_PublicKey::FrodoKEM_PublicKey().

◆ len_salt_bytes()

size_t Botan::FrodoKEMConstants::len_salt_bytes ( ) const
inline

Definition at line 59 of file frodo_constants.h.

59{ return m_len_salt / 8; }

◆ len_se_bytes()

size_t Botan::FrodoKEMConstants::len_se_bytes ( ) const
inline

Definition at line 55 of file frodo_constants.h.

55{ return m_len_se / 8; }

Referenced by Botan::FrodoKEM_PrivateKey::FrodoKEM_PrivateKey().

◆ len_sec_bytes()

size_t Botan::FrodoKEMConstants::len_sec_bytes ( ) const
inline

Definition at line 57 of file frodo_constants.h.

57{ return m_nist_strength / 8; }

Referenced by Botan::FrodoKEM_PrivateKey::FrodoKEM_PrivateKey(), and Botan::FrodoKEM_PrivateKey::FrodoKEM_PrivateKey().

◆ mode()

FrodoKEMMode Botan::FrodoKEMConstants::mode ( ) const
inline

Definition at line 37 of file frodo_constants.h.

37{ return m_mode; }

Referenced by Botan::create_aes_row_generator(), Botan::create_shake_row_generator(), and FrodoKEMConstants().

◆ n()

◆ n_bar()

◆ operator=() [1/2]

FrodoKEMConstants & Botan::FrodoKEMConstants::operator= ( const FrodoKEMConstants & other)
delete

◆ operator=() [2/2]

FrodoKEMConstants & Botan::FrodoKEMConstants::operator= ( FrodoKEMConstants && other)
default

◆ SHAKE_XOF()

XOF & Botan::FrodoKEMConstants::SHAKE_XOF ( ) const

Definition at line 97 of file frodo_constants.cpp.

97 {
98 m_shake_xof->clear();
99 return *m_shake_xof;
100}

Referenced by Botan::FrodoKEM_PrivateKey::FrodoKEM_PrivateKey().


The documentation for this class was generated from the following files: