Botan 3.7.1
Crypto and TLS for C&
Botan::Classic_McEliece_Parameters Class Referencefinal

#include <cmce_parameters.h>

Public Member Functions

size_t ciphertext_size () const
 The byte size of the ciphertext.
 
size_t encode_out_size () const
 The output byte size of the encoding algorithm. See ISO 7.3.
 
size_t estimated_strength () const
 The estimated bit security strength of the Classic McEliece instance.
 
Classic_McEliece_GF gf (CmceGfElem elem) const
 Create a GF(q) element using the modulus for the current instance.
 
std::unique_ptr< HashFunctionhash_func () const
 Create an instance of the hash function Hash(x) used in Classic McEliece's Decaps and Encaps algorithms.
 
bool is_f () const
 
bool is_pc () const
 
size_t m () const
 The degree of the Classic McEliece instance's underlying Galois Field, i.e. GF(q) = GF(2^m).
 
size_t n () const
 The code length of the Classic McEliece instance.
 
OID object_identifier () const
 The OID for the Classic McEliece instance.
 
Classic_McEliece_Parameter_Set parameter_set () const
 The parameter set for this Classic McEliece instance.
 
size_t pk_no_cols () const
 The number of columns in the public key's matrix.
 
size_t pk_no_rows () const
 The number of rows in the public key's matrix.
 
size_t pk_row_size_bytes () const
 The number of bytes for each row in the public key's matrix.
 
size_t pk_size_bytes () const
 The number of bytes for the public key.
 
CmceGfMod poly_f () const
 The monic irreducible polynomial f(z) of degree m over GF(2). Used for modular reduction in GF(2^m).
 
const Classic_McEliece_Polynomial_Ringpoly_ring () const
 The underlying polynomial ring.
 
std::unique_ptr< XOFprg (std::span< const uint8_t > seed) const
 Create a seeded XOF object representing Classic McEliece's PRG. See Classic McEliece ISO 9.1.
 
size_t q () const
 The field size of the Classic McEliece instance's underlying Galois Field, i.e. GF(q) is the underlying field.
 
size_t sk_alpha_control_bytes () const
 The length of the byte representation of the field ordering's control bits. See ISO 9.2.12.
 
size_t sk_poly_g_bytes () const
 The length of the byte representation of the minimal polynomial g. See ISO 9.2.12.
 
size_t sk_s_bytes () const
 The byte length of the seed s. s is used for implicit rejection. See ISO 9.2.12.
 
size_t sk_size_bytes () const
 The byte length of the secret key sk. See ISO 9.2.12.
 
size_t t () const
 The weight of the error vector e.
 
size_t tau () const
 Constant tau for fixed-weight vector generation. (see Classic McEliece ISO 8.4)
 

Static Public Member Functions

static Classic_McEliece_Parameters create (Classic_McEliece_Parameter_Set set)
 Create Classic McEliece parameters from a parameter set.
 
static Classic_McEliece_Parameters create (const OID &oid)
 Create Classic McEliece parameters from an OID.
 
static Classic_McEliece_Parameters create (std::string_view name)
 Create Classic McEliece parameters from a parameter set name.
 
static constexpr size_t ell ()
 Bit output length of the hash function H.
 
static constexpr size_t hash_out_bytes ()
 The byte size of the hash output.
 
static constexpr size_t mu ()
 Constant mu for semi-systematic matrix creation. (see Classic McEliece ISO 7.2.3)
 
static constexpr size_t nu ()
 Constant nu for semi-systematic matrix creation. (see Classic McEliece ISO 7.2.3)
 
static constexpr size_t seed_len ()
 The byte length of the seed delta. See ISO 9.2.12.
 
static constexpr size_t sigma1 ()
 The number of bits each GF element is encoded with.
 
static constexpr size_t sigma2 ()
 Constant for field-ordering generation. (see Classic McEliece ISO 8.2)
 
static constexpr size_t sk_c_bytes ()
 The byte length of the column selection c. See ISO 9.2.12.
 

Detailed Description

Container for all Classic McEliece parameters.

Definition at line 29 of file cmce_parameters.h.

Member Function Documentation

◆ ciphertext_size()

size_t Botan::Classic_McEliece_Parameters::ciphertext_size ( ) const
inline

The byte size of the ciphertext.

Definition at line 229 of file cmce_parameters.h.

