aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/model/GpgKey.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-12-03 13:01:27 +0000
committersaturneric <[email protected]>2023-12-03 13:01:27 +0000
commitd0602f09564d3d200b20e83a977315134ced842e (patch)
treeb9cd6f429983a0c9bce51e7fb711b894d634601b /src/core/model/GpgKey.cpp
parentfeat: general improvements of aync execution and memory security (diff)
downloadGpgFrontend-d0602f09564d3d200b20e83a977315134ced842e.tar.gz
GpgFrontend-d0602f09564d3d200b20e83a977315134ced842e.zip
fix: slove issues in key/subkey generation
Diffstat (limited to 'src/core/model/GpgKey.cpp')
-rw-r--r--src/core/model/GpgKey.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp
index 8a7f5a6e..9e6df32b 100644
--- a/src/core/model/GpgKey.cpp
+++ b/src/core/model/GpgKey.cpp
@@ -41,13 +41,13 @@ auto GpgKey::operator=(GpgKey &&k) noexcept -> GpgKey & {
return *this;
}
-GpgKey::GpgKey(const GpgKey &key) noexcept {
+GpgKey::GpgKey(const GpgKey &key) {
+ auto *key_ref = key.key_ref_.get();
{
const std::lock_guard<std::mutex> guard(gpgme_key_opera_mutex_);
- gpgme_key_ref(key.key_ref_.get());
+ gpgme_key_ref(key_ref);
}
- auto *new_key_ref = key_ref_.get();
- this->key_ref_ = KeyRefHandler(std::move(new_key_ref));
+ this->key_ref_ = KeyRefHandler(key_ref);
}
auto GpgKey::operator=(const GpgKey &key) -> GpgKey & {
@@ -55,13 +55,12 @@ auto GpgKey::operator=(const GpgKey &key) -> GpgKey & {
return *this;
}
+ auto *key_ref = key.key_ref_.get();
{
const std::lock_guard<std::mutex> guard(gpgme_key_opera_mutex_);
- gpgme_key_ref(key.key_ref_.get());
+ gpgme_key_ref(key_ref);
}
- auto *new_key_ref = key_ref_.get();
- this->key_ref_ = KeyRefHandler(std::move(new_key_ref));
-
+ this->key_ref_ = KeyRefHandler(key_ref);
return *this;
}
@@ -248,15 +247,6 @@ auto GpgKey::IsHasActualEncryptionCapability() const -> bool {
});
}
-auto GpgKey::Copy() const -> GpgKey {
- {
- const std::lock_guard<std::mutex> guard(gpgme_key_opera_mutex_);
- gpgme_key_ref(key_ref_.get());
- }
- auto *new_key_ref = key_ref_.get();
- return GpgKey(std::move(new_key_ref));
-}
-
void GpgKey::KeyRefDeleter::operator()(gpgme_key_t _key) {
if (_key != nullptr) gpgme_key_unref(_key);
}