From 21496761226c1020a98e3ec7dd2b9dd013d4386b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 27 May 2020 13:47:13 +0200 Subject: [PATCH] scd:openpgp: New KEY-STATUS attribute. * scd/app-openpgp.c (do_getattr): Return KEY-STATUS --- doc/DETAILS | 8 ++++++++ scd/app-openpgp.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/DETAILS b/doc/DETAILS index a1c53b88e..c22c14b72 100644 --- a/doc/DETAILS +++ b/doc/DETAILS @@ -1178,6 +1178,14 @@ pkd:0:1024:B665B1435F4C2 .... FF26ABB: name of the manufacturer is also given as ; spaces are not escaped. For PKCS#15 cards is TokenInfo.manufactorerID. +*** KEY-STATUS + This is the response from scdaemon on GETATTR KEY-STATUS for + OpenPGP cards. is the usual keyref (e.g. OPENPGP.1 or + OPENPGP.129) and is an integer describing the status of + the key: 0 = key is not present, 1 = key generated on card, 2 = + key imported. See section 4.4.3.8 of the OpenPGP Smart Card + Application V3.4. + * Format of the --attribute-fd output When --attribute-fd is set, during key listings (--list-keys, diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index 6c0c0f6d9..fe4c95a4e 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -1080,9 +1080,10 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name) { "UIF-1", 0x00D6, 0 }, { "UIF-2", 0x00D7, 0 }, { "UIF-3", 0x00D8, 0 }, - { "UIF", 0x0000, -9 }, /* Shortcut for all UIF */ { "KDF", 0x00F9, 5 }, { "MANUFACTURER", 0x0000, -8 }, + { "UIF", 0x0000, -9 }, /* Shortcut for all UIF */ + { "KEY-STATUS", 0x00DE, 6 }, { NULL, 0 } }; int idx, i, rc; @@ -1234,6 +1235,14 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name) send_status_info (ctrl, table[idx].name, value, valuelen, NULL, 0); } + else if (table[idx].special == 6) + { + for (i=0,rc=0; !rc && i+1 < valuelen; i += 2) + rc = send_status_printf (ctrl, table[idx].name, "OPENPGP.%u %u", + value[i], value[i+1]); + if (gpg_err_code (rc) == GPG_ERR_NO_OBJ) + rc = gpg_error (GPG_ERR_NOT_SUPPORTED); + } else send_status_info (ctrl, table[idx].name, value, valuelen, NULL, 0);