mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
gpg: Fix default-key selection when card is available.
* g10/getkey.c (get_seckey_default_or_card): Handle the case when card key is not suitable for requested usage. -- GnuPG-bug-id: 4850 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
60dbe08294
commit
1cdd9e57f7
10
g10/getkey.c
10
g10/getkey.c
@ -3810,7 +3810,15 @@ get_seckey_default_or_card (ctrl_t ctrl, PKT_public_key *pk,
|
||||
if (def_secret_key)
|
||||
add_to_strlist (&namelist, def_secret_key);
|
||||
else if (fpr_card)
|
||||
return get_pubkey_byfprint (ctrl, pk, NULL, fpr_card, fpr_len);
|
||||
{
|
||||
int rc = get_pubkey_byfprint (ctrl, pk, NULL, fpr_card, fpr_len);
|
||||
|
||||
/* The key on card can be not suitable for requested usage. */
|
||||
if (rc == GPG_ERR_UNUSABLE_PUBKEY)
|
||||
fpr_card = NULL; /* Fallthrough as no card. */
|
||||
else
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!fpr_card
|
||||
|| (def_secret_key && def_secret_key[strlen (def_secret_key)-1] == '!'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user