229 {
230 if(is_pc()) {
231 // C_0 + C_1
232 return encode_out_size() + hash_out_bytes();
233 } else {
234 return encode_out_size();
235 }
236 }
static constexpr size_t hash_out_bytes()
The byte size of the hash output.
size_t encode_out_size() const
The output byte size of the encoding algorithm. See ISO 7.3.

◆ create() [1/3]

Classic_McEliece_Parameters Botan::Classic_McEliece_Parameters::create ( Classic_McEliece_Parameter_Set set)
static

Create Classic McEliece parameters from a parameter set.

Definition at line 95 of file cmce_parameters.cpp.

95 {
96 auto poly_ring = determine_poly_ring(set);
97
98 switch(set.code()) {
101 return Classic_McEliece_Parameters(set, 12, 3488, std::move(poly_ring));
102
105 return Classic_McEliece_Parameters(set, 13, 4608, std::move(poly_ring));
106
111 return Classic_McEliece_Parameters(set, 13, 6688, std::move(poly_ring));
112
117 return Classic_McEliece_Parameters(set, 13, 6960, std::move(poly_ring));
118
123 return Classic_McEliece_Parameters(set, 13, 8192, std::move(poly_ring));
124 }
126}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137
const Classic_McEliece_Polynomial_Ring & poly_ring() const
The underlying polynomial ring.

References BOTAN_ASSERT_UNREACHABLE, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_348864, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_348864f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_460896, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_460896f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128pc, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128pcf, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119pc, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119pcf, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128pc, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128pcf, Botan::Classic_McEliece_Parameter_Set::code(), and poly_ring().

Referenced by Botan::Classic_McEliece_PrivateKey::Classic_McEliece_PrivateKey(), Botan::Classic_McEliece_PrivateKey::Classic_McEliece_PrivateKey(), Botan::Classic_McEliece_PublicKey::Classic_McEliece_PublicKey(), create(), and create().

◆ create() [2/3]

Classic_McEliece_Parameters Botan::Classic_McEliece_Parameters::create ( const OID & oid)
static

Create Classic McEliece parameters from an OID.

Definition at line 132 of file cmce_parameters.cpp.

132 {
134}
static Classic_McEliece_Parameter_Set from_oid(const OID &oid)
Get the parameter set for a given OID.
static Classic_McEliece_Parameters create(Classic_McEliece_Parameter_Set set)
Create Classic McEliece parameters from a parameter set.

References create(), and Botan::Classic_McEliece_Parameter_Set::from_oid().

◆ create() [3/3]

Classic_McEliece_Parameters Botan::Classic_McEliece_Parameters::create ( std::string_view name)
static

Create Classic McEliece parameters from a parameter set name.

Definition at line 128 of file cmce_parameters.cpp.

128 {
130}
static Classic_McEliece_Parameter_Set from_string(std::string_view param_name)
Get the parameter set for a given parameter set name.
std::string name

References create(), Botan::Classic_McEliece_Parameter_Set::from_string(), and name.

◆ ell()

static constexpr size_t Botan::Classic_McEliece_Parameters::ell ( )
inlinestaticconstexpr

Bit output length of the hash function H.

Definition at line 110 of file cmce_parameters.h.

110{ return 256; }

◆ encode_out_size()

size_t Botan::Classic_McEliece_Parameters::encode_out_size ( ) const
inline

The output byte size of the encoding algorithm. See ISO 7.3.

Definition at line 217 of file cmce_parameters.h.

217{ return ceil_division<size_t>(m() * t(), 8); }
size_t m() const
The degree of the Classic McEliece instance's underlying Galois Field, i.e. GF(q) = GF(2^m).
size_t t() const
The weight of the error vector e.
constexpr T ceil_division(T a, T b)
Definition bit_ops.h:160

◆ estimated_strength()

size_t Botan::Classic_McEliece_Parameters::estimated_strength ( ) const

The estimated bit security strength of the Classic McEliece instance.

Reference: Classic McEliece NIST Round 4 submission, Guide for security reviewers

Definition at line 148 of file cmce_parameters.cpp.

