Botan
2.6.0
Crypto and TLS for C++11
|
#include <polyn_gf2m.h>
Public Member Functions | |
void | add_to_coef (uint32_t i, gf2m v) |
int | calc_degree_secure () const |
void | degppf (const polyn_gf2m &g, int *p_result) |
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 (uint32_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 (std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m () | |
polyn_gf2m (const secure_vector< uint8_t > &encoded, std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m (polyn_gf2m &&other) | |
polyn_gf2m (int d, std::shared_ptr< GF2m_Field > sp_field) | |
polyn_gf2m (polyn_gf2m const &other) | |
polyn_gf2m (int t, RandomNumberGenerator &rng, 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 degree, const unsigned char *mem, uint32_t mem_byte_len, std::shared_ptr< GF2m_Field > sp_field) | |
void | set_coef (uint32_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 > | msp_field |
Definition at line 23 of file polyn_gf2m.h.
|
explicit |
|
inline |
Botan::polyn_gf2m::polyn_gf2m | ( | const secure_vector< uint8_t > & | encoded, |
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
|
inline |
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 | ( | int | t, |
Botan::RandomNumberGenerator & | rng, | ||
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
create zero polynomial with allocated size determined by specified degree d: random irreducible polynomial of degree t
Definition at line 641 of file polyn_gf2m.cpp.
References degppf(), and Botan::random_code_element().
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 unsigned char * | mem, | ||
uint32_t | mem_byte_len, | ||
std::shared_ptr< GF2m_Field > | sp_field | ||
) |
create a polynomial from memory area (encoded)
Definition at line 159 of file polyn_gf2m.cpp.
References coeff, get_degree(), and msp_field.
|
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().
void Botan::polyn_gf2m::degppf | ( | const polyn_gf2m & | g, |
int * | p_result | ||
) |
Definition at line 392 of file polyn_gf2m.cpp.
References get_degree(), get_sp_field(), msp_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 450 of file polyn_gf2m.cpp.
References BOTAN_ASSERT, calc_degree_secure(), coeff, Botan::expand_mask_16bit(), get_degree(), msp_field, patchup_deg_secure(), set_coef(), and set_to_zero().
secure_vector< uint8_t > Botan::polyn_gf2m::encode | ( | ) | const |
Definition at line 770 of file polyn_gf2m.cpp.
Referenced by Botan::McEliece_PrivateKey::private_key_bits().
void Botan::polyn_gf2m::encode | ( | uint32_t | min_numo_coeffs, |
uint8_t * | mem, | ||
uint32_t | mem_len | ||
) | const |
|
inline |
int Botan::polyn_gf2m::get_degree | ( | ) | const |
Definition at line 230 of file polyn_gf2m.cpp.
Referenced by degppf(), eea_with_coefficients(), Botan::mceliece_decrypt(), Botan::McEliece_PrivateKey::McEliece_PrivateKey(), polyn_gf2m(), sqmod(), sqmod_init(), sqrt_mod_init(), Botan::syndrome_init(), and to_string().
|
inline |
Definition at line 81 of file polyn_gf2m.h.
|
inline |
Definition at line 74 of file polyn_gf2m.h.
References msp_field.
Referenced by degppf(), Botan::mceliece_decrypt(), sqmod_init(), and sqrt_mod_init().
|
inline |
Definition at line 40 of file polyn_gf2m.h.
|
default |
|
inline |
bool Botan::polyn_gf2m::operator== | ( | const polyn_gf2m & | other | ) | const |
Definition at line 798 of file polyn_gf2m.cpp.
|
inline |
|
inline |
void Botan::polyn_gf2m::patchup_deg_secure | ( | uint32_t | trgt_deg, |
volatile gf2m | patch_elem | ||
) |
Definition at line 431 of file polyn_gf2m.cpp.
References calc_degree_secure(), and Botan::expand_mask_16bit().
Referenced by eea_with_coefficients().
|
inline |
Definition at line 85 of file polyn_gf2m.h.
References coeff.
Referenced by degppf(), eea_with_coefficients(), sqmod(), sqmod_init(), and sqrt_mod_init().
void Botan::polyn_gf2m::set_to_zero | ( | ) |
Definition at line 224 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 325 of file polyn_gf2m.cpp.
References get_degree(), msp_field, and set_coef().
Referenced by degppf(), and sqrt_mod_init().
|
static |
Definition at line 291 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 677 of file polyn_gf2m.cpp.
References get_degree(), get_sp_field(), msp_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 791 of file polyn_gf2m.cpp.
References coeff, m_deg, and msp_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, get_degree(), and Botan::ASN1::to_string().
secure_vector<gf2m> Botan::polyn_gf2m::coeff |
Definition at line 152 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[](), polyn_gf2m(), set_coef(), set_to_zero(), sqmod_init(), swap(), and to_string().
int Botan::polyn_gf2m::m_deg |
Definition at line 149 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::msp_field |
Definition at line 155 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().