diff options
| author | Werner Koch <[email protected]> | 2020-09-21 12:47:53 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2020-09-21 12:47:53 +0000 |
| commit | 26da47ae53d51e16ae6867cd419ddbf124a94933 (patch) | |
| tree | 8c343896aacf1e07c71aabdebb457732bc540b14 /scd/app-openpgp.c | |
| parent | doc: Some documentation updates. (diff) | |
| download | gnupg-26da47ae53d51e16ae6867cd419ddbf124a94933.tar.gz gnupg-26da47ae53d51e16ae6867cd419ddbf124a94933.zip | |
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 <[email protected]>
Diffstat (limited to 'scd/app-openpgp.c')
| -rw-r--r-- | scd/app-openpgp.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index 465819adc..c631383c0 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -2049,6 +2049,7 @@ send_keypair_info (app_t app, ctrl_t ctrl, int key) gpg_error_t err = 0; const char *usage; u32 fprtime; + char *algostr = NULL; err = get_public_key (app, keyno); if (err) @@ -2069,11 +2070,29 @@ send_keypair_info (app_t app, ctrl_t ctrl, int key) if (retrieve_fprtime_from_card (app, keyno, &fprtime)) fprtime = 0; - err = send_status_printf (ctrl, "KEYPAIRINFO", "%s OPENPGP.%d %s %lu", + { + gcry_sexp_t s_pkey; + if (gcry_sexp_new (&s_pkey, app->app_local->pk[keyno].key, + app->app_local->pk[keyno].keylen, 0)) + algostr = xtrystrdup ("?"); + else + { + algostr = pubkey_algo_string (s_pkey, NULL); + gcry_sexp_release (s_pkey); + } + } + if (!algostr) + { + err = gpg_error_from_syserror (); + goto leave; + } + + err = send_status_printf (ctrl, "KEYPAIRINFO", "%s OPENPGP.%d %s %lu %s", app->app_local->pk[keyno].keygrip_str, - keyno+1, usage, (unsigned long)fprtime); + keyno+1, usage, (unsigned long)fprtime, algostr); leave: + xfree (algostr); return err; } |
