From 63c1b8ca0047749b92a6a4f334f5e739c2e91c49 Mon Sep 17 00:00:00 2001 From: Fabian Albert Date: Wed, 10 Jan 2024 12:17:43 +0100 Subject: [PATCH] Fix shared builds --- src/lib/pubkey/classic_mceliece/cmce.cpp | 2 +- src/lib/pubkey/classic_mceliece/cmce.h | 9 +- src/lib/pubkey/classic_mceliece/cmce_decaps.h | 3 +- src/lib/pubkey/classic_mceliece/cmce_encaps.h | 5 +- .../classic_mceliece/cmce_field_ordering.cpp | 2 +- .../classic_mceliece/cmce_field_ordering.h | 2 +- src/lib/pubkey/classic_mceliece/cmce_gf.h | 2 +- .../classic_mceliece/cmce_keys_internal.h | 8 +- src/lib/pubkey/classic_mceliece/cmce_matrix.h | 2 +- .../classic_mceliece/cmce_parameter_set.cpp | 124 ++++++++++++++++++ .../classic_mceliece/cmce_parameter_set.h | 69 ++++++++++ .../classic_mceliece/cmce_parameters.cpp | 122 +---------------- .../pubkey/classic_mceliece/cmce_parameters.h | 58 +------- src/lib/pubkey/classic_mceliece/cmce_poly.h | 3 +- src/lib/pubkey/classic_mceliece/info.txt | 3 +- src/lib/pubkey/pk_algs.cpp | 2 +- src/tests/test_cmce.cpp | 2 +- 17 files changed, 220 insertions(+), 198 deletions(-) create mode 100644 src/lib/pubkey/classic_mceliece/cmce_parameter_set.cpp create mode 100644 src/lib/pubkey/classic_mceliece/cmce_parameter_set.h diff --git a/src/lib/pubkey/classic_mceliece/cmce.cpp b/src/lib/pubkey/classic_mceliece/cmce.cpp index deac0a41b8e..4ae1fb86672 100644 --- a/src/lib/pubkey/classic_mceliece/cmce.cpp +++ b/src/lib/pubkey/classic_mceliece/cmce.cpp @@ -98,7 +98,7 @@ Classic_McEliece_PrivateKey::Classic_McEliece_PrivateKey(Classic_McEliece_Parame Classic_McEliece_PrivateKey::Classic_McEliece_PrivateKey(const AlgorithmIdentifier& alg_id, std::span key_bits) : - Classic_McEliece_PrivateKey(Classic_McEliece_Parameters::param_set_from_oid(alg_id.oid()), key_bits) {} + Classic_McEliece_PrivateKey(param_set_from_oid(alg_id.oid()), key_bits) {} std::unique_ptr Classic_McEliece_PrivateKey::public_key() const { return std::make_unique(*this); diff --git a/src/lib/pubkey/classic_mceliece/cmce.h b/src/lib/pubkey/classic_mceliece/cmce.h index dcf09ac23a1..4f26795efc3 100644 --- a/src/lib/pubkey/classic_mceliece/cmce.h +++ b/src/lib/pubkey/classic_mceliece/cmce.h @@ -12,14 +12,13 @@ #include -#include -#include -#include -#include -#include +#include namespace Botan { +class Classic_McEliece_PublicKeyInternal; +class Classic_McEliece_PrivateKeyInternal; + /** * Classic McEliece is a Code-Based KEM. It is a round 4 candidate in NIST's PQC competition. * It is endorsed by the German Federal Office for Information Security for its conservative security diff --git a/src/lib/pubkey/classic_mceliece/cmce_decaps.h b/src/lib/pubkey/classic_mceliece/cmce_decaps.h index 5c6238d6b67..f3aa7406215 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_decaps.h +++ b/src/lib/pubkey/classic_mceliece/cmce_decaps.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,7 @@ namespace Botan { /** * Classic McEliece Decapsulation Operation */ -class Classic_McEliece_Decryptor final : public PK_Ops::KEM_Decryption { +class BOTAN_TEST_API Classic_McEliece_Decryptor final : public PK_Ops::KEM_Decryption { public: /** * @brief Constructs a Classic_McEliece_Decryptor object with the given private key. diff --git a/src/lib/pubkey/classic_mceliece/cmce_encaps.h b/src/lib/pubkey/classic_mceliece/cmce_encaps.h index 46ec1327fa0..4a23e5d5ae8 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_encaps.h +++ b/src/lib/pubkey/classic_mceliece/cmce_encaps.h @@ -12,9 +12,10 @@ #include #include -#include #include +#include #include +#include #include #include #include @@ -25,7 +26,7 @@ namespace Botan { * @brief Classic McEliece Encapsulation Operation */ -class Classic_McEliece_Encryptor final : public PK_Ops::KEM_Encryption { +class BOTAN_TEST_API Classic_McEliece_Encryptor final : public PK_Ops::KEM_Encryption { public: Classic_McEliece_Encryptor(std::shared_ptr key) : m_key(std::move(key)) {} diff --git a/src/lib/pubkey/classic_mceliece/cmce_field_ordering.cpp b/src/lib/pubkey/classic_mceliece/cmce_field_ordering.cpp index b9e624d9cca..a7c4f3963b5 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_field_ordering.cpp +++ b/src/lib/pubkey/classic_mceliece/cmce_field_ordering.cpp @@ -5,7 +5,7 @@ * * Botan is released under the Simplified BSD License (see license.txt) **/ -#include "cmce_field_ordering.h" +#include #include #include diff --git a/src/lib/pubkey/classic_mceliece/cmce_field_ordering.h b/src/lib/pubkey/classic_mceliece/cmce_field_ordering.h index a362a6cb870..ed1af8e0828 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_field_ordering.h +++ b/src/lib/pubkey/classic_mceliece/cmce_field_ordering.h @@ -9,7 +9,7 @@ #ifndef BOTAN_CMCE_FIELD_ORDERING_H_ #define BOTAN_CMCE_FIELD_ORDERING_H_ -#include +#include #include namespace Botan { diff --git a/src/lib/pubkey/classic_mceliece/cmce_gf.h b/src/lib/pubkey/classic_mceliece/cmce_gf.h index 62cf0bed778..60cd991434c 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_gf.h +++ b/src/lib/pubkey/classic_mceliece/cmce_gf.h @@ -142,7 +142,7 @@ class BOTAN_TEST_API Classic_McEliece_GF { /** * @brief Constant time mask wrapper for GF(q) elements. */ -class GF_Mask final { +class BOTAN_TEST_API GF_Mask final { public: static GF_Mask expand(const Classic_McEliece_GF& v) { return GF_Mask(CT::Mask::expand(v.elem())); } diff --git a/src/lib/pubkey/classic_mceliece/cmce_keys_internal.h b/src/lib/pubkey/classic_mceliece/cmce_keys_internal.h index 55f268ced2f..f30d6d172e3 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_keys_internal.h +++ b/src/lib/pubkey/classic_mceliece/cmce_keys_internal.h @@ -9,9 +9,9 @@ #ifndef BOTAN_CMCE_KEYS_INTERNAL_H_ #define BOTAN_CMCE_KEYS_INTERNAL_H_ -#include #include #include +#include #include namespace Botan { @@ -26,7 +26,7 @@ class Classic_McEliece_PrivateKeyInternal; * - The Classic McEliece parameters * - The public key matrix */ -class Classic_McEliece_PublicKeyInternal { +class BOTAN_TEST_API Classic_McEliece_PublicKeyInternal { public: /** * @brief Construct a Classic McEliece public key. @@ -83,7 +83,7 @@ class Classic_McEliece_PublicKeyInternal { * - The field ordering alpha * - The seed s for implicit rejection */ -class Classic_McEliece_PrivateKeyInternal { +class BOTAN_TEST_API Classic_McEliece_PrivateKeyInternal { public: /** * @brief Construct a Classic McEliece private key. @@ -169,7 +169,7 @@ class Classic_McEliece_PrivateKeyInternal { /** * @brief Representation of a Classic McEliece key pair. */ -struct Classic_McEliece_KeyPair_Internal { +struct BOTAN_TEST_API Classic_McEliece_KeyPair_Internal { std::shared_ptr private_key; std::shared_ptr public_key; diff --git a/src/lib/pubkey/classic_mceliece/cmce_matrix.h b/src/lib/pubkey/classic_mceliece/cmce_matrix.h index 550306834ac..1cd566add90 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_matrix.h +++ b/src/lib/pubkey/classic_mceliece/cmce_matrix.h @@ -11,9 +11,9 @@ #ifndef BOTAN_CMCE_MATRIX_H_ #define BOTAN_CMCE_MATRIX_H_ -#include #include #include +#include #include namespace Botan { diff --git a/src/lib/pubkey/classic_mceliece/cmce_parameter_set.cpp b/src/lib/pubkey/classic_mceliece/cmce_parameter_set.cpp new file mode 100644 index 00000000000..82ed3af6df6 --- /dev/null +++ b/src/lib/pubkey/classic_mceliece/cmce_parameter_set.cpp @@ -0,0 +1,124 @@ +#include + +namespace Botan { + +Classic_McEliece_Parameter_Set param_set_from_str(std::string_view param_name) { + if(param_name == "mceliece348864") { + return Classic_McEliece_Parameter_Set::mceliece348864; + } + if(param_name == "mceliece348864f") { + return Classic_McEliece_Parameter_Set::mceliece348864f; + } + if(param_name == "mceliece460896") { + return Classic_McEliece_Parameter_Set::mceliece460896; + } + if(param_name == "mceliece460896f") { + return Classic_McEliece_Parameter_Set::mceliece460896f; + } + if(param_name == "mceliece6688128") { + return Classic_McEliece_Parameter_Set::mceliece6688128; + } + if(param_name == "mceliece6688128f") { + return Classic_McEliece_Parameter_Set::mceliece6688128f; + } + if(param_name == "mceliece6688128pc") { + return Classic_McEliece_Parameter_Set::mceliece6688128pc; + } + if(param_name == "mceliece6688128pcf") { + return Classic_McEliece_Parameter_Set::mceliece6688128pcf; + } + if(param_name == "mceliece6960119") { + return Classic_McEliece_Parameter_Set::mceliece6960119; + } + if(param_name == "mceliece6960119f") { + return Classic_McEliece_Parameter_Set::mceliece6960119f; + } + if(param_name == "mceliece6960119pc") { + return Classic_McEliece_Parameter_Set::mceliece6960119pc; + } + if(param_name == "mceliece6960119pcf") { + return Classic_McEliece_Parameter_Set::mceliece6960119pcf; + } + if(param_name == "mceliece8192128") { + return Classic_McEliece_Parameter_Set::mceliece8192128; + } + if(param_name == "mceliece8192128f") { + return Classic_McEliece_Parameter_Set::mceliece8192128f; + } + if(param_name == "mceliece8192128pc") { + return Classic_McEliece_Parameter_Set::mceliece8192128pc; + } + if(param_name == "mceliece8192128pcf") { + return Classic_McEliece_Parameter_Set::mceliece8192128pcf; + } + // TODO: Remove on final PR + if(param_name == "test") { + return Classic_McEliece_Parameter_Set::test; + } + if(param_name == "testf") { + return Classic_McEliece_Parameter_Set::testf; + } + if(param_name == "testpc") { + return Classic_McEliece_Parameter_Set::testpc; + } + if(param_name == "testpcf") { + return Classic_McEliece_Parameter_Set::testpcf; + } + + throw Decoding_Error("Cannot convert string to CMCE parameter set"); +} + +std::string str_from_param_set(Classic_McEliece_Parameter_Set param) { + switch(param) { + case Classic_McEliece_Parameter_Set::mceliece348864: + return "mceliece348864"; + case Classic_McEliece_Parameter_Set::mceliece348864f: + return "mceliece348864f"; + case Classic_McEliece_Parameter_Set::mceliece460896: + return "mceliece460896"; + case Classic_McEliece_Parameter_Set::mceliece460896f: + return "mceliece460896f"; + case Classic_McEliece_Parameter_Set::mceliece6688128: + return "mceliece6688128"; + case Classic_McEliece_Parameter_Set::mceliece6688128f: + return "mceliece6688128f"; + case Classic_McEliece_Parameter_Set::mceliece6688128pc: + return "mceliece6688128pc"; + case Classic_McEliece_Parameter_Set::mceliece6688128pcf: + return "mceliece6688128pcf"; + case Classic_McEliece_Parameter_Set::mceliece6960119: + return "mceliece6960119"; + case Classic_McEliece_Parameter_Set::mceliece6960119f: + return "mceliece6960119f"; + case Classic_McEliece_Parameter_Set::mceliece6960119pc: + return "mceliece6960119pc"; + case Classic_McEliece_Parameter_Set::mceliece6960119pcf: + return "mceliece6960119pcf"; + case Classic_McEliece_Parameter_Set::mceliece8192128: + return "mceliece8192128"; + case Classic_McEliece_Parameter_Set::mceliece8192128f: + return "mceliece8192128f"; + case Classic_McEliece_Parameter_Set::mceliece8192128pc: + return "mceliece8192128pc"; + case Classic_McEliece_Parameter_Set::mceliece8192128pcf: + return "mceliece8192128pcf"; + // TODO: Remove on final PR + case Classic_McEliece_Parameter_Set::test: + return "test"; + case Classic_McEliece_Parameter_Set::testf: + return "testf"; + case Classic_McEliece_Parameter_Set::testpc: + return "testpc"; + case Classic_McEliece_Parameter_Set::testpcf: + return "testpcf"; + default: + throw Decoding_Error("Parameter set not supported"); + } + BOTAN_ASSERT_UNREACHABLE(); +} + +Classic_McEliece_Parameter_Set param_set_from_oid(const OID& oid) { + return param_set_from_str(oid.to_formatted_string()); +} + +} // namespace Botan diff --git a/src/lib/pubkey/classic_mceliece/cmce_parameter_set.h b/src/lib/pubkey/classic_mceliece/cmce_parameter_set.h new file mode 100644 index 00000000000..f8a267fd3c7 --- /dev/null +++ b/src/lib/pubkey/classic_mceliece/cmce_parameter_set.h @@ -0,0 +1,69 @@ +#ifndef CMCE_PARAMETER_SET_H +#define CMCE_PARAMETER_SET_H + +#include + +namespace Botan { + +/** + * All Classic McEliece parameter sets defined in the NIST Round 4 + * submission and the Classic McEliece ISO Draft. + * + * Instances are defined in the following format: + * mceliece{n}{t}{[pc]}{[f]} + * + * Instance with 'pc' use plaintext confirmation as defined in the ISO Draft. + * Instance with 'f' use matrix reduction with the semi-systematic form. + */ +enum class Classic_McEliece_Parameter_Set { + mceliece348864, // NIST + mceliece348864f, // NIST + + mceliece460896, // NIST + mceliece460896f, // NIST + + mceliece6688128, // ISO + NIST + mceliece6688128f, // ISO + NIST + mceliece6688128pc, // ISO + mceliece6688128pcf, // ISO + + mceliece6960119, // ISO + NIST + mceliece6960119f, // ISO + NIST + mceliece6960119pc, // ISO + mceliece6960119pcf, // ISO + + mceliece8192128, // ISO + NIST + mceliece8192128f, // ISO + NIST + mceliece8192128pc, // ISO + mceliece8192128pcf, // ISO + + toy, + /// Self-created test instance: m=8, n=128, t=8, f(z)=z^8+z^7+z^2+z+1, F(y)=y^8+y^4+y^3+y^2+1 + /// Minimal instance without semi-systematic matrix creation and no plaintext confirmation + test, + /// Minimal instance with semi-systematic matrix creation and no plaintext confirmation + testf, + /// Minimal instance without semi-systematic matrix creation and with plaintext confirmation + testpc, + /// Minimal instance with semi-systematic matrix creation and with plaintext confirmation + testpcf +}; + +/** + * @brief Get the parameter set for a given parameter set name. + */ +Classic_McEliece_Parameter_Set param_set_from_str(std::string_view param_name); + +/** + * @brief Get the parameter set name for a given parameter set. + */ +std::string str_from_param_set(Classic_McEliece_Parameter_Set param); + +/** + * @brief Get the parameter set for a given OID. + */ +Classic_McEliece_Parameter_Set param_set_from_oid(const OID& oid); + +} // namespace Botan + +#endif // CMCE_PARAMETER_SET_H diff --git a/src/lib/pubkey/classic_mceliece/cmce_parameters.cpp b/src/lib/pubkey/classic_mceliece/cmce_parameters.cpp index dd7c33873ca..8cec13b5f4d 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_parameters.cpp +++ b/src/lib/pubkey/classic_mceliece/cmce_parameters.cpp @@ -6,7 +6,7 @@ * Botan is released under the Simplified BSD License (see license.txt) **/ -#include +#include #include namespace Botan { @@ -15,56 +15,6 @@ namespace { // TODO: Maybe use parameter mapping like this: https://godbolt.org/z/e8oo7WKMK -// TODO: unused? -[[maybe_unused]] std::string str_from_param_set(Classic_McEliece_Parameter_Set param) { - switch(param) { - case Classic_McEliece_Parameter_Set::mceliece348864: - return "mceliece348864"; - case Classic_McEliece_Parameter_Set::mceliece348864f: - return "mceliece348864f"; - case Classic_McEliece_Parameter_Set::mceliece460896: - return "mceliece460896"; - case Classic_McEliece_Parameter_Set::mceliece460896f: - return "mceliece460896f"; - case Classic_McEliece_Parameter_Set::mceliece6688128: - return "mceliece6688128"; - case Classic_McEliece_Parameter_Set::mceliece6688128f: - return "mceliece6688128f"; - case Classic_McEliece_Parameter_Set::mceliece6688128pc: - return "mceliece6688128pc"; - case Classic_McEliece_Parameter_Set::mceliece6688128pcf: - return "mceliece6688128pcf"; - case Classic_McEliece_Parameter_Set::mceliece6960119: - return "mceliece6960119"; - case Classic_McEliece_Parameter_Set::mceliece6960119f: - return "mceliece6960119f"; - case Classic_McEliece_Parameter_Set::mceliece6960119pc: - return "mceliece6960119pc"; - case Classic_McEliece_Parameter_Set::mceliece6960119pcf: - return "mceliece6960119pcf"; - case Classic_McEliece_Parameter_Set::mceliece8192128: - return "mceliece8192128"; - case Classic_McEliece_Parameter_Set::mceliece8192128f: - return "mceliece8192128f"; - case Classic_McEliece_Parameter_Set::mceliece8192128pc: - return "mceliece8192128pc"; - case Classic_McEliece_Parameter_Set::mceliece8192128pcf: - return "mceliece8192128pcf"; - // TODO: Remove on final PR - case Classic_McEliece_Parameter_Set::test: - return "test"; - case Classic_McEliece_Parameter_Set::testf: - return "testf"; - case Classic_McEliece_Parameter_Set::testpc: - return "testpc"; - case Classic_McEliece_Parameter_Set::testpcf: - return "testpcf"; - default: - throw Decoding_Error("Parameter set not supported"); - } - BOTAN_ASSERT_UNREACHABLE(); -} - std::vector determine_big_f_coef(size_t t, uint16_t modulus) { std::vector big_f_coef; switch(t) { @@ -104,72 +54,6 @@ std::vector determine_big_f } } //namespace -Classic_McEliece_Parameter_Set Classic_McEliece_Parameters::param_set_from_str(std::string_view param_name) { - if(param_name == "mceliece348864") { - return Classic_McEliece_Parameter_Set::mceliece348864; - } - if(param_name == "mceliece348864f") { - return Classic_McEliece_Parameter_Set::mceliece348864f; - } - if(param_name == "mceliece460896") { - return Classic_McEliece_Parameter_Set::mceliece460896; - } - if(param_name == "mceliece460896f") { - return Classic_McEliece_Parameter_Set::mceliece460896f; - } - if(param_name == "mceliece6688128") { - return Classic_McEliece_Parameter_Set::mceliece6688128; - } - if(param_name == "mceliece6688128f") { - return Classic_McEliece_Parameter_Set::mceliece6688128f; - } - if(param_name == "mceliece6688128pc") { - return Classic_McEliece_Parameter_Set::mceliece6688128pc; - } - if(param_name == "mceliece6688128pcf") { - return Classic_McEliece_Parameter_Set::mceliece6688128pcf; - } - if(param_name == "mceliece6960119") { - return Classic_McEliece_Parameter_Set::mceliece6960119; - } - if(param_name == "mceliece6960119f") { - return Classic_McEliece_Parameter_Set::mceliece6960119f; - } - if(param_name == "mceliece6960119pc") { - return Classic_McEliece_Parameter_Set::mceliece6960119pc; - } - if(param_name == "mceliece6960119pcf") { - return Classic_McEliece_Parameter_Set::mceliece6960119pcf; - } - if(param_name == "mceliece8192128") { - return Classic_McEliece_Parameter_Set::mceliece8192128; - } - if(param_name == "mceliece8192128f") { - return Classic_McEliece_Parameter_Set::mceliece8192128f; - } - if(param_name == "mceliece8192128pc") { - return Classic_McEliece_Parameter_Set::mceliece8192128pc; - } - if(param_name == "mceliece8192128pcf") { - return Classic_McEliece_Parameter_Set::mceliece8192128pcf; - } - // TODO: Remove on final PR - if(param_name == "test") { - return Classic_McEliece_Parameter_Set::test; - } - if(param_name == "testf") { - return Classic_McEliece_Parameter_Set::testf; - } - if(param_name == "testpc") { - return Classic_McEliece_Parameter_Set::testpc; - } - if(param_name == "testpcf") { - return Classic_McEliece_Parameter_Set::testpcf; - } - - throw Decoding_Error("Cannot convert string to CMCE parameter set"); -} - Classic_McEliece_Parameters Classic_McEliece_Parameters::create(Classic_McEliece_Parameter_Set set) { switch(set) { case Classic_McEliece_Parameter_Set::mceliece348864: @@ -221,10 +105,6 @@ Classic_McEliece_Parameters Classic_McEliece_Parameters::create(const OID& oid) return create(param_set); } -Classic_McEliece_Parameter_Set Classic_McEliece_Parameters::param_set_from_oid(const OID& oid) { - return Classic_McEliece_Parameters::param_set_from_str(oid.to_formatted_string()); -} - OID Classic_McEliece_Parameters::object_identifier() const { return OID::from_string(str_from_param_set(m_set)); } diff --git a/src/lib/pubkey/classic_mceliece/cmce_parameters.h b/src/lib/pubkey/classic_mceliece/cmce_parameters.h index 8dc5fcd798e..9146831cca8 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_parameters.h +++ b/src/lib/pubkey/classic_mceliece/cmce_parameters.h @@ -9,11 +9,13 @@ #ifndef BOTAN_CMCE_PARAMS_H_ #define BOTAN_CMCE_PARAMS_H_ +#include #include #include #include #include #include +#include #include @@ -22,50 +24,6 @@ namespace Botan { struct Classic_McEliece_Big_F_Coefficient; class Classic_McEliece_Polynomial_Ring; -/** - * Specifies the Classic McEliece parameter sets defined in the NIST Round 4 - * submission and the Classic McEliece ISO Draft. - * - * Instances are defined in the following format: - * mceliece{n}{t}{[pc]}{[f]} - * - * Instance with 'pc' use plaintext confirmation as defined in the ISO Draft. - * Instance with 'f' use matrix reduction with the semi-systematic form. - */ -enum class Classic_McEliece_Parameter_Set { - mceliece348864, // NIST - mceliece348864f, // NIST - - mceliece460896, // NIST - mceliece460896f, // NIST - - mceliece6688128, // ISO + NIST - mceliece6688128f, // ISO + NIST - mceliece6688128pc, // ISO - mceliece6688128pcf, // ISO - - mceliece6960119, // ISO + NIST - mceliece6960119f, // ISO + NIST - mceliece6960119pc, // ISO - mceliece6960119pcf, // ISO - - mceliece8192128, // ISO + NIST - mceliece8192128f, // ISO + NIST - mceliece8192128pc, // ISO - mceliece8192128pcf, // ISO - - toy, - /// Self-created test instance: m=8, n=128, t=8, f(z)=z^8+z^7+z^2+z+1, F(y)=y^8+y^4+y^3+y^2+1 - /// Minimal instance without semi-systematic matrix creation and no plaintext confirmation - test, - /// Minimal instance with semi-systematic matrix creation and no plaintext confirmation - testf, - /// Minimal instance without semi-systematic matrix creation and with plaintext confirmation - testpc, - /// Minimal instance with semi-systematic matrix creation and with plaintext confirmation - testpcf -}; - /** * @returns ceil(n/d) * TODO: Remove once LMS is merged @@ -77,7 +35,7 @@ constexpr size_t ceil_div(size_t n, size_t d) { /** * Container for all Classic McEliece parameters. */ -class BOTAN_PUBLIC_API(3, 1) Classic_McEliece_Parameters final { +class BOTAN_TEST_API Classic_McEliece_Parameters final { public: /** * @brief Create Classic McEliece parameters from a parameter set. @@ -94,16 +52,6 @@ class BOTAN_PUBLIC_API(3, 1) Classic_McEliece_Parameters final { */ static Classic_McEliece_Parameters create(const OID& oid); - /** - * @brief Get the parameter set for a given OID. - */ - static Classic_McEliece_Parameter_Set param_set_from_oid(const OID& oid); - - /** - * @brief Get the parameter set for a given parameter set name. - */ - static Classic_McEliece_Parameter_Set param_set_from_str(std::string_view param_name); - /** * @brief Copy constructor. */ diff --git a/src/lib/pubkey/classic_mceliece/cmce_poly.h b/src/lib/pubkey/classic_mceliece/cmce_poly.h index 70b6b2fb0cd..91509b9e1e9 100644 --- a/src/lib/pubkey/classic_mceliece/cmce_poly.h +++ b/src/lib/pubkey/classic_mceliece/cmce_poly.h @@ -9,7 +9,6 @@ #ifndef BOTAN_CMCE_POLY_H_ #define BOTAN_CMCE_POLY_H_ -#include #include #include #include @@ -73,7 +72,7 @@ class BOTAN_TEST_API Classic_McEliece_Polynomial { * * It represents the monic irreducible degree-t polynomial of the goppa code. */ -class Classic_McEliece_Minimal_Polynomial : public Classic_McEliece_Polynomial { +class BOTAN_TEST_API Classic_McEliece_Minimal_Polynomial : public Classic_McEliece_Polynomial { public: /** * @brief Serialize the polynomial to bytes according to ISO Section 9.2.9. diff --git a/src/lib/pubkey/classic_mceliece/info.txt b/src/lib/pubkey/classic_mceliece/info.txt index 312a0aa0759..6a622a73f09 100644 --- a/src/lib/pubkey/classic_mceliece/info.txt +++ b/src/lib/pubkey/classic_mceliece/info.txt @@ -14,6 +14,7 @@ shake_xof +cmce_parameters.h cmce_poly.h cmce_matrix.h cmce_gf.h @@ -26,6 +27,6 @@ cmce_keys_internal.h cmce.h -cmce_parameters.h +cmce_parameter_set.h diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp index 0e4ea4ffcc2..7c631dc7d24 100644 --- a/src/lib/pubkey/pk_algs.cpp +++ b/src/lib/pubkey/pk_algs.cpp @@ -431,7 +431,7 @@ std::unique_ptr create_private_key(std::string_view alg_name, #endif #if defined(BOTAN_HAS_CLASSICMCELIECE) if(alg_name == "ClassicMcEliece") { - auto cmce_params_set = Classic_McEliece_Parameters::param_set_from_str(params); + auto cmce_params_set = param_set_from_str(params); return std::make_unique(rng, cmce_params_set); } diff --git a/src/tests/test_cmce.cpp b/src/tests/test_cmce.cpp index aaefea683ba..6aac01797bd 100644 --- a/src/tests/test_cmce.cpp +++ b/src/tests/test_cmce.cpp @@ -12,7 +12,6 @@ #include "tests.h" #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include #include #include