9#ifndef BOTAN_CMCE_PARAMS_H_
10#define BOTAN_CMCE_PARAMS_H_
12#include <botan/asn1_obj.h>
13#include <botan/cmce_parameter_set.h>
14#include <botan/hash.h>
16#include <botan/internal/cmce_gf.h>
17#include <botan/internal/cmce_poly.h>
23struct Classic_McEliece_Big_F_Coefficient;
24class Classic_McEliece_Polynomial_Ring;
54 OID object_identifier()
const;
60 return (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128pc) ||
61 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128pcf) ||
62 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119pc) ||
63 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119pcf) ||
64 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128pc) ||
65 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128pcf);
73 return (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_348864f) ||
74 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_460896f) ||
75 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128f) ||
76 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6688128pcf) ||
77 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119f) ||
78 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_6960119pcf) ||
79 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128f) ||
80 (m_set == Classic_McEliece_Parameter_Set::ClassicMcEliece_8192128pcf);
86 size_t m()
const {
return m_m; }
92 size_t q()
const {
return (
size_t(1) << m_m); }
100 size_t n()
const {
return m_n; }
105 size_t t()
const {
return m_poly_ring.degree(); }
110 static constexpr size_t ell() {
return 256; }
115 static constexpr size_t sigma1() {
return 16; }
120 static constexpr size_t sigma2() {
return 32; }
125 static constexpr size_t mu() {
return 32; }
130 static constexpr size_t nu() {
return 64; }
138 size_t tau_fact = size_t(1) << (m() -
floor_log2(n()));
139 return tau_fact * t();
153 size_t estimated_strength()
const;
158 static constexpr size_t seed_len() {
return ell() / 8; }
185 return seed_len() + sk_c_bytes() + sk_poly_g_bytes() + sk_alpha_control_bytes() + sk_s_bytes();
232 return encode_out_size() + hash_out_bytes();
234 return encode_out_size();
249 std::unique_ptr<XOF> prg(std::span<const uint8_t> seed)
const;
257 std::unique_ptr<HashFunction>
hash_func()
const {
return HashFunction::create_or_throw(
"SHAKE-256(256)"); }
Represents an element of the finite field GF(q) for q = 2^m.
Classic_McEliece_GF gf(CmceGfElem elem) const
Create a GF(q) element using the modulus for the current instance.
size_t m() const
The degree of the Classic McEliece instance's underlying Galois Field, i.e. GF(q) = GF(2^m).
static constexpr size_t seed_len()
The byte length of the seed delta. See ISO 9.2.12.
std::unique_ptr< HashFunction > hash_func() const
Create an instance of the hash function Hash(x) used in Classic McEliece's Decaps and Encaps algorith...
size_t q() const
The field size of the Classic McEliece instance's underlying Galois Field, i.e. GF(q) is the underlyi...
CmceGfMod poly_f() const
The monic irreducible polynomial f(z) of degree m over GF(2). Used for modular reduction in GF(2^m).
static constexpr size_t sk_c_bytes()
The byte length of the column selection c. See ISO 9.2.12.
static constexpr size_t nu()
Constant nu for semi-systematic matrix creation. (see Classic McEliece ISO 7.2.3)
static constexpr size_t mu()
Constant mu for semi-systematic matrix creation. (see Classic McEliece ISO 7.2.3)
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.
static constexpr size_t hash_out_bytes()
The byte size of the hash output.
size_t n() const
The code length of the Classic McEliece instance.
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 tau() const
Constant tau for fixed-weight vector generation. (see Classic McEliece ISO 8.4)
size_t pk_no_cols() const
The number of columns in the public key's matrix.
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 pk_size_bytes() const
The number of bytes for the public key.
size_t ciphertext_size() const
The byte size of the ciphertext.
const Classic_McEliece_Polynomial_Ring & poly_ring() const
The underlying polynomial ring.
size_t encode_out_size() const
The output byte size of the encoding algorithm. See ISO 7.3.
size_t sk_s_bytes() const
The byte length of the seed s. s is used for implicit rejection. See ISO 9.2.12.
static constexpr size_t sigma2()
Constant for field-ordering generation. (see Classic McEliece ISO 8.2)
size_t sk_size_bytes() const
The byte length of the secret key sk. See ISO 9.2.12.
static constexpr size_t sigma1()
The number of bits each GF element is encoded with.
static constexpr size_t ell()
Bit output length of the hash function H.
size_t t() const
The weight of the error vector e.
Classic_McEliece_Parameter_Set parameter_set() const
The parameter set for this Classic McEliece instance.
Represents the polynomial ring GF(q)[y]/F(y) where F(y) is the modulus polynomial in GF(q)[y] of degr...
int(* final)(unsigned char *, CTX *)
constexpr T floor_log2(T n)