diff --git a/frameworks/native/tls_socket/include/tls_key.h b/frameworks/native/tls_socket/include/tls_key.h index a6a357dd61052694475f053fbb3f01b370b0f9f0..c514c83607e41fab22885d5e82b2449891c9413b 100644 --- a/frameworks/native/tls_socket/include/tls_key.h +++ b/frameworks/native/tls_socket/include/tls_key.h @@ -44,7 +44,6 @@ public: EncodingFormat format = PEM, KeyType type = PRIVATE_KEY); TLSKey(const TLSKey &other); - TLSKey &operator=(const TLSKey &other); [[nodiscard]] KeyAlgorithm Algorithm() const; [[nodiscard]] Handle handle() const; @@ -65,7 +64,6 @@ private: DSA *dsa_ = nullptr; DH *dh_ = nullptr; EC_KEY *ec_ = nullptr; - EVP_PKEY *genericKey_ = nullptr; SecureData keyPass_; SecureData keyData_; bool keyIsNull_ = true; diff --git a/frameworks/native/tls_socket/src/tls_key.cpp b/frameworks/native/tls_socket/src/tls_key.cpp index da2026eba0eaa719b44b3243f57cfe8be605385f..1eb5497405d8c16bed849deed8fc62bf695d2f1d 100644 --- a/frameworks/native/tls_socket/src/tls_key.cpp +++ b/frameworks/native/tls_socket/src/tls_key.cpp @@ -59,36 +59,6 @@ TLSKey::TLSKey(const TLSKey &other) *this = other; } -TLSKey &TLSKey::operator=(const TLSKey &other) -{ - if (other.rsa_ != nullptr) { - rsa_ = RSA_new(); - rsa_ = other.rsa_; - } - if (other.dsa_ != nullptr) { - dsa_ = DSA_new(); - dsa_ = other.dsa_; - } - if (other.dh_ != nullptr) { - dh_ = DH_new(); - dh_ = other.dh_; - } - if (other.ec_ != nullptr) { - ec_ = EC_KEY_new(); - ec_ = other.ec_; - } - if (other.genericKey_ != nullptr) { - genericKey_ = EVP_PKEY_new(); - genericKey_ = other.genericKey_; - } - keyIsNull_ = other.keyIsNull_; - keyType_ = other.keyType_; - keyAlgorithm_ = other.keyAlgorithm_; - keyPass_ = other.keyPass_; - keyData_ = other.keyData_; - return *this; -} - void TLSKey::DecodeData(const SecureData &data, const SecureData &passPhrase) { if (data.Length() == 0) { diff --git a/test/unittest/tls_test/core/tls_key.test.cpp b/test/unittest/tls_test/core/tls_key.test.cpp index c71ff75649e80be2f2cd658dc8c8c534ee337ba3..3216a89980cc37f2840cb419f465453afa976537 100644 --- a/test/unittest/tls_test/core/tls_key.test.cpp +++ b/test/unittest/tls_test/core/tls_key.test.cpp @@ -42,18 +42,15 @@ HWTEST_F(TLSKeyTest, TLSKeyTestt001, testing::ext::TestSize.Level1) EXPECT_EQ(key.dsa_, nullptr); EXPECT_EQ(key.dh_, nullptr); EXPECT_EQ(key.ec_, nullptr); - EXPECT_EQ(key.genericKey_, nullptr); other.rsa_ = RSA_new(); other.dsa_ = DSA_new(); other.dh_ = DH_new(); other.ec_ = EC_KEY_new(); - other.genericKey_ = EVP_PKEY_new(); key = other; EXPECT_NE(key.rsa_, nullptr); EXPECT_NE(key.dsa_, nullptr); EXPECT_NE(key.dh_, nullptr); EXPECT_NE(key.ec_, nullptr); - EXPECT_NE(key.genericKey_, nullptr); } HWTEST_F(TLSKeyTest, TLSKeyTestt002, testing::ext::TestSize.Level1) @@ -63,7 +60,6 @@ HWTEST_F(TLSKeyTest, TLSKeyTestt002, testing::ext::TestSize.Level1) key.dsa_ = DSA_new(); key.dh_ = DH_new(); key.ec_ = EC_KEY_new(); - key.genericKey_ = EVP_PKEY_new(); SecureData data; SecureData phrase; key.DecodeData(data, phrase); diff --git a/test/unittest/tlssocket/core/tls_key.test.cpp b/test/unittest/tlssocket/core/tls_key.test.cpp index c71ff75649e80be2f2cd658dc8c8c534ee337ba3..3216a89980cc37f2840cb419f465453afa976537 100644 --- a/test/unittest/tlssocket/core/tls_key.test.cpp +++ b/test/unittest/tlssocket/core/tls_key.test.cpp @@ -42,18 +42,15 @@ HWTEST_F(TLSKeyTest, TLSKeyTestt001, testing::ext::TestSize.Level1) EXPECT_EQ(key.dsa_, nullptr); EXPECT_EQ(key.dh_, nullptr); EXPECT_EQ(key.ec_, nullptr); - EXPECT_EQ(key.genericKey_, nullptr); other.rsa_ = RSA_new(); other.dsa_ = DSA_new(); other.dh_ = DH_new(); other.ec_ = EC_KEY_new(); - other.genericKey_ = EVP_PKEY_new(); key = other; EXPECT_NE(key.rsa_, nullptr); EXPECT_NE(key.dsa_, nullptr); EXPECT_NE(key.dh_, nullptr); EXPECT_NE(key.ec_, nullptr); - EXPECT_NE(key.genericKey_, nullptr); } HWTEST_F(TLSKeyTest, TLSKeyTestt002, testing::ext::TestSize.Level1) @@ -63,7 +60,6 @@ HWTEST_F(TLSKeyTest, TLSKeyTestt002, testing::ext::TestSize.Level1) key.dsa_ = DSA_new(); key.dh_ = DH_new(); key.ec_ = EC_KEY_new(); - key.genericKey_ = EVP_PKEY_new(); SecureData data; SecureData phrase; key.DecodeData(data, phrase);