Skip to content

Commit

Permalink
Applied review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
FAlbertDev committed Oct 29, 2024
1 parent c2caebb commit 97cc674
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/lib/pubkey/classic_mceliece/cmce.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Classic_McEliece_PrivateKeyInternal;
* - Relatively slow key generation
* - Algorithm is complex and hard to implement side-channel resistant
*/
class BOTAN_PUBLIC_API(3, 4) Classic_McEliece_PublicKey : public virtual Public_Key {
class BOTAN_PUBLIC_API(3, 7) Classic_McEliece_PublicKey : public virtual Public_Key {
public:
/**
* @brief Load a Classic McEliece public key from bytes.
Expand Down Expand Up @@ -95,7 +95,7 @@ class BOTAN_PUBLIC_API(3, 4) Classic_McEliece_PublicKey : public virtual Public_
BOTAN_DIAGNOSTIC_PUSH
BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE

class BOTAN_PUBLIC_API(3, 4) Classic_McEliece_PrivateKey final : public virtual Classic_McEliece_PublicKey,
class BOTAN_PUBLIC_API(3, 7) Classic_McEliece_PrivateKey final : public virtual Classic_McEliece_PublicKey,
public virtual Private_Key {
public:
/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/classic_mceliece/cmce_decaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Classic_McEliece_Polynomial Classic_McEliece_Decryptor::compute_goppa_syndrome(
auto g_alpha = goppa_poly(alphas[i]);
auto r = (g_alpha * g_alpha).inv();

auto c_mask = GF_Mask(CT::Mask<uint16_t>::expand(code_word.at(i)));
auto c_mask = GF_Mask::expand(static_cast<bool>(code_word.at(i)));

for(size_t j = 0; j < 2 * params.t(); ++j) {
syndrome[j] += c_mask.if_set_return(r);
Expand Down
15 changes: 6 additions & 9 deletions src/lib/pubkey/classic_mceliece/cmce_gf.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ class BOTAN_TEST_API Classic_McEliece_GF {
return *this;
}

/**
* @brief XOR assign a GF_Elem to the element of this. Constant time.
*/
Classic_McEliece_GF& operator^=(CmceGfElem other) {
m_elem ^= other;
return *this;
}

/**
* @brief Multiply the element by @p other in GF(q). Constant time.
*/
Expand Down Expand Up @@ -160,7 +152,12 @@ class BOTAN_TEST_API Classic_McEliece_GF {
*/
class BOTAN_TEST_API GF_Mask final {
public:
static GF_Mask expand(Classic_McEliece_GF v) { return GF_Mask(CT::Mask<uint16_t>::expand(v.elem().get())); }
template <std::unsigned_integral T>
static GF_Mask expand(T v) {
return GF_Mask(CT::Mask<uint16_t>::expand(v));
}

static GF_Mask expand(Classic_McEliece_GF v) { return expand(v.elem().get()); }

static GF_Mask is_zero(Classic_McEliece_GF v) { return GF_Mask(CT::Mask<uint16_t>::is_zero(v.elem().get())); }

Expand Down
4 changes: 1 addition & 3 deletions src/tests/test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,9 +863,7 @@ class BitOps_Tests final : public Test {

template <typename T>
auto random_pc(Test::Result& result) {
std::array<uint8_t, sizeof(T)> buf;
Test::rng().randomize(buf);
auto n = Botan::load_le<T>(buf);
auto n = Botan::load_le<T>(Test::rng().random_array<sizeof(T)>());
result.test_is_eq<size_t>(Botan::fmt("popcount({}) == {}", n, std::popcount(n)), pc(n), std::popcount(n));
}

Expand Down

0 comments on commit 97cc674

Please sign in to comment.