diff --git a/src/lib/pubkey/classic_mceliece/cmce_poly.cpp b/src/lib/pubkey/classic_mceliece/cmce_poly.cpp index cf718582d0..fa2a366aae 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_poly.cpp +++ b/src/lib/pubkey/classic_mceliece/cmce_poly.cpp @@ -38,7 +38,7 @@ std::vector load_le_gf_vec(std::span bytes) { } // namespace Classic_McEliece_GF Classic_McEliece_Polynomial::operator()(Classic_McEliece_GF a) const { - BOTAN_ASSERT(a.modulus() == coef_at(0).modulus(), "Unmatching Galois fields"); + BOTAN_ASSERT(a.modulus() == coef_at(0).modulus(), "Galois fields match"); Classic_McEliece_GF r(GF_Elem(0), a.modulus()); for(auto it = m_coef.rbegin(); it != m_coef.rend(); ++it) { @@ -67,7 +67,7 @@ Classic_McEliece_Polynomial Classic_McEliece_Polynomial_Ring::multiply(const Cla prod.erase(prod.begin() + m_t, prod.end()); - return Classic_McEliece_Polynomial(prod); + return Classic_McEliece_Polynomial(std::move(prod)); } Classic_McEliece_Polynomial Classic_McEliece_Polynomial_Ring::create_element_from_bytes( @@ -100,7 +100,7 @@ std::optional Classic_McEliece_Polynomial_R mat.push_back(create_element_from_coef(concat_as>( std::vector{GF_Elem(1)}, std::vector(degree() - 1, GF_Elem(0))))); - mat.emplace_back(polynomial); + mat.push_back(polynomial); for(size_t j = 2; j <= degree(); ++j) { mat.push_back(multiply(mat.at(j - 1), polynomial)); @@ -129,7 +129,7 @@ std::optional Classic_McEliece_Polynomial_R for(size_t k = 0; k < degree(); ++k) { if(k != j) { - auto t = mat.at(j).coef_at(k); + const auto t = mat.at(j).coef_at(k); for(size_t c = j; c < degree() + 1; ++c) { mat.at(c).coef_at(k) += mat.at(c).coef_at(j) * t; @@ -149,11 +149,11 @@ secure_vector Classic_McEliece_Minimal_Polynomial::serialize() const { BOTAN_ASSERT_NOMSG(!coef().empty()); auto& all_coeffs = coef(); // Store all except coef for monomial x^t since polynomial is monic (ISO Spec Section 9.2.9) - auto coeffs_to_store = std::span(all_coeffs).subspan(0, all_coeffs.size() - 1); + auto coeffs_to_store = std::span(all_coeffs).first(all_coeffs.size() - 1); secure_vector bytes(sizeof(uint16_t) * coeffs_to_store.size()); BufferStuffer bytes_stuf(bytes); for(auto& coef : coeffs_to_store) { - store_le(coef.elem().get(), bytes_stuf.next(sizeof(GF_Elem)).data()); + store_le(bytes_stuf.next(), coef.elem().get()); } BOTAN_ASSERT_NOMSG(bytes_stuf.full()); return bytes; diff --git a/src/lib/pubkey/classic_mceliece/cmce_poly.h b/src/lib/pubkey/classic_mceliece/cmce_poly.h index 4645263aed..ffd189675a 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_poly.h +++ b/src/lib/pubkey/classic_mceliece/cmce_poly.h @@ -90,14 +90,12 @@ class BOTAN_TEST_API Classic_McEliece_Minimal_Polynomial : public Classic_McElie static Classic_McEliece_Minimal_Polynomial from_bytes(std::span bytes, GF_Mod poly_f); }; -// Stores all auxiliary information and logic of FF_(q^t) via FF_q[y]/F(y) /** * @brief Represents the polynomial ring GF(q)[y]/F(y) where F(y) is the modulus polynomial in * GF(q)[y] of degree t. * * This class contains a modulus polynomial F(y) and the GF(q) modulus f(z). It is used * to create and operate with Classic_McEliece_Polynomials. - * */ class BOTAN_TEST_API Classic_McEliece_Polynomial_Ring { public: @@ -122,8 +120,8 @@ class BOTAN_TEST_API Classic_McEliece_Polynomial_Ring { * @param poly_f The modulus f(z) of GF(q). * @param t The polynomial degree of the ring (and of F(y)). */ - Classic_McEliece_Polynomial_Ring(const std::vector& poly_big_f_coef, GF_Mod poly_f, size_t t) : - m_position_map(poly_big_f_coef), m_t(t), m_poly_f(poly_f) {} + Classic_McEliece_Polynomial_Ring(std::vector poly_big_f_coef, GF_Mod poly_f, size_t t) : + m_position_map(std::move(poly_big_f_coef)), m_t(t), m_poly_f(poly_f) {} GF_Mod poly_f() const { return m_poly_f; } diff --git a/src/lib/pubkey/classic_mceliece/info.txt b/src/lib/pubkey/classic_mceliece/info.txt index c537b5e628..85472dad2f 100644 --- a/src/lib/pubkey/classic_mceliece/info.txt +++ b/src/lib/pubkey/classic_mceliece/info.txt @@ -7,7 +7,6 @@ name -> "Classic McEliece" -xof shake shake_xof diff --git a/src/lib/utils/bit_ops.h b/src/lib/utils/bit_ops.h index d3de9856a8..888192b658 100644 --- a/src/lib/utils/bit_ops.h +++ b/src/lib/utils/bit_ops.h @@ -212,7 +212,7 @@ inline constexpr T majority(T a, T b, T c) { * instruction, if available. This is the SWAR (SIMD within a register) * algorithm. See: https://nimrod.blog/posts/algorithms-behind-popcount/#swar-algorithm * - * Note: C++20 provides std::popcount(), but there's no gurantee that this + * Note: C++20 provides std::popcount(), but there's no guarantee that this * is implemented in constant-time. * * @param x an unsigned integer