summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2024-05-06 09:48:20 +0200
committerWerner Koch <wk@gnupg.org>2024-05-06 09:48:20 +0200
commit473f37a53ef4896995fe6b3cc05e95bd3ed25449 (patch)
tree27588159ba1964651b6b4ef49a9dcc5f9c71306f /tools
parentspeedo: Update the instructions to use the gnupg26 tag. (diff)
downloadgnupg2-473f37a53ef4896995fe6b3cc05e95bd3ed25449.tar.xz
gnupg2-473f37a53ef4896995fe6b3cc05e95bd3ed25449.zip
scd:piv: Support listing of retired keys with KEYINFO.
* scd/app-piv.c (data_objects): Mark returned key as having a keypair. (do_with_keygrip): Check against encrusage and not used one tag. * tools/gpg-card.c (piv_keyref_is_retired): New. (list_all_kinfo): Pretty print retired keys. -- This allows to list all existing retired keys without using separate readkey commands.
Diffstat (limited to 'tools')
-rw-r--r--tools/gpg-card.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index f24b74194..8b3a3082b 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -836,6 +836,21 @@ list_one_kinfo (card_info_t info, key_info_t kinfo,
}
+/* Return the retired key number if KEYREF is for a retired key; 0 if
+ * not. */
+static int
+piv_keyref_is_retired (const char *keyref)
+{
+ if (!strncmp (keyref, "PIV.8", 5)
+ && keyref[5] >= '2' && hexdigitp (keyref + 5))
+ return xtoi_1 (keyref+5) - 1;
+ else if (!strncmp (keyref, "PIV.9", 5)
+ && keyref[5] >= '0' && keyref[5] <= '5')
+ return atoi_1 (keyref+5) + 15;
+ else
+ return 0;
+}
+
/* List all keyinfo in INFO using the list of LABELS. */
static void
list_all_kinfo (card_info_t info, keyinfolabel_t labels, estream_t fp,
@@ -843,6 +858,7 @@ list_all_kinfo (card_info_t info, keyinfolabel_t labels, estream_t fp,
{
key_info_t kinfo;
int idx, i, j;
+ int rn;
/* Print the keyinfo. We first print those we known and then all
* remaining item. */
@@ -864,9 +880,15 @@ list_all_kinfo (card_info_t info, keyinfolabel_t labels, estream_t fp,
{
if (kinfo->xflag)
continue;
- tty_fprintf (fp, "Key %s", kinfo->keyref);
- for (i=4+strlen (kinfo->keyref), j=0; i < 18; i++, j=1)
- tty_fprintf (fp, j? ".":" ");
+ if (info->apptype == APP_TYPE_PIV
+ && (rn = piv_keyref_is_retired (kinfo->keyref)))
+ tty_fprintf (fp, "Key retired %2d ...", rn);
+ else
+ {
+ tty_fprintf (fp, "Key %s", kinfo->keyref);
+ for (i=4+strlen (kinfo->keyref), j=0; i < 18; i++, j=1)
+ tty_fprintf (fp, j? ".":" ");
+ }
tty_fprintf (fp, ":");
list_one_kinfo (info, kinfo, NULL, fp, no_key_lookup, create_shadow);
}