aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-10-26 13:49:23 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2020-10-26 13:49:23 +0900
commit157f1de64e437cecd75335e9f4077ba9835e3da0 (patch)
treeb0cb5d922a2077c3cebcf41853619e9fde38d0de
parent31def32eeed8cff705ca827e4bbc0bfcc80c512f (diff)
downloadgnupg-157f1de64e437cecd75335e9f4077ba9835e3da0.tar.gz
gpg,tools: Fix detecting OpenPGP card by serialno.
* tools/gpg-card.c (list_openpgp): Use ->apptype to determine card's APP. * g10/card-util.c (get_info_for_key_operation): Likewise. (current_card_status): Even if its SERIALNO is not like OpenPGP card, it's OpenPGP card when app says so. -- GnuPG-bug-id: 5100 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--g10/card-util.c9
-rw-r--r--tools/gpg-card.c4
2 files changed, 6 insertions, 7 deletions
diff --git a/g10/card-util.c b/g10/card-util.c
index b1f57c5b5..3f91fe78f 100644
--- a/g10/card-util.c
+++ b/g10/card-util.c
@@ -385,7 +385,9 @@ current_card_status (ctrl_t ctrl, estream_t fp,
|| strlen (info.serialno) != 32 )
{
const char *name1, *name2;
- if (info.apptype && !strcmp (info.apptype, "NKS"))
+ if (info.apptype && !strcmp (info.apptype, "openpgp"))
+ goto openpgp;
+ else if (info.apptype && !strcmp (info.apptype, "NKS"))
{
name1 = "netkey";
name2 = "NetKey";
@@ -425,7 +427,7 @@ current_card_status (ctrl_t ctrl, estream_t fp,
xfree (pk);
return;
}
-
+ openpgp:
if (!serialno)
;
else if (strlen (info.serialno)+1 > serialnobuflen)
@@ -1253,8 +1255,7 @@ get_info_for_key_operation (struct agent_card_info_s *info)
memset (info, 0, sizeof *info);
rc = agent_scd_getattr ("SERIALNO", info);
- if (rc || !info->serialno || strncmp (info->serialno, "D27600012401", 12)
- || strlen (info->serialno) != 32 )
+ if (rc || !info->apptype || strcmp (info->apptype, "openpgp"))
{
log_error (_("key operation not possible: %s\n"),
rc ? gpg_strerror (rc) : _("not an OpenPGP card"));
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index ba48905e2..7c30ad3aa 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -841,9 +841,7 @@ list_openpgp (card_info_t info, estream_t fp, int no_key_lookup)
{ NULL, NULL }
};
- if (!info->serialno
- || strncmp (info->serialno, "D27600012401", 12)
- || strlen (info->serialno) != 32 )
+ if (info->apptype != APP_TYPE_OPENPGP)
{
tty_fprintf (fp, "invalid OpenPGP card\n");
return;