Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicit types for shifts (MSVC warning fix)
Browse files Browse the repository at this point in the history
FAlbertDev committed Jan 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3502ca1 commit 1a4a5a9
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/pubkey/classic_mceliece/cmce_field_ordering.cpp
Original file line number Diff line number Diff line change
@@ -278,11 +278,11 @@ secure_vector<uint16_t> Classic_McEliece_Field_Ordering::generate_control_bits_i
Classic_McEliece_Field_Ordering Classic_McEliece_Field_Ordering::create_from_control_bits(
const Classic_McEliece_Parameters& params, const secure_bitvector& control_bits) {
BOTAN_ASSERT_NOMSG(control_bits.size() == (2 * params.m() - 1) << (params.m() - 1));
uint16_t n = 1 << params.m();
uint16_t n = uint16_t(1) << params.m();
secure_vector<uint16_t> pi(n);
std::iota(pi.begin(), pi.end(), 0);
for(size_t i = 0; i < 2 * params.m() - 1; ++i) {
size_t gap = 1 << std::min(i, 2 * params.m() - 2 - i);
size_t gap = size_t(1) << std::min(i, 2 * params.m() - 2 - i);
for(size_t j = 0; j < n / 2; ++j) {
size_t pos = (j % gap) + 2 * gap * (j / gap);
auto mask = CT::Mask<uint16_t>::expand(control_bits[i * n / 2 + j]);
2 changes: 1 addition & 1 deletion src/lib/pubkey/classic_mceliece/cmce_gf.cpp
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ Classic_McEliece_GF Classic_McEliece_GF::square() const {
}

Classic_McEliece_GF Classic_McEliece_GF::inv() const {
size_t exponent = (1 << log_q()) - 2; // This is public information
size_t exponent = (size_t(1) << log_q()) - 2; // This is public information
Classic_McEliece_GF base = *this;

Classic_McEliece_GF result = {1, m_modulus};
2 changes: 1 addition & 1 deletion src/lib/pubkey/classic_mceliece/cmce_matrix.cpp
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ std::vector<secure_bitvector> init_matrix_with_alphas(const Classic_McEliece_Par
for(size_t i = 0; i < params.t(); ++i) {
for(size_t j = 0; j < params.n(); ++j) {
for(size_t alpha_i_j_bit = 0; alpha_i_j_bit < params.m(); ++alpha_i_j_bit) {
mat.at(i * params.m() + alpha_i_j_bit).at(j) = (1 << alpha_i_j_bit) & inv_g_of_alpha.at(j).elem();
mat.at(i * params.m() + alpha_i_j_bit).at(j) = (uint16_t(1) << alpha_i_j_bit) & inv_g_of_alpha.at(j).elem();
}
}
// Update for the next i so that:
2 changes: 1 addition & 1 deletion src/lib/pubkey/classic_mceliece/cmce_parameters.h
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ class BOTAN_TEST_API Classic_McEliece_Parameters final {
/**
* @brief The length of the byte representation of the field ordering's control bits. See ISO 9.2.12.
*/
size_t sk_alpha_control_bytes() const { return (2 * m() - 1) * (1 << (m() - 4)); }
size_t sk_alpha_control_bytes() const { return (2 * m() - 1) * (size_t(1) << (m() - 4)); }

/**
* @brief The byte length of the seed s. s is used for implicit rejection. See ISO 9.2.12.

0 comments on commit 1a4a5a9

Please sign in to comment.