diff --git a/src/lib/pubkey/dh/dh.cpp b/src/lib/pubkey/dh/dh.cpp index e30ec8664b0..d6d8d224d39 100644 --- a/src/lib/pubkey/dh/dh.cpp +++ b/src/lib/pubkey/dh/dh.cpp @@ -76,15 +76,6 @@ DH_PrivateKey::DH_PrivateKey(const AlgorithmIdentifier& alg_id, std::spanpublic_key(); } -DH_PrivateKey& DH_PrivateKey::operator=(DH_PrivateKey&& other) noexcept { - if(this != &other) { - static_cast(*this) = static_cast(other); - m_private_key = std::move(other.m_private_key); - } - - return *this; -} - std::unique_ptr DH_PrivateKey::public_key() const { return std::unique_ptr(new DH_PublicKey(m_public_key)); } diff --git a/src/lib/pubkey/dh/dh.h b/src/lib/pubkey/dh/dh.h index e830ae0e98c..75c1c2019e7 100644 --- a/src/lib/pubkey/dh/dh.h +++ b/src/lib/pubkey/dh/dh.h @@ -78,7 +78,7 @@ BOTAN_DIAGNOSTIC_PUSH BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE class BOTAN_PUBLIC_API(2, 0) DH_PrivateKey final : public DH_PublicKey, - public PK_Key_Agreement_Key, + public virtual PK_Key_Agreement_Key, public virtual Private_Key { public: /** @@ -102,19 +102,6 @@ class BOTAN_PUBLIC_API(2, 0) DH_PrivateKey final : public DH_PublicKey, */ DH_PrivateKey(RandomNumberGenerator& rng, const DL_Group& group); - /* Work around a bug/oddity in clang-cl on Windows - the default move assignment operator - * generates multiple calls to Public_Key(Public_Key&&) as a technically-valid-but-dangerous - * side-effect of the class having the dllexport attribute. In the cast of the Public_Key - * class, this isn't actually a problem since its just an interface and has no data members, - * but Clang still raises a warning for it. - * - * We implement an explicit move assignment operator to silence this warning. - */ - DH_PrivateKey(const DH_PrivateKey&) = default; - DH_PrivateKey& operator=(const DH_PrivateKey&) = default; - DH_PrivateKey(DH_PrivateKey&&) = default; - DH_PrivateKey& operator=(DH_PrivateKey&& other) noexcept; - std::unique_ptr public_key() const override; std::vector public_value() const override; diff --git a/src/lib/pubkey/ecdh/ecdh.h b/src/lib/pubkey/ecdh/ecdh.h index 2c43cc7565d..82ed0f976de 100644 --- a/src/lib/pubkey/ecdh/ecdh.h +++ b/src/lib/pubkey/ecdh/ecdh.h @@ -66,8 +66,8 @@ BOTAN_DIAGNOSTIC_PUSH BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE class BOTAN_PUBLIC_API(2, 0) ECDH_PrivateKey final : public ECDH_PublicKey, - public EC_PrivateKey, - public PK_Key_Agreement_Key { + public virtual EC_PrivateKey, + public virtual PK_Key_Agreement_Key { public: /** * Load a private key. diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp index 531fe3e525f..78cfb3ac43b 100644 --- a/src/lib/pubkey/ecies/ecies.cpp +++ b/src/lib/pubkey/ecies/ecies.cpp @@ -26,8 +26,8 @@ namespace { BOTAN_DIAGNOSTIC_PUSH BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE -class ECIES_PrivateKey final : public EC_PrivateKey, - public PK_Key_Agreement_Key { +class ECIES_PrivateKey final : public virtual EC_PrivateKey, + public virtual PK_Key_Agreement_Key { public: explicit ECIES_PrivateKey(const ECDH_PrivateKey& private_key) : EC_PublicKey(private_key), EC_PrivateKey(private_key), PK_Key_Agreement_Key(), m_key(private_key) {} diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp index 897fa4bc87d..8ae7e444d66 100644 --- a/src/lib/pubkey/rsa/rsa.cpp +++ b/src/lib/pubkey/rsa/rsa.cpp @@ -358,15 +358,6 @@ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng, size_t bits, size_t e RSA_PrivateKey::init(std::move(d), std::move(p), std::move(q), std::move(d1), std::move(d2), std::move(c)); } -RSA_PrivateKey& RSA_PrivateKey::operator=(RSA_PrivateKey&& other) noexcept { - if(this != &other) { - static_cast(*this) = static_cast(other); - m_private = std::move(other.m_private); - } - - return *this; -} - const BigInt& RSA_PrivateKey::get_int_field(std::string_view field) const { if(field == "p") { return m_private->get_p(); diff --git a/src/lib/pubkey/rsa/rsa.h b/src/lib/pubkey/rsa/rsa.h index 2a9dc1c0f4b..78e80e238da 100644 --- a/src/lib/pubkey/rsa/rsa.h +++ b/src/lib/pubkey/rsa/rsa.h @@ -98,8 +98,8 @@ class BOTAN_PUBLIC_API(2, 0) RSA_PublicKey : public virtual Public_Key { BOTAN_DIAGNOSTIC_PUSH BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE -class BOTAN_PUBLIC_API(2, 0) RSA_PrivateKey final : public Private_Key, - public RSA_PublicKey { +class BOTAN_PUBLIC_API(2, 0) RSA_PrivateKey final : public virtual Private_Key, + public virtual RSA_PublicKey { public: /** * Load a private key. @@ -133,19 +133,6 @@ class BOTAN_PUBLIC_API(2, 0) RSA_PrivateKey final : public Private_Key, */ RSA_PrivateKey(RandomNumberGenerator& rng, size_t bits, size_t exp = 65537); - /* Work around a bug/oddity in clang-cl on Windows - the default move assignment operator - * generates multiple calls to Public_Key(Public_Key&&) as a technically-valid-but-dangerous - * side-effect of the class having the dllexport attribute. In the cast of the Public_Key - * class, this isn't actually a problem since its just an interface and has no data members, - * but Clang still raises a warning for it. - * - * We implement an explicit move assignment operator to silence this warning. - */ - RSA_PrivateKey(const RSA_PrivateKey&) = default; - RSA_PrivateKey& operator=(const RSA_PrivateKey&) = default; - RSA_PrivateKey(RSA_PrivateKey&&) = default; - RSA_PrivateKey& operator=(RSA_PrivateKey&&) noexcept; - std::unique_ptr public_key() const override; bool check_key(RandomNumberGenerator& rng, bool) const override; diff --git a/src/lib/tls/tls13_pqc/hybrid_public_key.cpp b/src/lib/tls/tls13_pqc/hybrid_public_key.cpp index 01500ccbd2d..a49dd9c66c9 100644 --- a/src/lib/tls/tls13_pqc/hybrid_public_key.cpp +++ b/src/lib/tls/tls13_pqc/hybrid_public_key.cpp @@ -349,15 +349,6 @@ Hybrid_KEM_PrivateKey::Hybrid_KEM_PrivateKey(std::vector(*this) = static_cast(other); - m_private_keys = std::move(other.m_private_keys); - } - - return *this; -} - secure_vector Hybrid_KEM_PrivateKey::private_key_bits() const { throw Not_Implemented("Hybrid private keys cannot be serialized"); } diff --git a/src/lib/tls/tls13_pqc/hybrid_public_key.h b/src/lib/tls/tls13_pqc/hybrid_public_key.h index ce38b3104e8..991d07e9ffc 100644 --- a/src/lib/tls/tls13_pqc/hybrid_public_key.h +++ b/src/lib/tls/tls13_pqc/hybrid_public_key.h @@ -82,8 +82,8 @@ BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE * Composes a number of private keys for hybrid key agreement as defined in this * IETF draft: https://datatracker.ietf.org/doc/html/draft-ietf-tls-hybrid-design-04 */ -class BOTAN_TEST_API Hybrid_KEM_PrivateKey final : public Private_Key, - public Hybrid_KEM_PublicKey { +class BOTAN_TEST_API Hybrid_KEM_PrivateKey final : public virtual Private_Key, + public virtual Hybrid_KEM_PublicKey { public: /** * Generate a hybrid private key for the given TLS code point. @@ -93,19 +93,6 @@ class BOTAN_TEST_API Hybrid_KEM_PrivateKey final : public Private_Key, public: Hybrid_KEM_PrivateKey(std::vector> private_keys); - /* Work around a bug/oddity in clang-cl on Windows - the default move assignment operator - * generates multiple calls to Public_Key(Public_Key&&) as a technically-valid-but-dangerous - * side-effect of the class having the dllexport attribute. In the cast of the Public_Key - * class, this isn't actually a problem since its just an interface and has no data members, - * but Clang still raises a warning for it. - * - * We implement an explicit move assignment operator to silence this warning. - */ - Hybrid_KEM_PrivateKey(const Hybrid_KEM_PublicKey&) = delete; - Hybrid_KEM_PrivateKey& operator=(const Hybrid_KEM_PrivateKey&) = delete; - Hybrid_KEM_PrivateKey(Hybrid_KEM_PrivateKey&&) = default; - Hybrid_KEM_PrivateKey& operator=(Hybrid_KEM_PrivateKey&& other) noexcept; - secure_vector private_key_bits() const override; std::unique_ptr public_key() const override;