diff options
author | Jack Lloyd <[email protected]> | 2022-02-04 18:05:34 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2022-02-06 08:52:16 -0500 |
commit | fbb7c5fba1bcde2460dda48c1423a23b3b3062bf (patch) | |
tree | c0b9cd348067f0813d80e9b1b23b149d1a0d0af2 /src/lib/pubkey/mce | |
parent | 3c8d79246c7c5c57296d3165922b58aad401e5e3 (diff) |
Fix clang-tidy performance warnings
Diffstat (limited to 'src/lib/pubkey/mce')
-rw-r--r-- | src/lib/pubkey/mce/mceliece.h | 9 | ||||
-rw-r--r-- | src/lib/pubkey/mce/mceliece_key.cpp | 5 | ||||
-rw-r--r-- | src/lib/pubkey/mce/polyn_gf2m.cpp | 19 | ||||
-rw-r--r-- | src/lib/pubkey/mce/polyn_gf2m.h | 15 |
4 files changed, 24 insertions, 24 deletions
diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h index 3ac48aeb4..c7e0ab65e 100644 --- a/src/lib/pubkey/mce/mceliece.h +++ b/src/lib/pubkey/mce/mceliece.h @@ -98,10 +98,11 @@ class BOTAN_PUBLIC_API(2,0) McEliece_PrivateKey final : public virtual McEliece_ ~McEliece_PrivateKey(); - McEliece_PrivateKey(const McEliece_PrivateKey&); - McEliece_PrivateKey(McEliece_PrivateKey&&); - McEliece_PrivateKey& operator=(const McEliece_PrivateKey&); - McEliece_PrivateKey& operator=(McEliece_PrivateKey&&); + McEliece_PrivateKey(const McEliece_PrivateKey&) = default; + McEliece_PrivateKey& operator=(const McEliece_PrivateKey&) = default; + + McEliece_PrivateKey(McEliece_PrivateKey&&) noexcept = default; + McEliece_PrivateKey& operator=(McEliece_PrivateKey&&) noexcept = default; bool check_key(RandomNumberGenerator& rng, bool strong) const override; diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp index 8c23bf659..22a9c62ad 100644 --- a/src/lib/pubkey/mce/mceliece_key.cpp +++ b/src/lib/pubkey/mce/mceliece_key.cpp @@ -23,11 +23,6 @@ namespace Botan { -McEliece_PrivateKey::McEliece_PrivateKey(const McEliece_PrivateKey&) = default; -McEliece_PrivateKey::McEliece_PrivateKey(McEliece_PrivateKey&&) = default; -McEliece_PrivateKey& McEliece_PrivateKey::operator=(const McEliece_PrivateKey&) = default; -McEliece_PrivateKey& McEliece_PrivateKey::operator=(McEliece_PrivateKey&&) = default; - McEliece_PrivateKey::McEliece_PrivateKey(polyn_gf2m const& goppa_polyn, std::vector<uint32_t> const& parity_check_matrix_coeffs, std::vector<polyn_gf2m> const& square_root_matrix, diff --git a/src/lib/pubkey/mce/polyn_gf2m.cpp b/src/lib/pubkey/mce/polyn_gf2m.cpp index 75381b36b..508c7c6e5 100644 --- a/src/lib/pubkey/mce/polyn_gf2m.cpp +++ b/src/lib/pubkey/mce/polyn_gf2m.cpp @@ -94,10 +94,10 @@ polyn_gf2m::polyn_gf2m(polyn_gf2m const& other) m_sp_field(other.m_sp_field) { } -polyn_gf2m::polyn_gf2m(int d, std::shared_ptr<GF2m_Field> sp_field) +polyn_gf2m::polyn_gf2m(int d, const std::shared_ptr<GF2m_Field>& sp_field) :m_deg(-1), coeff(d+1), - m_sp_field(sp_field) + m_sp_field(std::move(sp_field)) { } @@ -123,7 +123,7 @@ void polyn_gf2m::realloc(uint32_t new_size) this->coeff = secure_vector<gf2m>(new_size); } -polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field) : +polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, const std::shared_ptr<GF2m_Field>& sp_field) : m_deg(-1), m_sp_field(sp_field) { if(mem_len % sizeof(gf2m)) @@ -150,11 +150,11 @@ polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2 } -polyn_gf2m::polyn_gf2m( std::shared_ptr<GF2m_Field> sp_field) : +polyn_gf2m::polyn_gf2m(const std::shared_ptr<GF2m_Field>& sp_field) : m_deg(-1), coeff(1), m_sp_field(sp_field) {} -polyn_gf2m::polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field) +polyn_gf2m::polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len, const std::shared_ptr<GF2m_Field>& sp_field) :m_sp_field(sp_field) { uint32_t j, k, l; @@ -235,7 +235,7 @@ int polyn_gf2m::get_degree() const } -static gf2m eval_aux(const gf2m * /*restrict*/ coeff, gf2m a, int d, std::shared_ptr<GF2m_Field> sp_field) +static gf2m eval_aux(const gf2m * /*restrict*/ coeff, gf2m a, int d, const std::shared_ptr<GF2m_Field>& sp_field) { gf2m b; b = coeff[d--]; @@ -636,7 +636,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn return std::make_pair(u1,r1); // coefficients u,v } -polyn_gf2m::polyn_gf2m(size_t t, RandomNumberGenerator& rng, std::shared_ptr<GF2m_Field> sp_field) +polyn_gf2m::polyn_gf2m(size_t t, RandomNumberGenerator& rng, const std::shared_ptr<GF2m_Field>& sp_field) :m_deg(static_cast<int>(t)), coeff(t+1), m_sp_field(sp_field) @@ -751,8 +751,9 @@ std::vector<polyn_gf2m> syndrome_init(polyn_gf2m const& generator, std::vector<g return result; } -polyn_gf2m::polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field ) - :m_sp_field(sp_field) +polyn_gf2m::polyn_gf2m(const secure_vector<uint8_t>& encoded, + const std::shared_ptr<GF2m_Field>& sp_field) : + m_sp_field(sp_field) { if(encoded.size() % 2) { diff --git a/src/lib/pubkey/mce/polyn_gf2m.h b/src/lib/pubkey/mce/polyn_gf2m.h index 5c8b3e75c..29ea8009f 100644 --- a/src/lib/pubkey/mce/polyn_gf2m.h +++ b/src/lib/pubkey/mce/polyn_gf2m.h @@ -30,33 +30,36 @@ class polyn_gf2m /** * create a zero polynomial: */ - explicit polyn_gf2m(std::shared_ptr<GF2m_Field> sp_field); + explicit polyn_gf2m(const std::shared_ptr<GF2m_Field>& sp_field); polyn_gf2m() : m_deg(-1) {} - polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field); + polyn_gf2m(const secure_vector<uint8_t>& encoded, + const std::shared_ptr<GF2m_Field>& sp_field); polyn_gf2m& operator=(const polyn_gf2m&) = default; /** * create zero polynomial with reservation of space for a degree d polynomial */ - polyn_gf2m(int d, std::shared_ptr<GF2m_Field> sp_field); + polyn_gf2m(int d, const std::shared_ptr<GF2m_Field>& sp_field); polyn_gf2m(polyn_gf2m const& other); /** * random irreducible polynomial of degree t */ - polyn_gf2m(size_t t, RandomNumberGenerator& rng, std::shared_ptr<GF2m_Field> sp_field); + polyn_gf2m(size_t t, RandomNumberGenerator& rng, + const std::shared_ptr<GF2m_Field>& sp_field); /** decode a polynomial from memory: **/ - polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field); + polyn_gf2m(const uint8_t* mem, uint32_t mem_len, const std::shared_ptr<GF2m_Field>& sp_field); /** * create a polynomial from memory area (encoded) */ - polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field); + polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len, + const std::shared_ptr<GF2m_Field>& sp_field); bool operator==(const polyn_gf2m & other) const ; |