Botan 3.0.0
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 |
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, gf2m patch_elem) |
polyn_gf2m () | |
polyn_gf2m (const secure_vector< uint8_t > &encoded, const std::shared_ptr< GF2m_Field > &sp_field) | |
polyn_gf2m (const std::shared_ptr< GF2m_Field > &sp_field) | |
polyn_gf2m (const uint8_t *mem, uint32_t mem_len, const std::shared_ptr< GF2m_Field > &sp_field) | |
polyn_gf2m (int d, const std::shared_ptr< GF2m_Field > &sp_field) | |
polyn_gf2m (int degree, const uint8_t *mem, size_t mem_byte_len, const 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, const 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) |
Static Public Member Functions | |
static size_t | degppf (const polyn_gf2m &g) |
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) |
Definition at line 26 of file polyn_gf2m.h.
|
explicit |
create a zero polynomial:
Definition at line 135 of file polyn_gf2m.cpp.
|
inline |
Definition at line 34 of file polyn_gf2m.h.
Referenced by sqmod_init(), and sqrt_mod_init().
Botan::polyn_gf2m::polyn_gf2m | ( | const secure_vector< uint8_t > & | encoded, |
const std::shared_ptr< GF2m_Field > & | sp_field | ||
) |
Definition at line 705 of file polyn_gf2m.cpp.
References get_degree().
Botan::polyn_gf2m::polyn_gf2m | ( | int | d, |
const std::shared_ptr< GF2m_Field > & | sp_field | ||
) |
create zero polynomial with reservation of space for a degree d polynomial
Definition at line 93 of file polyn_gf2m.cpp.
|
default |
Botan::polyn_gf2m::polyn_gf2m | ( | size_t | t, |
RandomNumberGenerator & | rng, | ||
const std::shared_ptr< GF2m_Field > & | sp_field | ||
) |
random irreducible polynomial of degree t
Definition at line 590 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, | ||
const std::shared_ptr< GF2m_Field > & | sp_field | ||
) |
decode a polynomial from memory:
Definition at line 108 of file polyn_gf2m.cpp.
References Botan::decode_gf2m(), and get_degree().
Botan::polyn_gf2m::polyn_gf2m | ( | int | degree, |
const uint8_t * | mem, | ||
size_t | mem_byte_len, | ||
const std::shared_ptr< GF2m_Field > & | sp_field | ||
) |
create a polynomial from memory area (encoded)
Definition at line 139 of file polyn_gf2m.cpp.
References get_degree().
|
inline |
|
inline |
Definition at line 101 of file polyn_gf2m.h.
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 Botan::expand_mask_16bit().
Referenced by eea_with_coefficients(), and patchup_deg_secure().
|
static |
Definition at line 341 of file polyn_gf2m.cpp.
References get_degree(), get_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 399 of file polyn_gf2m.cpp.
References BOTAN_ASSERT, calc_degree_secure(), Botan::expand_mask_16bit(), get_degree(), patchup_deg_secure(), set_coef(), and set_to_zero().
secure_vector< uint8_t > Botan::polyn_gf2m::encode | ( | ) | const |
Definition at line 721 of file polyn_gf2m.cpp.
void Botan::polyn_gf2m::encode | ( | uint32_t | min_numo_coeffs, |
uint8_t * | mem, | ||
uint32_t | mem_len | ||
) | const |
Definition at line 205 of file polyn_gf2m.cpp.
|
inline |
Definition at line 94 of file polyn_gf2m.h.
int Botan::polyn_gf2m::get_degree | ( | ) | const |
Definition at line 179 of file polyn_gf2m.cpp.
Referenced by degppf(), eea_with_coefficients(), Botan::mceliece_decrypt(), polyn_gf2m(), sqmod(), sqmod_init(), sqrt_mod_init(), and Botan::syndrome_init().
|
inline |
Definition at line 92 of file polyn_gf2m.h.
|
inline |
Definition at line 85 of file polyn_gf2m.h.
Referenced by degppf(), Botan::mceliece_decrypt(), sqmod_init(), sqrt_mod_init(), and Botan::syndrome_init().
|
inline |
Definition at line 65 of file polyn_gf2m.h.
|
default |
|
inline |
Definition at line 72 of file polyn_gf2m.h.
References swap().
bool Botan::polyn_gf2m::operator== | ( | const polyn_gf2m & | other | ) | const |
Definition at line 749 of file polyn_gf2m.cpp.
|
inline |
Definition at line 88 of file polyn_gf2m.h.
|
inline |
Definition at line 90 of file polyn_gf2m.h.
void Botan::polyn_gf2m::patchup_deg_secure | ( | uint32_t | trgt_deg, |
gf2m | patch_elem | ||
) |
Definition at line 380 of file polyn_gf2m.cpp.
References calc_degree_secure(), and Botan::expand_mask_16bit().
Referenced by eea_with_coefficients().
|
inline |
Definition at line 96 of file polyn_gf2m.h.
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 173 of file polyn_gf2m.cpp.
References Botan::clear_mem().
Referenced by eea_with_coefficients().
polyn_gf2m Botan::polyn_gf2m::sqmod | ( | const std::vector< polyn_gf2m > & | sq, |
int | d | ||
) |
Definition at line 274 of file polyn_gf2m.cpp.
References get_degree(), and set_coef().
Referenced by degppf(), and sqrt_mod_init().
|
static |
Definition at line 240 of file polyn_gf2m.cpp.
References Botan::clear_mem(), Botan::copy_mem(), get_degree(), get_sp_field(), polyn_gf2m(), and set_coef().
Referenced by degppf(), and sqrt_mod_init().
|
static |
Definition at line 627 of file polyn_gf2m.cpp.
References get_degree(), get_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 742 of file polyn_gf2m.cpp.
Referenced by operator=(), and polyn_gf2m().