diff options
author | Jack Lloyd <[email protected]> | 2020-11-05 03:53:10 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2020-11-05 04:02:01 -0500 |
commit | 7688e7a0985878e5db79796eac81df3f565e6894 (patch) | |
tree | d7aa733766b68332d4f3e4ace12fb4e45650e5aa /src | |
parent | 69b3ceb1602d22addf2a171e8edbf0134df9fe7c (diff) |
Remove some implementation headers from public McEliece includes
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/pubkey/mce/code_based_key_gen.cpp | 1 | ||||
-rw-r--r-- | src/lib/pubkey/mce/gf2m_small_m.h | 3 | ||||
-rw-r--r-- | src/lib/pubkey/mce/mce_internal.h | 1 | ||||
-rw-r--r-- | src/lib/pubkey/mce/mceliece.h | 11 | ||||
-rw-r--r-- | src/lib/pubkey/mce/mceliece_key.cpp | 16 | ||||
-rw-r--r-- | src/lib/pubkey/mce/polyn_gf2m.h | 7 |
6 files changed, 28 insertions, 11 deletions
diff --git a/src/lib/pubkey/mce/code_based_key_gen.cpp b/src/lib/pubkey/mce/code_based_key_gen.cpp index 2768f5d36..8dc3a3178 100644 --- a/src/lib/pubkey/mce/code_based_key_gen.cpp +++ b/src/lib/pubkey/mce/code_based_key_gen.cpp @@ -13,6 +13,7 @@ #include <botan/mceliece.h> #include <botan/internal/mce_internal.h> #include <botan/internal/code_based_util.h> +#include <botan/polyn_gf2m.h> #include <botan/loadstor.h> namespace Botan { diff --git a/src/lib/pubkey/mce/gf2m_small_m.h b/src/lib/pubkey/mce/gf2m_small_m.h index 44903bc46..ae3eab226 100644 --- a/src/lib/pubkey/mce/gf2m_small_m.h +++ b/src/lib/pubkey/mce/gf2m_small_m.h @@ -15,8 +15,7 @@ #include <botan/types.h> #include <vector> -// fixme - still used in mceliece.h -//BOTAN_FUTURE_INTERNAL_HEADER(gf2m_small_m.h) +BOTAN_FUTURE_INTERNAL_HEADER(gf2m_small_m.h) namespace Botan { diff --git a/src/lib/pubkey/mce/mce_internal.h b/src/lib/pubkey/mce/mce_internal.h index f3845b286..7059f4e2e 100644 --- a/src/lib/pubkey/mce/mce_internal.h +++ b/src/lib/pubkey/mce/mce_internal.h @@ -16,6 +16,7 @@ #include <botan/types.h> #include <botan/pk_ops.h> #include <botan/mceliece.h> +#include <botan/polyn_gf2m.h> namespace Botan { diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h index 0c86ec8c4..ff11ec746 100644 --- a/src/lib/pubkey/mce/mceliece.h +++ b/src/lib/pubkey/mce/mceliece.h @@ -13,11 +13,14 @@ #define BOTAN_MCELIECE_KEY_H_ #include <botan/pk_keys.h> -#include <botan/polyn_gf2m.h> #include <botan/exceptn.h> namespace Botan { +typedef uint16_t gf2m; + +class polyn_gf2m; + class BOTAN_PUBLIC_API(2,0) McEliece_PublicKey : public virtual Public_Key { public: @@ -94,9 +97,11 @@ class BOTAN_PUBLIC_API(2,0) McEliece_PrivateKey final : public virtual McEliece_ std::vector<gf2m> const& inverse_support, std::vector<uint8_t> const& public_matrix ); + ~McEliece_PrivateKey(); + bool check_key(RandomNumberGenerator& rng, bool strong) const override; - polyn_gf2m const& get_goppa_polyn() const { return m_g; } + polyn_gf2m const& get_goppa_polyn() const; std::vector<uint32_t> const& get_H_coeffs() const { return m_coeffs; } std::vector<gf2m> const& get_Linv() const { return m_Linv; } std::vector<polyn_gf2m> const& get_sqrtmod() const { return m_sqrtmod; } @@ -116,7 +121,7 @@ class BOTAN_PUBLIC_API(2,0) McEliece_PrivateKey final : public virtual McEliece_ const std::string& params, const std::string& provider) const override; private: - polyn_gf2m m_g; + std::vector<polyn_gf2m> m_g; // single element std::vector<polyn_gf2m> m_sqrtmod; std::vector<gf2m> m_Linv; std::vector<uint32_t> m_coeffs; diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp index 6b44b4a73..283421be4 100644 --- a/src/lib/pubkey/mce/mceliece_key.cpp +++ b/src/lib/pubkey/mce/mceliece_key.cpp @@ -11,6 +11,7 @@ */ #include <botan/mceliece.h> +#include <botan/polyn_gf2m.h> #include <botan/internal/mce_internal.h> #include <botan/internal/bit_ops.h> #include <botan/internal/code_based_util.h> @@ -28,7 +29,7 @@ McEliece_PrivateKey::McEliece_PrivateKey(polyn_gf2m const& goppa_polyn, std::vector<gf2m> const& inverse_support, std::vector<uint8_t> const& public_matrix) : McEliece_PublicKey(public_matrix, goppa_polyn.get_degree(), inverse_support.size()), - m_g(goppa_polyn), + m_g{goppa_polyn}, m_sqrtmod(square_root_matrix), m_Linv(inverse_support), m_coeffs(parity_check_matrix_coeffs), @@ -43,6 +44,13 @@ McEliece_PrivateKey::McEliece_PrivateKey(RandomNumberGenerator& rng, size_t code *this = generate_mceliece_key(rng, ext_deg, code_length, t); } +McEliece_PrivateKey::~McEliece_PrivateKey() = default; + +const polyn_gf2m& McEliece_PrivateKey::get_goppa_polyn() const + { + return m_g[0]; + } + size_t McEliece_PublicKey::get_message_word_bit_length() const { size_t codimension = ceil_log2(m_code_length) * m_t; @@ -120,7 +128,7 @@ secure_vector<uint8_t> McEliece_PrivateKey::private_key_bits() const .encode(static_cast<size_t>(get_t())) .end_cons() .encode(m_public_matrix, OCTET_STRING) - .encode(m_g.encode(), OCTET_STRING); // g as octet string + .encode(m_g[0].encode(), OCTET_STRING); // g as octet string enc.start_cons(SEQUENCE); for(size_t i = 0; i < m_sqrtmod.size(); i++) { @@ -189,8 +197,8 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<uint8_t>& key_bits) m_dimension = (n - m_codimension); std::shared_ptr<GF2m_Field> sp_field(new GF2m_Field(ext_deg)); - m_g = polyn_gf2m(enc_g, sp_field); - if(m_g.get_degree() != static_cast<int>(t)) + m_g = { polyn_gf2m(enc_g, sp_field) }; + if(m_g[0].get_degree() != static_cast<int>(t)) { throw Decoding_Error("degree of decoded Goppa polynomial is incorrect"); } diff --git a/src/lib/pubkey/mce/polyn_gf2m.h b/src/lib/pubkey/mce/polyn_gf2m.h index 55e865a29..574fcb917 100644 --- a/src/lib/pubkey/mce/polyn_gf2m.h +++ b/src/lib/pubkey/mce/polyn_gf2m.h @@ -13,14 +13,17 @@ #define BOTAN_POLYN_GF2M_H_ #include <botan/secmem.h> -#include <botan/gf2m_small_m.h> #include <utility> #include <string> -//BOTAN_FUTURE_INTERNAL_HEADER(polyn_gf2m.h) +BOTAN_FUTURE_INTERNAL_HEADER(polyn_gf2m.h) namespace Botan { +typedef uint16_t gf2m; + +class GF2m_Field; + class RandomNumberGenerator; class polyn_gf2m |