aboutsummaryrefslogtreecommitdiffstats
path: root/g10/skclist.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-04-03 15:45:35 +0000
committerWerner Koch <[email protected]>2019-04-03 15:45:35 +0000
commit2c9b68f28de1ce9a6a18d091caba01ddd4707774 (patch)
treeafc99495166052529ebc54c0d6ce87d758a4fb0d /g10/skclist.c
parentscd: New options --info and --info-only for READKEY. (diff)
downloadgnupg-2c9b68f28de1ce9a6a18d091caba01ddd4707774.tar.gz
gnupg-2c9b68f28de1ce9a6a18d091caba01ddd4707774.zip
gpg: Improve the code to decrypt using PIV cards.
* g10/call-agent.c (agent_scd_keypairinfo): Add arg 'keyref'. * g10/keygen.c (ask_algo): Adjust. * g10/skclist.c (enum_secret_keys): Request the keyref directly. -- This improves commit ec6a6779236a89d4784a6bb7de0def9cc0f9e8a4 to avoid looping over all keypairinfos. This way scdaemon does not need to compute all the keypairinfos for all keys of a card. This patch is possible due the enhanced READKEY command in scdaemon. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/skclist.c')
-rw-r--r--g10/skclist.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/g10/skclist.c b/g10/skclist.c
index b4f83ea1a..c13566e2b 100644
--- a/g10/skclist.c
+++ b/g10/skclist.c
@@ -450,38 +450,31 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
/* KEY-FPR not supported by the card - get
* the key using the keygrip. */
char *keyref;
- strlist_t kplist, sl;
+ strlist_t kplist;
const char *s;
int i;
err = agent_scd_getattr_one ("$ENCRKEYID", &keyref);
if (!err)
{
- err = agent_scd_keypairinfo (ctrl, &kplist);
+ err = agent_scd_keypairinfo (ctrl, keyref,
+ &kplist);
if (!err)
{
- for (sl = kplist; sl; sl = sl->next)
- if ((s = strchr (sl->d, ' '))
- && !strcmp (s+1, keyref))
- break;
- if (sl)
- {
- c->fpr2[0] = '&';
- for (i=1, s=sl->d;
- (*s && *s != ' '
- && i < sizeof c->fpr2 - 3);
- s++, i++)
- c->fpr2[i] = *s;
- c->fpr2[i] = 0;
- name = c->fpr2;
- }
- else /* Restore error. */
- err = gpg_error (GPG_ERR_INV_NAME);
+ c->fpr2[0] = '&';
+ for (i=1, s=kplist->d;
+ (*s && *s != ' '
+ && i < sizeof c->fpr2 - 3);
+ s++, i++)
+ c->fpr2[i] = *s;
+ c->fpr2[i] = 0;
+ name = c->fpr2;
free_strlist (kplist);
}
+ xfree (keyref);
}
- xfree (keyref);
}
+
if (err)
log_error ("error retrieving key from card: %s\n",
gpg_strerror (err));