1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

gpg: Prefer card key on use in multiple subkeys situation.

* g10/call-agent.c (keyinfo_status_cb): Parse more fields.
(agent_probe_secret_key): Use KEYINFO and returns bigger value
representing the preference.
* g10/getkey.c (finish_lookup): For subkeys, select one
by using value of agent_probe_secret_key.

--

GnuPG-bug-id: 3416
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-01-17 16:03:53 +09:00
parent 853d5b7677
commit 8748c50bfa
2 changed files with 80 additions and 42 deletions

View file

@ -3470,6 +3470,7 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact,
kbnode_t nextk;
int n_subkeys = 0;
int n_revoked_or_expired = 0;
int last_secret_key_avail = 0;
/* Either start a loop or check just this one subkey. */
for (k = foundk ? foundk : keyblock; k; k = nextk)
@ -3527,11 +3528,23 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact,
continue;
}
if (want_secret && !agent_probe_secret_key (NULL, pk))
if (want_secret)
{
if (DBG_LOOKUP)
log_debug ("\tno secret key\n");
continue;
int secret_key_avail = agent_probe_secret_key (NULL, pk);
if (!secret_key_avail)
{
if (DBG_LOOKUP)
log_debug ("\tno secret key\n");
continue;
}
if (secret_key_avail > last_secret_key_avail)
{
/* Use this key. */
last_secret_key_avail = secret_key_avail;
latest_date = 0;
}
}
if (DBG_LOOKUP)