Botan 2.19.3
Crypto and TLS for C&
|
#include <polyn_gf2m.h>
Public Member Functions | |
void | add_to_coef (size_t i, gf2m v) |
int | calc_degree_secure () const |
size_t | degppf (const polyn_gf2m &g) |
secure_vector< uint8_t > | encode () const |
void | encode (uint32_t min_numo_coeffs, uint8_t *mem, uint32_t mem_len) const |
gf2m | eval (gf2m a) |
gf2m | get_coef (size_t i) const |
int | get_degree () const |
gf2m | get_lead_coef () const |
std::shared_ptr< GF2m_Field > | get_sp_field () const |
bool | operator!= (const polyn_gf2m &other) const |
polyn_gf2m & | operator= (const polyn_gf2m &)=default |
polyn_gf2m & | operator= (polyn_gf2m &&other) |
bool | operator== (const polyn_gf2m &other) const |
gf2m & | operator[] (size_t i) |
gf2m | operator[] (size_t i) const |
void | patchup_deg_secure (uint32_t trgt_deg, volatile gf2m patch_elem) |
polyn_gf2m () | |
polyn_gf2m (const secure_vector< uint8_t > &encoded, std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m (const uint8_t *mem, uint32_t mem_len, std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m (int d, std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m (int degree, const uint8_t *mem, size_t mem_byte_len, std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m (polyn_gf2m &&other) | |
polyn_gf2m (polyn_gf2m const &other) | |
polyn_gf2m (size_t t, RandomNumberGenerator &rng, std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m (std::shared_ptr< GF2m_Field > sp_field) | |
void | set_coef (size_t i, gf2m v) |
void | set_to_zero () |
polyn_gf2m | sqmod (const std::vector< polyn_gf2m > &sq, int d) |
void | swap (polyn_gf2m &other) |
std::string | to_string () const |
Static Public Member Functions | |
static std::pair< polyn_gf2m, polyn_gf2m > | eea_with_coefficients (const polyn_gf2m &p, const polyn_gf2m &g, int break_deg) |
static std::vector< polyn_gf2m > | sqmod_init (const polyn_gf2m &g) |
static std::vector< polyn_gf2m > | sqrt_mod_init (const polyn_gf2m &g) |
Public Attributes | |
secure_vector< gf2m > | coeff |
int | m_deg |
std::shared_ptr< GF2m_Field > | m_sp_field |
Definition at line 30 of file polyn_gf2m.h.
|
explicit |
|
inline |
Definition at line 38 of file polyn_gf2m.h.
Referenced by sqmod_init(), and sqrt_mod_init().
Botan::polyn_gf2m::polyn_gf2m | ( | const secure_vector< uint8_t > & | encoded, |
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
Definition at line 754 of file polyn_gf2m.cpp.
References coeff, and get_degree().
Botan::polyn_gf2m::polyn_gf2m | ( | int | d, |
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
create zero polynomial with reservation of space for a degree d polynomial
Definition at line 97 of file polyn_gf2m.cpp.
Botan::polyn_gf2m::polyn_gf2m | ( | polyn_gf2m const & | other | ) |
Definition at line 91 of file polyn_gf2m.cpp.
Botan::polyn_gf2m::polyn_gf2m | ( | size_t | t, |
RandomNumberGenerator & | rng, | ||
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
random irreducible polynomial of degree t
Definition at line 639 of file polyn_gf2m.cpp.
References degppf(), Botan::random_code_element(), and set_coef().
Botan::polyn_gf2m::polyn_gf2m | ( | const uint8_t * | mem, |
uint32_t | mem_len, | ||
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
decode a polynomial from memory:
Definition at line 126 of file polyn_gf2m.cpp.
References coeff, Botan::decode_gf2m(), get_degree(), and m_deg.
Botan::polyn_gf2m::polyn_gf2m | ( | int | degree, |
const uint8_t * | mem, | ||
size_t | mem_byte_len, | ||
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
create a polynomial from memory area (encoded)
Definition at line 157 of file polyn_gf2m.cpp.
References coeff, get_degree(), and m_sp_field.
|
inline |
|
inline |
int Botan::polyn_gf2m::calc_degree_secure | ( | ) | const |
determine the degree in a timing secure manner. the timing of this function only depends on the number of allocated coefficients, not on the actual degree
Definition at line 46 of file polyn_gf2m.cpp.
References coeff, Botan::expand_mask_16bit(), and m_deg.
Referenced by eea_with_coefficients(), and patchup_deg_secure().
size_t Botan::polyn_gf2m::degppf | ( | const polyn_gf2m & | g | ) |
Definition at line 390 of file polyn_gf2m.cpp.
References get_degree(), get_sp_field(), m_sp_field, set_coef(), sqmod(), and sqmod_init().
Referenced by polyn_gf2m().
|
static |
countermeasure against the low weight attacks for w=4, w=6 and w=8. Higher values are not covered since for w=8 we already have a probability for a positive of 1/n^3 from random ciphertexts with the given weight. For w = 10 it would be 1/n^4 and so on. Thus attacks based on such high values of w are considered impractical.
The outer test for the degree of u ( Omega in the paper ) needs not to be disguised. Each of the three is performed at most once per EEA (syndrome inversion) execution, the attacker knows this already when preparing the ciphertext with the given weight. Inside these three cases however, we must use timing neutral (branch free) operations to implement the condition detection and the counteractions.
Condition that the EEA would break now
Now come the conditions for all odd coefficients of this sigma candiate. If they are all fulfilled, then we know that we have a low weight error vector, since the key-equation solving EEA is skipped if the degree of tau^2 is low (=m_deg(u0)) and all its odd cofficients are zero (they would cause "full-length" contributions from the square root computation).
Definition at line 448 of file polyn_gf2m.cpp.
References BOTAN_ASSERT, calc_degree_secure(), coeff, Botan::expand_mask_16bit(), get_degree(), m_sp_field, patchup_deg_secure(), set_coef(), and set_to_zero().
secure_vector< uint8_t > Botan::polyn_gf2m::encode | ( | ) | const |
Definition at line 769 of file polyn_gf2m.cpp.
References coeff, Botan::get_byte(), and m_deg.
void Botan::polyn_gf2m::encode | ( | uint32_t | min_numo_coeffs, |
uint8_t * | mem, | ||
uint32_t | mem_len | ||
) | const |
Definition at line 254 of file polyn_gf2m.cpp.
References m_deg, and m_sp_field.
|
inline |
int Botan::polyn_gf2m::get_degree | ( | ) | const |
Definition at line 228 of file polyn_gf2m.cpp.
Referenced by degppf(), eea_with_coefficients(), Botan::mceliece_decrypt(), polyn_gf2m(), polyn_gf2m(), polyn_gf2m(), sqmod(), sqmod_init(), sqrt_mod_init(), Botan::syndrome_init(), and to_string().
|
inline |
|
inline |
Definition at line 86 of file polyn_gf2m.h.
References m_sp_field.
Referenced by degppf(), Botan::mceliece_decrypt(), sqmod_init(), and sqrt_mod_init().
|
inline |
Definition at line 66 of file polyn_gf2m.h.
|
default |
|
inline |
Definition at line 73 of file polyn_gf2m.h.
References swap().
bool Botan::polyn_gf2m::operator== | ( | const polyn_gf2m & | other | ) | const |
|
inline |
|
inline |
void Botan::polyn_gf2m::patchup_deg_secure | ( | uint32_t | trgt_deg, |
volatile gf2m | patch_elem | ||
) |
Definition at line 429 of file polyn_gf2m.cpp.
References calc_degree_secure(), and Botan::expand_mask_16bit().
Referenced by eea_with_coefficients().
|
inline |
Definition at line 97 of file polyn_gf2m.h.
References coeff.
Referenced by degppf(), eea_with_coefficients(), polyn_gf2m(), sqmod(), sqmod_init(), and sqrt_mod_init().
void Botan::polyn_gf2m::set_to_zero | ( | ) |
Definition at line 222 of file polyn_gf2m.cpp.
References Botan::clear_mem(), coeff, and m_deg.
Referenced by eea_with_coefficients().
polyn_gf2m Botan::polyn_gf2m::sqmod | ( | const std::vector< polyn_gf2m > & | sq, |
int | d | ||
) |
Definition at line 323 of file polyn_gf2m.cpp.
References get_degree(), m_sp_field, and set_coef().
Referenced by degppf(), and sqrt_mod_init().
|
static |
Definition at line 289 of file polyn_gf2m.cpp.
References Botan::clear_mem(), coeff, Botan::copy_mem(), get_degree(), get_sp_field(), m_deg, polyn_gf2m(), and set_coef().
Referenced by degppf(), and sqrt_mod_init().
|
static |
Definition at line 676 of file polyn_gf2m.cpp.
References get_degree(), get_sp_field(), m_sp_field, polyn_gf2m(), set_coef(), sqmod(), and sqmod_init().
Referenced by Botan::generate_mceliece_key().
void Botan::polyn_gf2m::swap | ( | polyn_gf2m & | other | ) |
Definition at line 790 of file polyn_gf2m.cpp.
References coeff, m_deg, and m_sp_field.
Referenced by operator=(), and polyn_gf2m().
std::string Botan::polyn_gf2m::to_string | ( | ) | const |
Definition at line 104 of file polyn_gf2m.cpp.
References coeff, and get_degree().
secure_vector<gf2m> Botan::polyn_gf2m::coeff |
Definition at line 156 of file polyn_gf2m.h.
Referenced by add_to_coef(), calc_degree_secure(), eea_with_coefficients(), encode(), get_coef(), get_degree(), get_lead_coef(), operator==(), operator[](), operator[](), polyn_gf2m(), polyn_gf2m(), polyn_gf2m(), set_coef(), set_to_zero(), sqmod_init(), swap(), and to_string().
int Botan::polyn_gf2m::m_deg |
Definition at line 153 of file polyn_gf2m.h.
Referenced by calc_degree_secure(), encode(), eval(), get_degree(), get_lead_coef(), operator==(), polyn_gf2m(), set_to_zero(), sqmod_init(), and swap().
std::shared_ptr<GF2m_Field> Botan::polyn_gf2m::m_sp_field |
Definition at line 159 of file polyn_gf2m.h.
Referenced by degppf(), eea_with_coefficients(), eval(), get_sp_field(), polyn_gf2m(), sqmod(), sqrt_mod_init(), swap(), and Botan::syndrome_init().