From 5264d3f58e8a8362900c3518bdd683ff9a23cccc Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 26 May 2022 12:01:16 +0900 Subject: scd: Return USAGE information for KEYINFO command. * scd/command.c (hlp_keyinfo): Update. (send_keyinfo): Add a USAGE argument. * scd/scdaemon.h (send_keyinfo): Add a USAGE argument. * scd/app-nks.c (set_usage_string): New. (do_learn_status_core, do_readkey): Use set_usage_string. (do_with_keygrip): Add USAGE to call send_keyinfo, using set_usage_string. * scd/app-openpgp.c (get_usage_string): New. (send_keypair_info): Use get_usage_string. (send_keyinfo_if_available): Add USAGE to call send_keyinfo, using get_usage_string. * scd/app-p15.c (set_usage_string): New. (send_keypairinfo): Use set_usage_string. (do_with_keygrip): Add USAGE to call send_keyinfo, using set_usage_string. * scd/app-piv.c (do_with_keygrip): Add USAGE to call send_keyinfo. -- Signed-off-by: NIIBE Yutaka --- scd/command.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'scd/command.c') diff --git a/scd/command.c b/scd/command.c index 28fdfcb62..b9303b546 100644 --- a/scd/command.c +++ b/scd/command.c @@ -2235,7 +2235,7 @@ static const char hlp_keyinfo[] = "Unless --data is given, the\n" "information is returned as a status line using the format:\n" "\n" - " KEYINFO T \n" + " KEYINFO T \n" "\n" "KEYGRIP is the keygrip.\n" "\n" @@ -2243,9 +2243,13 @@ static const char hlp_keyinfo[] = " smartcard. If the serial number is not known a single\n" " dash '-' is used instead.\n" "\n" - "IDSTR is the IDSTR used to distinguish keys on a smartcard. If it\n" + "IDSTR is a string used to distinguish keys on a smartcard. If it\n" " is not known a dash is used instead.\n" "\n" + "USAGE is a string of capabilities of the key, 's' for sign, \n" + "'e' for encryption, 'a' for auth, and 'c' for cert. If it is not\n" + "known a dash is used instead.\n" + "\n" "More information may be added in the future."; static gpg_error_t cmd_keyinfo (assuan_context_t ctx, char *line) @@ -2290,14 +2294,15 @@ cmd_keyinfo (assuan_context_t ctx, char *line) * line. */ void send_keyinfo (ctrl_t ctrl, int data, const char *keygrip_str, - const char *serialno, const char *idstr) + const char *serialno, const char *idstr, const char *usage) { char *string; assuan_context_t ctx = ctrl->server_local->assuan_ctx; - string = xtryasprintf ("%s T %s %s%s", keygrip_str, + string = xtryasprintf ("%s T %s %s %s%s", keygrip_str, serialno? serialno : "-", idstr? idstr : "-", + usage? usage : "-", data? "\n" : ""); if (!string) -- cgit v1.2.3