diff options
author | Jack Lloyd <[email protected]> | 2019-06-29 18:15:33 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-06-29 18:15:33 -0400 |
commit | 5b435d11d32046062f23c0b69495631f5455ef6b (patch) | |
tree | 2361fe3c901bf83f20469ca80e208aae0ac75fe3 /src/lib/pubkey | |
parent | 692ca2118f77ad1c035e05ee495e3a21a9a99cbc (diff) | |
parent | 8b8745236368c70a82db2b19feeed5e9f9b59c5b (diff) |
Merge GH #2010 Fix MSVC warnings
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r-- | src/lib/pubkey/mce/code_based_key_gen.cpp | 14 | ||||
-rw-r--r-- | src/lib/pubkey/mce/code_based_util.h | 4 | ||||
-rw-r--r-- | src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp | 4 | ||||
-rw-r--r-- | src/lib/pubkey/mce/gf2m_small_m.cpp | 7 | ||||
-rw-r--r-- | src/lib/pubkey/mce/goppa_code.cpp | 4 | ||||
-rw-r--r-- | src/lib/pubkey/mce/mceliece_key.cpp | 20 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_signature.h | 2 |
7 files changed, 27 insertions, 28 deletions
diff --git a/src/lib/pubkey/mce/code_based_key_gen.cpp b/src/lib/pubkey/mce/code_based_key_gen.cpp index 97414418d..dad06f0c0 100644 --- a/src/lib/pubkey/mce/code_based_key_gen.cpp +++ b/src/lib/pubkey/mce/code_based_key_gen.cpp @@ -253,18 +253,18 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, uint32_t // speed up the syndrome computation) // // - std::vector<uint32_t> H(bit_size_to_32bit_size(codimension) * code_length ); + std::vector<uint32_t> H(bit_size_to_32bit_size(codimension) * code_length); uint32_t* sk = H.data(); for(size_t i = 0; i < code_length; ++i) { for(size_t l = 0; l < t; ++l) { - const uint32_t k = (l * ext_deg) / 32; - const uint32_t j = (l * ext_deg) % 32; + const size_t k = (l * ext_deg) / 32; + const size_t j = (l * ext_deg) % 32; sk[k] ^= static_cast<uint32_t>(F[i].get_coef(l)) << j; - if (j + ext_deg > 32) + if(j + ext_deg > 32) { - sk[k + 1] ^= F[i].get_coef( l) >> (32 - j); + sk[k + 1] ^= F[i].get_coef(l) >> (32 - j); } } sk += bit_size_to_32bit_size(codimension); @@ -274,9 +274,9 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, uint32_t // inverse is needed std::vector<gf2m> Linv(code_length) ; - for (size_t i = 0; i != Linv.size(); ++i) + for(size_t i = 0; i != Linv.size(); ++i) { - Linv[L[i]] = i; + Linv[L[i]] = static_cast<gf2m>(i); } std::vector<uint8_t> pubmat (R->m_elem.size() * 4); for(size_t i = 0; i < R->m_elem.size(); i++) diff --git a/src/lib/pubkey/mce/code_based_util.h b/src/lib/pubkey/mce/code_based_util.h index 3812f4a40..291954a45 100644 --- a/src/lib/pubkey/mce/code_based_util.h +++ b/src/lib/pubkey/mce/code_based_util.h @@ -42,12 +42,12 @@ inline gf2m lex_to_gray(gf2m lex) return (lex >> 1) ^ lex; } -inline uint32_t bit_size_to_byte_size(uint32_t bit_size) +inline size_t bit_size_to_byte_size(uint32_t bit_size) { return (bit_size - 1) / 8 + 1; } -inline uint32_t bit_size_to_32bit_size(uint32_t bit_size) +inline size_t bit_size_to_32bit_size(uint32_t bit_size) { return (bit_size - 1) / 32 + 1; } diff --git a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp index 1d35447fa..2c0f32194 100644 --- a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp +++ b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp @@ -19,15 +19,13 @@ uint32_t patch_root_array(gf2m* res_root_arr, uint32_t res_root_arr_len, uint32_t root_pos) { - volatile uint32_t i; volatile gf2m patch_elem = 0x01; volatile gf2m cond_mask = (root_pos == res_root_arr_len); cond_mask = expand_mask_16bit(cond_mask); cond_mask = ~cond_mask; /* now cond = 1 if not enough roots */ patch_elem &= cond_mask; - for(i = 0; i < res_root_arr_len; i++) + for(size_t i = 0; i < res_root_arr_len; i++) { - gf2m masked_patch_elem = (patch_elem++) & cond_mask; res_root_arr[i] ^= masked_patch_elem++; } diff --git a/src/lib/pubkey/mce/gf2m_small_m.cpp b/src/lib/pubkey/mce/gf2m_small_m.cpp index ffa593b66..47b4c34ae 100644 --- a/src/lib/pubkey/mce/gf2m_small_m.cpp +++ b/src/lib/pubkey/mce/gf2m_small_m.cpp @@ -18,7 +18,7 @@ namespace Botan { namespace { -unsigned int prim_poly[MAX_EXT_DEG + 1] = { +gf2m prim_poly[MAX_EXT_DEG + 1] = { 01, /* extension degree 0 (!) never used */ 03, /* extension degree 1 (!) never used */ 07, /* extension degree 2 */ @@ -35,7 +35,6 @@ unsigned int prim_poly[MAX_EXT_DEG + 1] = { 020033, /* extension degree 13 */ 042103, /* extension degree 14 */ 0100003, /* extension degree 15 */ - 0210013 /* extension degree 16 */ }; std::vector<gf2m> gf_exp_table(size_t deg, gf2m prime_poly) @@ -72,9 +71,9 @@ std::vector<gf2m> gf_log_table(size_t deg, const std::vector<gf2m>& exp) std::vector<gf2m> tab(1 << deg); tab[0] = (1 << deg) - 1; // log of 0 is the order by convention - for (size_t i = 0; i < tab.size(); ++i) + for(size_t i = 0; i < tab.size(); ++i) { - tab[exp[i]] = i; + tab[exp[i]] = static_cast<gf2m>(i); } return tab; } diff --git a/src/lib/pubkey/mce/goppa_code.cpp b/src/lib/pubkey/mce/goppa_code.cpp index 8183dd1d4..a1c493a13 100644 --- a/src/lib/pubkey/mce/goppa_code.cpp +++ b/src/lib/pubkey/mce/goppa_code.cpp @@ -117,7 +117,7 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn, /// XXX double assignment, possible bug? if(tmp >= code_length) /* invalid root */ { - result[i] = i; + result[i] = static_cast<gf2m>(i); } result[i] = Linv[tmp]; } @@ -197,7 +197,7 @@ secure_vector<uint8_t> mceliece_decrypt( uint32_t syndrome_byte_vec_size = syndrome_byte_vec.size(); for(uint32_t i = 0; i < syndrome_byte_vec_size; i++) { - syndrome_byte_vec[i] = syndrome_vec[i/4] >> (8* (i % 4)); + syndrome_byte_vec[i] = static_cast<uint8_t>(syndrome_vec[i/4] >> (8* (i % 4))); } syndrome_polyn = polyn_gf2m(t-1, syndrome_byte_vec.data(), bit_size_to_byte_size(codimension), key.get_goppa_polyn().get_sp_field()); diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp index 09c4c3f31..433e65171 100644 --- a/src/lib/pubkey/mce/mceliece_key.cpp +++ b/src/lib/pubkey/mce/mceliece_key.cpp @@ -15,6 +15,7 @@ #include <botan/internal/bit_ops.h> #include <botan/internal/code_based_util.h> #include <botan/internal/pk_ops_impl.h> +#include <botan/loadstor.h> #include <botan/der_enc.h> #include <botan/ber_dec.h> #include <botan/rng.h> @@ -121,25 +122,26 @@ secure_vector<uint8_t> McEliece_PrivateKey::private_key_bits() const .encode(m_public_matrix, OCTET_STRING) .encode(m_g.encode(), OCTET_STRING); // g as octet string enc.start_cons(SEQUENCE); - for(uint32_t i = 0; i < m_sqrtmod.size(); i++) + for(size_t i = 0; i < m_sqrtmod.size(); i++) { enc.encode(m_sqrtmod[i].encode(), OCTET_STRING); } enc.end_cons(); secure_vector<uint8_t> enc_support; - for(uint32_t i = 0; i < m_Linv.size(); i++) + + for(uint16_t Linv : m_Linv) { - enc_support.push_back(m_Linv[i] >> 8); - enc_support.push_back(m_Linv[i]); + enc_support.push_back(get_byte(0, Linv)); + enc_support.push_back(get_byte(1, Linv)); } enc.encode(enc_support, OCTET_STRING); secure_vector<uint8_t> enc_H; - for(uint32_t i = 0; i < m_coeffs.size(); i++) + for(uint32_t coef : m_coeffs) { - enc_H.push_back(m_coeffs[i] >> 24); - enc_H.push_back(m_coeffs[i] >> 16); - enc_H.push_back(m_coeffs[i] >> 8); - enc_H.push_back(m_coeffs[i]); + enc_H.push_back(get_byte(0, coef)); + enc_H.push_back(get_byte(1, coef)); + enc_H.push_back(get_byte(2, coef)); + enc_H.push_back(get_byte(3, coef)); } enc.encode(enc_H, OCTET_STRING); enc.end_cons(); diff --git a/src/lib/pubkey/xmss/xmss_signature.h b/src/lib/pubkey/xmss/xmss_signature.h index 25e168fd8..838aae2e8 100644 --- a/src/lib/pubkey/xmss/xmss_signature.h +++ b/src/lib/pubkey/xmss/xmss_signature.h @@ -117,7 +117,7 @@ class XMSS_Signature final secure_vector<uint8_t> bytes() const; private: - uint64_t m_leaf_idx; + size_t m_leaf_idx; secure_vector<uint8_t> m_randomness; XMSS_WOTS_PublicKey::TreeSignature m_tree_sig; }; |