diff --git a/NEWS b/NEWS index f5dd953d..40663afc 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ Noteworthy changes in version 1.14.0 (unreleased) ------------------------------------------------- + * New keylist mode to force the engine to return the keygrip. [#4820] + * New context flag "extended-edit" to enable expert key edit. [#4734] * cpp: Add convenience API to obtain remarks. [#4734] @@ -18,6 +20,7 @@ Noteworthy changes in version 1.14.0 (unreleased) * Interface changes relative to the 1.13.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + GPGME_KEYLIST_MODE_WITH_KEYGRIP NEW. gpgme_user_id_t EXTENDED: New field 'uidhash'. cpp: UserID::remark NEW. cpp: UserID::remarks NEW. diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 3c9594f5..2eda0117 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -2820,6 +2820,13 @@ The @code{GPGME_KEYLIST_MODE_WITH_TOFU} symbol specifies that information pertaining to the TOFU trust model should be included in the listed keys. +@item GPGME_KEYLIST_MODE_WITH_KEYGRIP +@since{1.14.0} + +The @code{GPGME_KEYLIST_MODE_WITH_KEYRIP} symbol specifies that the +keygrip is always included in the listing. The default depends on the +version of the backend and the used protocol. + @item GPGME_KEYLIST_MODE_WITH_SECRET @since{1.5.1} diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index c0a1dc21..002b20f5 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -1615,6 +1615,7 @@ std::ostream &operator<<(std::ostream &os, KeyListMode mode) CHECK(Validate); CHECK(Ephemeral); CHECK(WithTofu); + CHECK(WithKeygrip); #undef CHECK return os << ')'; } diff --git a/lang/cpp/src/global.h b/lang/cpp/src/global.h index d5c2e135..7a88dc32 100644 --- a/lang/cpp/src/global.h +++ b/lang/cpp/src/global.h @@ -65,7 +65,8 @@ enum KeyListMode { SignatureNotations = 0x8, Validate = 0x10, Ephemeral = 0x20, - WithTofu = 0x40 + WithTofu = 0x40, + WithKeygrip = 0x80 }; enum SignatureMode { NormalSignatureMode, Detached, Clearsigned }; diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index 73045fb3..c422fcc5 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -358,7 +358,8 @@ void Key::update() KeyListMode::Signatures | KeyListMode::SignatureNotations | KeyListMode::Validate | - KeyListMode::WithTofu); + KeyListMode::WithTofu | + KeyListMode::WithKeygrip); Error err; auto newKey = ctx->key(primaryFingerprint(), err, true); // Not secret so we get the information from the pubring. diff --git a/lang/cpp/src/util.h b/lang/cpp/src/util.h index 4495cc02..1c0477f4 100644 --- a/lang/cpp/src/util.h +++ b/lang/cpp/src/util.h @@ -81,6 +81,9 @@ static inline gpgme_keylist_mode_t add_to_gpgme_keylist_mode_t(unsigned int oldm if (newmodes & GpgME::WithTofu) { oldmode |= GPGME_KEYLIST_MODE_WITH_TOFU; } + if (newmodes & GpgME::WithKeygrip) { + oldmode |= GPGME_KEYLIST_MODE_WITH_KEYGRIP; + } #ifndef NDEBUG if (newmodes & ~(GpgME::Local | GpgME::Extern | GpgME::Signatures | GpgME::SignatureNotations | GpgME::Ephemeral | GpgME::Validate)) { //std::cerr << "GpgME::Context: keylist mode must be one of Local, " diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp index 1e9f81f5..bfe82e30 100644 --- a/lang/cpp/src/verificationresult.cpp +++ b/lang/cpp/src/verificationresult.cpp @@ -413,7 +413,8 @@ GpgME::Key GpgME::Signature::key(bool search, bool update) const KeyListMode::Signatures | KeyListMode::SignatureNotations | KeyListMode::Validate | - KeyListMode::WithTofu); + KeyListMode::WithTofu | + KeyListMode::WithKeygrip); Error e; ret = d->keys[idx] = ctx->key(fingerprint(), e, false); delete ctx; diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 73e5245a..c343e80e 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -3001,6 +3001,11 @@ gpg_keylist_build_options (engine_gpg_t gpg, int secret_only, err = add_arg (gpg, "--with-secret"); err = add_arg (gpg, "--with-keygrip"); } + else if (!err && (mode & GPGME_KEYLIST_MODE_WITH_KEYGRIP)) + { + /* Explicitly requests the keygrip. */ + err = add_arg (gpg, "--with-keygrip"); + } if (!err && (mode & GPGME_KEYLIST_MODE_SIGS) diff --git a/src/gpgme-json.c b/src/gpgme-json.c index 7957659d..bcaa1fc0 100644 --- a/src/gpgme-json.c +++ b/src/gpgme-json.c @@ -2298,6 +2298,7 @@ static const char hlp_keylist[] = "sigs: Add KEYLIST_MODE_SIGS.\n" "notations: Add KEYLIST_MODE_SIG_NOTATIONS.\n" "tofu: Add KEYLIST_MODE_WITH_TOFU.\n" + "keygrip: Add KEYLIST_MODE_WITH_KEYGRIP.\n" "ephemeral: Add KEYLIST_MODE_EPHEMERAL.\n" "validate: Add KEYLIST_MODE_VALIDATE.\n" "locate: Add KEYLIST_MODE_LOCATE.\n" @@ -2463,6 +2464,11 @@ op_keylist (cjson_t request, cjson_t result) if (abool) mode |= GPGME_KEYLIST_MODE_WITH_TOFU; + if ((err = get_boolean_flag (request, "keygrip", 0, &abool))) + goto leave; + if (abool) + mode |= GPGME_KEYLIST_MODE_WITH_KEYGRIP; + if ((err = get_boolean_flag (request, "ephemeral", 0, &abool))) goto leave; if (abool) diff --git a/src/gpgme.h.in b/src/gpgme.h.in index a52901bb..4efa325d 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -379,6 +379,7 @@ gpgme_protocol_t; #define GPGME_KEYLIST_MODE_SIG_NOTATIONS 8 #define GPGME_KEYLIST_MODE_WITH_SECRET 16 #define GPGME_KEYLIST_MODE_WITH_TOFU 32 +#define GPGME_KEYLIST_MODE_WITH_KEYGRIP 64 #define GPGME_KEYLIST_MODE_EPHEMERAL 128 #define GPGME_KEYLIST_MODE_VALIDATE 256 @@ -600,7 +601,7 @@ struct _gpgme_subkey /* The name of the curve for ECC algorithms or NULL. */ char *curve; - /* The keygrip of the subkey in hex digit form or NULL if not availabale. */ + /* The keygrip of the subkey in hex digit form or NULL if not available. */ char *keygrip; }; typedef struct _gpgme_subkey *gpgme_subkey_t;