From 26da47ae53d51e16ae6867cd419ddbf124a94933 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 21 Sep 2020 14:47:53 +0200 Subject: scd: Extend KEYPAIRINFO with an algorithm string. * scd/app-openpgp.c (send_keypair_info): Emit the algo string as part of a KEYPAIRINFO. * scd/command.c (do_readkey): Ditto. * scd/app-piv.c (do_readkey): Ditto. * scd/app-nks.c (do_learn_status_core): Ditto. (struct fid_cache_s): Add field algostr. (flush_fid_cache): Release it. (keygripstr_from_pk_file): Fill it and add it to the cache. Use a single exit label. * scd/app-help.c (app_help_get_keygrip_string_pk): Add new arg r_algostr. Change all callers. -- This is helpful so that callers do not need to parse the key for this basic information. Use "scd readkey --info-only" to return the info status line instead of the key material; using just --info returns the info in addition to the key material. Signed-off-by: Werner Koch --- scd/command.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'scd/command.c') diff --git a/scd/command.c b/scd/command.c index e2d366d47..56d422a4a 100644 --- a/scd/command.c +++ b/scd/command.c @@ -433,7 +433,7 @@ static const char hlp_learn[] = "or a \"CANCEL\" to force the function to terminate with a Cancel\n" "error message.\n" "\n" - "With the option --keypairinfo only KEYPARIINFO status lines are\n" + "With the option --keypairinfo only KEYPAIRINFO status lines are\n" "returned.\n" "\n" "The response of this command is a list of status lines formatted as\n" @@ -650,9 +650,11 @@ do_readkey (card_t card, ctrl_t ctrl, const char *line, if (opt_info) { char keygripstr[KEYGRIP_LEN*2+1]; + char *algostr; rc = app_help_get_keygrip_string_pk (*pk_p, *pklen_p, - keygripstr, NULL, NULL); + keygripstr, NULL, NULL, + &algostr); if (rc) { log_error ("app_help_get_keygrip_string failed: %s\n", @@ -665,7 +667,11 @@ do_readkey (card_t card, ctrl_t ctrl, const char *line, send_status_info (ctrl, "KEYPAIRINFO", keygripstr, strlen (keygripstr), line, strlen (line), + "-", (size_t)1, + "-", (size_t)1, + algostr, strlen (algostr), NULL, (size_t)0); + xfree (algostr); } } else -- cgit v1.2.3