diff options
author | JinWang An <jinwang.an@samsung.com> | 2021-12-01 16:54:36 +0900 |
---|---|---|
committer | JinWang An <jinwang.an@samsung.com> | 2021-12-01 16:54:36 +0900 |
commit | 10e16af58579b2e22154d944d8cb4144924a8406 (patch) | |
tree | 035206c11f62125c4b8aa66fb36daeb071c90184 /lang/cpp/src/verificationresult.cpp | |
parent | e158cb38f461261d019c653a5f5e0ca9ddab8d6d (diff) | |
download | gpgme-10e16af58579b2e22154d944d8cb4144924a8406.tar.gz gpgme-10e16af58579b2e22154d944d8cb4144924a8406.tar.bz2 gpgme-10e16af58579b2e22154d944d8cb4144924a8406.zip |
Imported Upstream version 1.7.1upstream/1.7.1
Diffstat (limited to 'lang/cpp/src/verificationresult.cpp')
-rw-r--r-- | lang/cpp/src/verificationresult.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp index c62625d..23c458e 100644 --- a/lang/cpp/src/verificationresult.cpp +++ b/lang/cpp/src/verificationresult.cpp @@ -20,11 +20,16 @@ Boston, MA 02110-1301, USA. */ +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + #include <verificationresult.h> #include <notation.h> #include "result_p.h" #include "util.h" #include "key.h" +#include "context.h" #include <gpgme.h> @@ -68,6 +73,8 @@ public: // copy keys if (scopy->key) { keys.push_back(Key(scopy->key, true)); + } else { + keys.push_back(Key()); } // copy notations: nota.push_back(std::vector<Nota>()); @@ -115,6 +122,7 @@ public: std::vector<GpgME::Key> keys; std::vector<char *> purls; std::string file_name; + Protocol proto; }; GpgME::VerificationResult::VerificationResult(gpgme_ctx_t ctx, int error) @@ -139,6 +147,10 @@ void GpgME::VerificationResult::init(gpgme_ctx_t ctx) return; } d.reset(new Private(res)); + gpgme_protocol_t proto = gpgme_get_protocol(ctx); + d->proto = proto == GPGME_PROTOCOL_OpenPGP ? OpenPGP : + proto == GPGME_PROTOCOL_CMS ? CMS : + UnknownProtocol; } make_standard_stuff(VerificationResult) @@ -380,6 +392,32 @@ GpgME::Key GpgME::Signature::key() const return d->keys[idx]; } +GpgME::Key GpgME::Signature::key(bool search, bool update) const +{ + if (isNull()) { + return Key(); + } + + GpgME::Key ret = key(); + if (ret.isNull() && search) { + auto ctx = Context::createForProtocol (d->proto); + if (ctx) { + ctx->setKeyListMode(KeyListMode::Local | + KeyListMode::Signatures | + KeyListMode::SignatureNotations | + KeyListMode::Validate | + KeyListMode::WithTofu); + Error e; + ret = d->keys[idx] = ctx->key(fingerprint(), e, false); + delete ctx; + } + } + if (update) { + ret.update(); + } + return ret; +} + class GpgME::Notation::Private { public: |