summaryrefslogtreecommitdiffstats
path: root/g10/gpg.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2021-05-19 02:32:19 +0200
committerWerner Koch <wk@gnupg.org>2021-05-19 02:42:35 +0200
commit40da61b89b62dcb77847dc79eb159e885f52f817 (patch)
treecc96e9d8b54046a2a541f066c9e579921f07e523 /g10/gpg.h
parentgpg: Fix sending an OpenPGP key with umlaut to an LDAP keyserver. (diff)
downloadgnupg2-40da61b89b62dcb77847dc79eb159e885f52f817.tar.xz
gnupg2-40da61b89b62dcb77847dc79eb159e885f52f817.zip
gpg: Improve speed of secret key listing.
* agent/command.c (cmd_keyinfo): Factor some code out to ... (get_keyinfo_on_cards): ... new. (cmd_havekey): Add --list mode. * g10/gpg.h (struct server_control_s): Add new caching vars. * g10/gpg.c (gpg_deinit_default_ctrl): Release cache. * g10/call-agent.c (agent_probe_any_secret_key): Init and try to use the keygrip cache. (agent_genkey): Clear the cache. (agent_import_key): Ditto. * g10/keylist.c (list_all, list_one): Pass ctrl to agent_probe_any_secret_key. * g10/getkey.c (lookup): Ditto. -- With this change we first ask the agent for a list of all secret keygrips and use that list instead of asking the agent for each public key. Speeds up my "gpg -K" with a lot of secret and public keys by more than 25%. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/gpg.h')
-rw-r--r--g10/gpg.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/g10/gpg.h b/g10/gpg.h
index d4e66e72d..c51bbbb46 100644
--- a/g10/gpg.h
+++ b/g10/gpg.h
@@ -110,6 +110,14 @@ struct server_control_s
/* This is used to cache a key data base handle. */
KEYDB_HANDLE cached_getkey_kdb;
+
+ /* Cached results from HAVEKEY --list. They are used if the pointer
+ * is not NULL. The length gives the length in bytes and is a
+ * multiple of 20. If the no_more flag is set the list shall not
+ * anymore be refreshed even if it has been freed and NULLed. */
+ unsigned char *secret_keygrips;
+ size_t secret_keygrips_len;
+ int no_more_secret_keygrips;
};