aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/model/GpgKey.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-12-03 12:28:46 +0000
committersaturneric <[email protected]>2023-12-03 12:28:46 +0000
commit883db05d54510e76b6548e107593187e1306117d (patch)
treea4de9d60d3bfeb69ba443129d208feef65250b2c /src/core/model/GpgKey.cpp
parentfeat: improve memory security of function framework (diff)
downloadGpgFrontend-883db05d54510e76b6548e107593187e1306117d.tar.gz
GpgFrontend-883db05d54510e76b6548e107593187e1306117d.zip
feat: general improvements of aync execution and memory security
Diffstat (limited to 'src/core/model/GpgKey.cpp')
-rw-r--r--src/core/model/GpgKey.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp
index a183c240..8a7f5a6e 100644
--- a/src/core/model/GpgKey.cpp
+++ b/src/core/model/GpgKey.cpp
@@ -41,6 +41,30 @@ auto GpgKey::operator=(GpgKey &&k) noexcept -> GpgKey & {
return *this;
}
+GpgKey::GpgKey(const GpgKey &key) noexcept {
+ {
+ const std::lock_guard<std::mutex> guard(gpgme_key_opera_mutex_);
+ gpgme_key_ref(key.key_ref_.get());
+ }
+ auto *new_key_ref = key_ref_.get();
+ this->key_ref_ = KeyRefHandler(std::move(new_key_ref));
+}
+
+auto GpgKey::operator=(const GpgKey &key) -> GpgKey & {
+ if (this == &key) {
+ return *this;
+ }
+
+ {
+ const std::lock_guard<std::mutex> guard(gpgme_key_opera_mutex_);
+ gpgme_key_ref(key.key_ref_.get());
+ }
+ auto *new_key_ref = key_ref_.get();
+ this->key_ref_ = KeyRefHandler(std::move(new_key_ref));
+
+ return *this;
+}
+
auto GpgKey::operator==(const GpgKey &o) const -> bool {
return o.GetId() == this->GetId();
}