Botan 3.6.1
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) noexcept |
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 polyn_gf2m &other) | |
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) noexcept | |
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) noexcept |
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 130 of file polyn_gf2m.cpp.
|
inline |
Botan::polyn_gf2m::polyn_gf2m | ( | const secure_vector< uint8_t > & | encoded, |
const std::shared_ptr< GF2m_Field > & | sp_field ) |
Definition at line 635 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 99 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 538 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 109 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 132 of file polyn_gf2m.cpp.
|
inlinenoexcept |
|
inline |
Definition at line 88 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 58 of file polyn_gf2m.cpp.
References Botan::expand_mask_16bit().
Referenced by eea_with_coefficients().
|
static |
Definition at line 310 of file polyn_gf2m.cpp.
References get_degree(), get_sp_field(), and sqmod().
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 362 of file polyn_gf2m.cpp.
References BOTAN_ASSERT, calc_degree_secure(), Botan::expand_mask_16bit(), get_degree(), patchup_deg_secure(), and set_to_zero().
secure_vector< uint8_t > Botan::polyn_gf2m::encode | ( | ) | const |
Definition at line 647 of file polyn_gf2m.cpp.
References Botan::get_byte().
void Botan::polyn_gf2m::encode | ( | uint32_t | min_numo_coeffs, |
uint8_t * | mem, | ||
uint32_t | mem_len ) const |
Definition at line 195 of file polyn_gf2m.cpp.
|
inline |
Definition at line 84 of file polyn_gf2m.h.
int Botan::polyn_gf2m::get_degree | ( | ) | const |
Definition at line 169 of file polyn_gf2m.cpp.
Referenced by degppf(), eea_with_coefficients(), Botan::mceliece_decrypt(), polyn_gf2m(), polyn_gf2m(), sqmod(), sqmod_init(), sqrt_mod_init(), and Botan::syndrome_init().
|
inline |
Definition at line 82 of file polyn_gf2m.h.
|
inline |
Definition at line 76 of file polyn_gf2m.h.
Referenced by degppf(), Botan::mceliece_decrypt(), sqmod_init(), sqrt_mod_init(), and Botan::syndrome_init().
|
inline |
Definition at line 61 of file polyn_gf2m.h.
|
default |
|
inlinenoexcept |
Definition at line 65 of file polyn_gf2m.h.
References swap().
bool Botan::polyn_gf2m::operator== | ( | const polyn_gf2m & | other | ) | const |
Definition at line 671 of file polyn_gf2m.cpp.
|
inline |
Definition at line 78 of file polyn_gf2m.h.
|
inline |
Definition at line 80 of file polyn_gf2m.h.
void Botan::polyn_gf2m::patchup_deg_secure | ( | uint32_t | trgt_deg, |
gf2m | patch_elem ) |
Definition at line 345 of file polyn_gf2m.cpp.
References Botan::expand_mask_16bit().
Referenced by eea_with_coefficients().
|
inline |
Definition at line 86 of file polyn_gf2m.h.
Referenced by polyn_gf2m(), and sqrt_mod_init().
void Botan::polyn_gf2m::set_to_zero | ( | ) |
Definition at line 164 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 258 of file polyn_gf2m.cpp.
References get_degree().
Referenced by degppf(), and sqrt_mod_init().
|
static |
Definition at line 227 of file polyn_gf2m.cpp.
References Botan::clear_mem(), Botan::copy_mem(), get_degree(), and get_sp_field().
Referenced by sqrt_mod_init().
|
static |
Definition at line 568 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().
|
noexcept |
Definition at line 665 of file polyn_gf2m.cpp.
Referenced by operator=(), and polyn_gf2m().