diff options
author | saturneric <[email protected]> | 2023-12-03 13:01:27 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2023-12-03 13:01:27 +0000 |
commit | d0602f09564d3d200b20e83a977315134ced842e (patch) | |
tree | b9cd6f429983a0c9bce51e7fb711b894d634601b /src/core/function/gpg | |
parent | feat: general improvements of aync execution and memory security (diff) | |
download | GpgFrontend-d0602f09564d3d200b20e83a977315134ced842e.tar.gz GpgFrontend-d0602f09564d3d200b20e83a977315134ced842e.zip |
fix: slove issues in key/subkey generation
Diffstat (limited to 'src/core/function/gpg')
-rw-r--r-- | src/core/function/gpg/GpgKeyGetter.cpp | 8 | ||||
-rw-r--r-- | src/core/function/gpg/GpgKeyOpera.cpp | 3 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp index 5215f34b..cad2d884 100644 --- a/src/core/function/gpg/GpgKeyGetter.cpp +++ b/src/core/function/gpg/GpgKeyGetter.cpp @@ -82,7 +82,7 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> { auto keys_list = std::make_unique<GpgKeyLinkList>(); for (const auto& [key, value] : keys_cache_) { - keys_list->push_back(value.Copy()); + keys_list->push_back(value); } return keys_list; } @@ -140,7 +140,7 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> { // get the lock std::lock_guard<std::mutex> lock(ctx_mutex_); auto keys_copy = std::make_unique<GpgKeyLinkList>(); - for (const auto& key : *keys) keys_copy->emplace_back(key.Copy()); + for (const auto& key : *keys) keys_copy->emplace_back(key); return keys_copy; } @@ -148,7 +148,7 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> { // get the lock std::lock_guard<std::mutex> lock(ctx_mutex_); auto keys_copy = std::make_unique<KeyArgsList>(); - for (const auto& key : *keys) keys_copy->emplace_back(key.Copy()); + for (const auto& key : *keys) keys_copy->emplace_back(key); return keys_copy; } @@ -189,7 +189,7 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> { if (keys_cache_.find(key_id) != keys_cache_.end()) { std::lock_guard<std::mutex> lock(ctx_mutex_); // return a copy of the key in cache - return keys_cache_[key_id].Copy(); + return keys_cache_[key_id]; } // return a bad key diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp index 1c4c78a5..b4aa85eb 100644 --- a/src/core/function/gpg/GpgKeyOpera.cpp +++ b/src/core/function/gpg/GpgKeyOpera.cpp @@ -216,8 +216,7 @@ void GpgKeyOpera::GenerateSubkey(const GpgKey& key, const std::shared_ptr<GenKeyInfo>& params, const GpgOperationCallback& callback) { RunGpgOperaAsync( - [key = key.Copy(), &ctx = ctx_, - params](const DataObjectPtr&) -> GpgError { + [key, &ctx = ctx_, params](const DataObjectPtr&) -> GpgError { if (!params->IsSubKey()) return GPG_ERR_CANCELED; SPDLOG_DEBUG("generate subkey algo {} key size {}", params->GetAlgo(), |