diff options
author | Jack Lloyd <[email protected]> | 2016-02-09 10:11:51 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-02-09 10:11:51 -0500 |
commit | 2a045404e3a3187bd9dd5763a286b3e39d1fa47e (patch) | |
tree | 0145e98c94d4b3f5a2ada878c3987bedcacd4e48 /src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp | |
parent | 7c57af4436e765be9fc3fea37c35d452b0ecb3c9 (diff) |
Fix Coverity findings in McEliece code
Initialize variables in constructor in gf2m_decomp_rootfind_state
Add asserts on the degree where a positive value was assumed. How
polyn_gf2m handles the degree needs some work but this should do for
now.
Diffstat (limited to 'src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp')
-rw-r--r-- | src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp index 008da99c1..acae036db 100644 --- a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp +++ b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp @@ -95,7 +95,7 @@ secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, u32bit code } gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn, u32bit the_code_length) : - code_length(the_code_length) + code_length(the_code_length), m_j(0), m_j_gray(0) { gf2m coeff_3; gf2m coeff_head; @@ -105,7 +105,7 @@ gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn, { throw Internal_Error("Unexpected degree in gf2m_decomp_rootfind_state"); } - this->m_j = 0; + coeff_3 = polyn.get_coef( 3); coeff_head = polyn.get_coef( deg_sigma); /* dummy value for SCA CM */ if(coeff_3 != 0) @@ -275,7 +275,9 @@ gf2m gf2m_decomp_rootfind_state::calc_Fxj_j_neq_0( const polyn_gf2m & sigma, gf2 secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & sigma) { - secure_vector<gf2m> result(sigma.get_degree()); + const int sigma_degree = sigma.get_degree(); + BOTAN_ASSERT(sigma_degree > 0, "Valid sigma"); + secure_vector<gf2m> result(sigma_degree); u32bit root_pos = 0; this->calc_Ai_zero(sigma); |