aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app-help.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-09-21 12:47:53 +0000
committerWerner Koch <[email protected]>2020-09-21 12:47:53 +0000
commit26da47ae53d51e16ae6867cd419ddbf124a94933 (patch)
tree8c343896aacf1e07c71aabdebb457732bc540b14 /scd/app-help.c
parentdoc: Some documentation updates. (diff)
downloadgnupg-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-help.c')
-rw-r--r--scd/app-help.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/scd/app-help.c b/scd/app-help.c
index f2b592399..b599add71 100644
--- a/scd/app-help.c
+++ b/scd/app-help.c
@@ -57,10 +57,12 @@ app_help_count_bits (const unsigned char *a, size_t len)
* function succeeded, the S-expression representing the key is stored
* there. The caller needs to call gcry_sexp_release on that. If
* R_ALGO is not NULL the public key algorithm id of Libgcrypt is
- * stored there. */
+ * stored there. If R_ALGOSTR is not NULL and the function succeeds a
+ * newly allocated algo string (e.g. "rsa2048") is stored there. */
gpg_error_t
app_help_get_keygrip_string_pk (const void *pk, size_t pklen, char *hexkeygrip,
- gcry_sexp_t *r_pkey, int *r_algo)
+ gcry_sexp_t *r_pkey, int *r_algo,
+ char **r_algostr)
{
gpg_error_t err;
gcry_sexp_t s_pkey;
@@ -68,6 +70,8 @@ app_help_get_keygrip_string_pk (const void *pk, size_t pklen, char *hexkeygrip,
if (r_pkey)
*r_pkey = NULL;
+ if (r_algostr)
+ *r_algostr = NULL;
err = gcry_sexp_sscan (&s_pkey, NULL, pk, pklen);
if (err)
@@ -81,6 +85,17 @@ app_help_get_keygrip_string_pk (const void *pk, size_t pklen, char *hexkeygrip,
if (r_algo)
*r_algo = get_pk_algo_from_key (s_pkey);
+ if (r_algostr)
+ {
+ *r_algostr = pubkey_algo_string (s_pkey, NULL);
+ if (!*r_algostr)
+ {
+ err = gpg_error_from_syserror ();
+ gcry_sexp_release (s_pkey);
+ return err;
+ }
+ }
+
if (r_pkey)
*r_pkey = s_pkey;
else
@@ -116,7 +131,7 @@ app_help_get_keygrip_string (ksba_cert_t cert, char *hexkeygrip,
if (!n)
return gpg_error (GPG_ERR_INV_SEXP);
err = app_help_get_keygrip_string_pk ((void*)p, n, hexkeygrip,
- r_pkey, r_algo);
+ r_pkey, r_algo, NULL);
ksba_free (p);
return err;
}