mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Add new option --with-secret.
* g10/gpg.c: Add option --with-secret. * g10/options.h (struct opt): Add field with_secret. * g10/keylist.c (public_key_list): Pass opt.with_secret to list_all and list_one. (list_all, list_one): Add arg mark_secret. (list_keyblock_colon): Add arg has_secret. * sm/gpgsm.c: Add option --with-secret. * sm/server.c (option_handler): Add option "with-secret". * sm/gpgsm.h (server_control_s): Add field with_secret. * sm/keylist.c (list_cert_colon): Take care of with_secret. Also move the token string from the wrong field 14 to 15. -- This option is useful for key managers which need to know whether a key has a secret key. This change allows to collect this information in one pass.
This commit is contained in:
parent
d89dc6917e
commit
be07ed65e1
14 changed files with 88 additions and 30 deletions
14
sm/keylist.c
14
sm/keylist.c
|
@ -457,7 +457,6 @@ list_cert_colon (ctrl_t ctrl, ksba_cert_t cert, unsigned int validity,
|
|||
algo = gpgsm_get_key_algo_info (cert, &nbits);
|
||||
es_fprintf (fp, ":%u:%d:%s:", nbits, algo, fpr+24);
|
||||
|
||||
/* We assume --fixed-list-mode for gpgsm */
|
||||
ksba_cert_get_validity (cert, 0, t);
|
||||
print_time (t, fp);
|
||||
es_putc (':', fp);
|
||||
|
@ -495,19 +494,24 @@ list_cert_colon (ctrl_t ctrl, ksba_cert_t cert, unsigned int validity,
|
|||
es_putc (':', fp);
|
||||
/* Field 12, capabilities: */
|
||||
print_capabilities (cert, fp);
|
||||
es_putc (':', fp);
|
||||
/* Field 13, not used: */
|
||||
es_putc (':', fp);
|
||||
if (have_secret)
|
||||
if (have_secret || ctrl->with_secret)
|
||||
{
|
||||
char *cardsn;
|
||||
|
||||
p = gpgsm_get_keygrip_hexstring (cert);
|
||||
if (!gpgsm_agent_keyinfo (ctrl, p, &cardsn) && cardsn)
|
||||
if (!gpgsm_agent_keyinfo (ctrl, p, &cardsn)
|
||||
&& (cardsn || ctrl->with_secret))
|
||||
{
|
||||
/* Field 14, not used: */
|
||||
es_putc (':', fp);
|
||||
/* Field 15: Token serial number. */
|
||||
es_fputs (cardsn, fp);
|
||||
/* Field 15: Token serial number or secret key indicator. */
|
||||
if (cardsn)
|
||||
es_fputs (cardsn, fp);
|
||||
else if (ctrl->with_secret)
|
||||
es_putc ('+', fp);
|
||||
es_putc (':', fp);
|
||||
}
|
||||
xfree (cardsn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue