Skip to content

Commit

Permalink
Various small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FAlbertDev committed Jan 10, 2024
1 parent 4efc88a commit 4b0d025
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 36 deletions.
8 changes: 1 addition & 7 deletions src/lib/pubkey/classic_mceliece/cmce_encaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
namespace Botan {

/**
* @brief Classic McEliece Encapsulation Operation
* Classic McEliece Encapsulation Operation
*/
class BOTAN_TEST_API Classic_McEliece_Encryptor final : public PK_Ops::KEM_Encryption {
public:
Expand All @@ -49,11 +48,6 @@ class BOTAN_TEST_API Classic_McEliece_Encryptor final : public PK_Ops::KEM_Encry

/**
* @brief Encodes an error vector by multiplying it with the Classic McEliece matrix.
*
* @param params
* @param e
* @param mat
* @return bitvector
*/
bitvector encode(const Classic_McEliece_Parameters& params,
const secure_bitvector& e,
Expand Down
20 changes: 8 additions & 12 deletions src/lib/pubkey/classic_mceliece/cmce_gf.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ class BOTAN_TEST_API Classic_McEliece_GF {
static size_t log_q_from_mod(uint16_t modulus) { return high_bit(modulus) - 1; }

/**
* @brief Get m.
* @brief Get m, the degree of the element's modulus.
*
* For a given irreducible polynomial @p modulus f(z) representing the modulus of a finite field GF(q) = GF(2^m),
* get the degree log_q of f(z) which corresponds to m.
*
* @param modulus The modulus of GF(q).
* @return size_t The degree log_q of the modulus (m for GF(2^m)).
*/
size_t log_q() const { return log_q_from_mod(m_modulus); }
Expand All @@ -81,25 +77,25 @@ class BOTAN_TEST_API Classic_McEliece_GF {
uint16_t modulus() const { return m_modulus; }

/**
* @brief Change the element to @param elem.
* @brief Change the element to @p elem.
*/
Classic_McEliece_GF& operator=(const uint16_t elem) {
m_elem = elem & ((size_t(1) << log_q()) - 1);
return *this;
}

/**
* @brief Divide the element by @param other in GF(q). Constant time.
* @brief Divide the element by @p other in GF(q). Constant time.
*/
Classic_McEliece_GF operator/(const Classic_McEliece_GF& other) const;

/**
* @brief Add @param other to the element. Constant time.
* @brief Add @p other to the element. Constant time.
*/
Classic_McEliece_GF operator+(const Classic_McEliece_GF& other) const;

/**
* @brief Add @param other to the element. Constant time.
* @brief Add @p other to the element. Constant time.
*/
Classic_McEliece_GF& operator+=(const Classic_McEliece_GF& other);

Expand All @@ -109,17 +105,17 @@ class BOTAN_TEST_API Classic_McEliece_GF {
Classic_McEliece_GF& operator^=(uint16_t other);

/**
* @brief Multiply the element by @param other in GF(q). Constant time.
* @brief Multiply the element by @p other in GF(q). Constant time.
*/
Classic_McEliece_GF& operator*=(const Classic_McEliece_GF& other);

/**
* @brief Multiply the element by @param other in GF(q). Constant time.
* @brief Multiply the element by @p other in GF(q). Constant time.
*/
Classic_McEliece_GF operator*(const Classic_McEliece_GF& other) const;

/**
* @brief Check if the element is equal to @param other. Modulus is ignored.
* @brief Check if the element is equal to @p other. Modulus is ignored.
*/
bool operator==(const Classic_McEliece_GF& other) const { return elem() == other.elem(); }

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/classic_mceliece/cmce_keys_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class BOTAN_TEST_API Classic_McEliece_PrivateKeyInternal {
/**
* @brief Parses a Classic McEliece private key from a byte sequence.
*
* It also creates the field ordering from the control bits in @param sk_bytes.
* It also creates the field ordering from the control bits in @p sk_bytes.
*
* @param params The Classic McEliece parameters
* @param sk_bytes The secret key byte sequence
Expand Down
36 changes: 20 additions & 16 deletions src/tests/test_cmce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@
#include "test_rng.h"
#include "tests.h"

#include <botan/cmce.h>
#include <botan/hash.h>
#include <botan/pk_algs.h>
#include <botan/pubkey.h>
#include <botan/internal/cmce_debug_utils.h>
#include <botan/internal/cmce_decaps.h>
#include <botan/internal/cmce_encaps.h>
#include <botan/internal/cmce_field_ordering.h>
#include <botan/internal/cmce_gf.h>
#include <botan/internal/cmce_keys_internal.h>
#include <botan/internal/cmce_parameters.h>
#include <botan/internal/cmce_poly.h>

#include <iostream>
#if defined(BOTAN_HAS_CLASSICMCELIECE)

#include <botan/cmce.h>
#include <botan/hash.h>
#include <botan/pk_algs.h>
#include <botan/pubkey.h>
#include <botan/internal/cmce_debug_utils.h>
#include <botan/internal/cmce_decaps.h>
#include <botan/internal/cmce_encaps.h>
#include <botan/internal/cmce_field_ordering.h>
#include <botan/internal/cmce_gf.h>
#include <botan/internal/cmce_keys_internal.h>
#include <botan/internal/cmce_parameters.h>
#include <botan/internal/cmce_poly.h>

#include <iostream>

namespace Botan_Tests {

Expand Down Expand Up @@ -302,7 +304,7 @@ class CMCE_Invalid_Test : public Text_Based_Test {
}
};

#if false
#if false
class CMCE_Decaps_Unit_Test final : public Text_Based_Test {
private:
std::vector<Botan::Classic_McEliece_GF> gf_vector_from_bytes(const Botan::Classic_McEliece_Parameters& params,
Expand Down Expand Up @@ -381,7 +383,7 @@ class CMCE_Decaps_Unit_Test final : public Text_Based_Test {
return result;
}
};
#endif
#endif

class CMCE_Generic_Keygen_Tests final : public PK_Key_Generation_Test {
public:
Expand Down Expand Up @@ -482,3 +484,5 @@ BOTAN_REGISTER_TEST("cmce", "cmce_invalid", CMCE_Invalid_Test);
BOTAN_REGISTER_TEST("cmce", "cmce_minimal", CMCE_Minimal_Test);

} // namespace Botan_Tests

#endif // BOTAN_HAS_CLASSICMCELIECE

0 comments on commit 4b0d025

Please sign in to comment.