148 {
149 // Classic McEliece NIST Round 4 submission, Guide for security reviewers, Table 1:
150 // For each instance, the minimal strength against the best attack (with free memory access)
151 // is used as the overall security strength estimate. The strength is capped at 256, since the
152 // seed is only 256 bits long.
153 switch(m_set.code()) {
156 return 140;
159 return 179;
164 return 246;
169 return 245;
174 return 256; // 275 in the document. Capped at 256 because of the seed length.
175 }
177}
Code code() const
Get the code for a given parameter set.

References BOTAN_ASSERT_UNREACHABLE, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_348864, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_348864f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_460896, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_460896f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128pc, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128pcf, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119pc, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119pcf, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128f, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128pc, Botan::Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128pcf, and Botan::Classic_McEliece_Parameter_Set::code().

◆ gf()

Classic_McEliece_GF Botan::Classic_McEliece_Parameters::gf ( CmceGfElem elem) const
inline

Create a GF(q) element using the modulus for the current instance.

Parameters
elemThe GF(q) element value.
Returns
The GF(q) element.

Definition at line 265 of file cmce_parameters.h.

265{ return Classic_McEliece_GF(elem, poly_f()); }
CmceGfMod poly_f() const
The monic irreducible polynomial f(z) of degree m over GF(2). Used for modular reduction in GF(2^m).

◆ hash_func()

std::unique_ptr< HashFunction > Botan::Classic_McEliece_Parameters::hash_func ( ) const
inline

Create an instance of the hash function Hash(x) used in Classic McEliece's Decaps and Encaps algorithms.

Returns
a new instance of the hash function.

Definition at line 257 of file cmce_parameters.h.

257{ return HashFunction::create_or_throw("SHAKE-256(256)"); }
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:298

◆ hash_out_bytes()

static constexpr size_t Botan::Classic_McEliece_Parameters::hash_out_bytes ( )
inlinestaticconstexpr

The byte size of the hash output.

This is also the size of the shared key K that is a hash output.

Definition at line 224 of file cmce_parameters.h.

224{ return ell() / 8; }
static constexpr size_t ell()
Bit output length of the hash function H.

◆ is_f()

bool Botan::Classic_McEliece_Parameters::is_f ( ) const
inline

◆ is_pc()

bool Botan::Classic_McEliece_Parameters::is_pc ( ) const
inline

◆ m()

size_t Botan::Classic_McEliece_Parameters::m ( ) const
inline

The degree of the Classic McEliece instance's underlying Galois Field, i.e. GF(q) = GF(2^m).

Definition at line 86 of file cmce_parameters.h.

86{ return m_m; }

Referenced by Botan::Classic_McEliece_Field_Ordering::create_from_control_bits().

◆ mu()

static constexpr size_t Botan::Classic_McEliece_Parameters::mu ( )
inlinestaticconstexpr

Constant mu for semi-systematic matrix creation. (see Classic McEliece ISO 7.2.3)

Definition at line 125 of file cmce_parameters.h.

125{ return 32; }

Referenced by Botan::Classic_McEliece_Field_Ordering::permute_with_pivots().

◆ n()

size_t Botan::Classic_McEliece_Parameters::n ( ) const
inline

The code length of the Classic McEliece instance.

E.g. the Classic McEliece matrix H is of size m*t x n, the encoded error vector is, therefore, of size n.

Definition at line 100 of file cmce_parameters.h.

100{ return m_n; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key(), and Botan::Classic_McEliece_Matrix::mul().

◆ nu()

static constexpr size_t Botan::Classic_McEliece_Parameters::nu ( )
inlinestaticconstexpr

Constant nu for semi-systematic matrix creation. (see Classic McEliece ISO 7.2.3)

Definition at line 130 of file cmce_parameters.h.

130{ return 64; }

Referenced by Botan::Classic_McEliece_Field_Ordering::permute_with_pivots().

◆ object_identifier()

OID Botan::Classic_McEliece_Parameters::object_identifier ( ) const

The OID for the Classic McEliece instance.

Definition at line 136 of file cmce_parameters.cpp.

136 {
137 return OID::from_string(m_set.to_string());
138}
std::string to_string() const
Get the parameter set name for a given parameter set.
static OID from_string(std::string_view str)
Definition asn1_oid.cpp:86

References Botan::OID::from_string(), and Botan::Classic_McEliece_Parameter_Set::to_string().

◆ parameter_set()

Classic_McEliece_Parameter_Set Botan::Classic_McEliece_Parameters::parameter_set ( ) const
inline

The parameter set for this Classic McEliece instance.

Definition at line 49 of file cmce_parameters.h.

49{ return m_set; }

◆ pk_no_cols()

size_t Botan::Classic_McEliece_Parameters::pk_no_cols ( ) const
inline

The number of columns in the public key's matrix.

Note that this is only the column number of the submatrix T (with H = (I_mt | T)), which is stored in the public key. The column number of the whole matrix H is n. This constant is also denoted as k in the spec.

Definition at line 200 of file cmce_parameters.h.

200{ return n() - pk_no_rows(); }
size_t pk_no_rows() const
The number of rows in the public key's matrix.
size_t n() const
The code length of the Classic McEliece instance.

Referenced by Botan::Classic_McEliece_Matrix::Classic_McEliece_Matrix().

◆ pk_no_rows()

size_t Botan::Classic_McEliece_Parameters::pk_no_rows ( ) const
inline

The number of rows in the public key's matrix.

Definition at line 191 of file cmce_parameters.h.

191{ return t() * m(); }

Referenced by Botan::Classic_McEliece_Matrix::Classic_McEliece_Matrix(), Botan::Classic_McEliece_Matrix::mul(), and Botan::Classic_McEliece_Field_Ordering::permute_with_pivots().

◆ pk_row_size_bytes()

size_t Botan::Classic_McEliece_Parameters::pk_row_size_bytes ( ) const
inline

The number of bytes for each row in the public key's matrix.

Definition at line 205 of file cmce_parameters.h.

205{ return (pk_no_cols() + 7) / 8; }
size_t pk_no_cols() const
The number of columns in the public key's matrix.

Referenced by Botan::Classic_McEliece_Matrix::Classic_McEliece_Matrix(), and Botan::Classic_McEliece_Matrix::mul().

◆ pk_size_bytes()

size_t Botan::Classic_McEliece_Parameters::pk_size_bytes ( ) const
inline

The number of bytes for the public key.

Equal to the byte size of the CMCE matrix.

Definition at line 212 of file cmce_parameters.h.

212{ return pk_no_rows() * pk_row_size_bytes(); }
size_t pk_row_size_bytes() const
The number of bytes for each row in the public key's matrix.

Referenced by Botan::Classic_McEliece_Matrix::Classic_McEliece_Matrix().

◆ poly_f()

CmceGfMod Botan::Classic_McEliece_Parameters::poly_f ( ) const
inline

The monic irreducible polynomial f(z) of degree m over GF(2). Used for modular reduction in GF(2^m).

Definition at line 146 of file cmce_parameters.h.

146{ return m_poly_ring.poly_f(); }

Referenced by Botan::Classic_McEliece_Field_Ordering::create_field_ordering(), Botan::Classic_McEliece_Field_Ordering::create_from_control_bits(), and Botan::Classic_McEliece_PrivateKeyInternal::from_bytes().

◆ poly_ring()

const Classic_McEliece_Polynomial_Ring & Botan::Classic_McEliece_Parameters::poly_ring ( ) const
inline

The underlying polynomial ring.

Definition at line 241 of file cmce_parameters.h.

241{ return m_poly_ring; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key(), and create().

◆ prg()

std::unique_ptr< XOF > Botan::Classic_McEliece_Parameters::prg ( std::span< const uint8_t > seed) const

Create a seeded XOF object representing Classic McEliece's PRG. See Classic McEliece ISO 9.1.

Parameters
seedThe seed used for the XOF.

Definition at line 179 of file cmce_parameters.cpp.

179 {
180 BOTAN_ASSERT_EQUAL(seed.size(), 32, "Valid seed length");
181 auto xof = XOF::create_or_throw("SHAKE-256");
182
183 xof->update(std::array<uint8_t, 1>({64}));
184 xof->update(seed);
185
186 return xof;
187}
#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made)
Definition assert.h:68
static std::unique_ptr< XOF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition xof.cpp:42

References BOTAN_ASSERT_EQUAL, and Botan::XOF::create_or_throw().

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key().

◆ q()

size_t Botan::Classic_McEliece_Parameters::q ( ) const
inline

The field size of the Classic McEliece instance's underlying Galois Field, i.e. GF(q) is the underlying field.

Definition at line 92 of file cmce_parameters.h.

92{ return (size_t(1) << m_m); }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key(), and Botan::Classic_McEliece_Field_Ordering::create_field_ordering().

◆ seed_len()

static constexpr size_t Botan::Classic_McEliece_Parameters::seed_len ( )
inlinestaticconstexpr

The byte length of the seed delta. See ISO 9.2.12.

Definition at line 158 of file cmce_parameters.h.

158{ return ell() / 8; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::from_bytes(), and Botan::Classic_McEliece_KeyPair_Internal::generate().

◆ sigma1()

static constexpr size_t Botan::Classic_McEliece_Parameters::sigma1 ( )
inlinestaticconstexpr

The number of bits each GF element is encoded with.

Definition at line 115 of file cmce_parameters.h.

115{ return 16; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key().

◆ sigma2()

static constexpr size_t Botan::Classic_McEliece_Parameters::sigma2 ( )
inlinestaticconstexpr

Constant for field-ordering generation. (see Classic McEliece ISO 8.2)

Definition at line 120 of file cmce_parameters.h.

120{ return 32; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key(), and Botan::Classic_McEliece_Field_Ordering::create_field_ordering().

◆ sk_alpha_control_bytes()

size_t Botan::Classic_McEliece_Parameters::sk_alpha_control_bytes ( ) const
inline

The length of the byte representation of the field ordering's control bits. See ISO 9.2.12.

Definition at line 173 of file cmce_parameters.h.

173{ return (2 * m() - 1) * (size_t(1) << (m() - 4)); }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::from_bytes().

◆ sk_c_bytes()

static constexpr size_t Botan::Classic_McEliece_Parameters::sk_c_bytes ( )
inlinestaticconstexpr

The byte length of the column selection c. See ISO 9.2.12.

Definition at line 163 of file cmce_parameters.h.

163{ return 8; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::from_bytes().

◆ sk_poly_g_bytes()

size_t Botan::Classic_McEliece_Parameters::sk_poly_g_bytes ( ) const
inline

The length of the byte representation of the minimal polynomial g. See ISO 9.2.12.

Definition at line 168 of file cmce_parameters.h.

168{ return t() * sizeof(uint16_t); }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::from_bytes().

◆ sk_s_bytes()

size_t Botan::Classic_McEliece_Parameters::sk_s_bytes ( ) const
inline

The byte length of the seed s. s is used for implicit rejection. See ISO 9.2.12.

Definition at line 178 of file cmce_parameters.h.

178{ return n() / 8; }

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::from_bytes().

◆ sk_size_bytes()

size_t Botan::Classic_McEliece_Parameters::sk_size_bytes ( ) const
inline

The byte length of the secret key sk. See ISO 9.2.12.

Definition at line 183 of file cmce_parameters.h.

183 {
184 // ISO 9.2.12: sk = (delta, c, g, alpha(control bits), s)
186 }
static constexpr size_t seed_len()
The byte length of the seed delta. See ISO 9.2.12.
static constexpr size_t sk_c_bytes()
The byte length of the column selection c. See ISO 9.2.12.
size_t sk_poly_g_bytes() const
The length of the byte representation of the minimal polynomial g. See ISO 9.2.12.
size_t sk_alpha_control_bytes() const
The length of the byte representation of the field ordering's control bits. See ISO 9....
size_t sk_s_bytes() const
The byte length of the seed s. s is used for implicit rejection. See ISO 9.2.12.

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::from_bytes().

◆ t()

size_t Botan::Classic_McEliece_Parameters::t ( ) const
inline

The weight of the error vector e.

Definition at line 105 of file cmce_parameters.h.

105{ return m_poly_ring.degree(); }
size_t degree() const
The degree of polynomials in this ring (and of F(y)).
Definition cmce_poly.h:135

Referenced by Botan::Classic_McEliece_PrivateKeyInternal::check_key().

◆ tau()

size_t Botan::Classic_McEliece_Parameters::tau ( ) const
inline

Constant tau for fixed-weight vector generation. (see Classic McEliece ISO 8.4)

Definition at line 135 of file cmce_parameters.h.

135 {
136 // Section 8.4 of ISO:
137 // The integer tau is defined as t if n=q; as 2t if q/2<=n<q; as 4t if q/4<=n<q/2; etc
138 size_t tau_fact = size_t(1) << (m() - floor_log2(n()));
139 return tau_fact * t();
140 }
constexpr T floor_log2(T n)
Definition bit_ops.h:125

References Botan::floor_log2().


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