mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* call-agent.c (gpgsm_agent_havekey): New.
* keylist.c (list_cert_colon): New arg HAVE_SECRET, print "crs" when we know that the secret key is available. (gpgsm_list_keys): New arg MODE, check whether a secret key is available. Changed all callers. * gpgsm.c (main): New command --list-secret-keys. * server.c (cmd_listsecretkeys): New. (cmd_listkeys): Return secret keys with "crs" record.
This commit is contained in:
parent
2d1d9d928c
commit
cd30feaa8e
6 changed files with 89 additions and 14 deletions
41
sm/keylist.c
41
sm/keylist.c
|
@ -113,13 +113,13 @@ email_kludge (const char *name)
|
|||
|
||||
/* List one certificate in colon mode */
|
||||
static void
|
||||
list_cert_colon (KsbaCert cert, FILE *fp)
|
||||
list_cert_colon (KsbaCert cert, FILE *fp, int have_secret)
|
||||
{
|
||||
int idx, trustletter = 0;
|
||||
char *p;
|
||||
KsbaSexp sexp;
|
||||
|
||||
fputs ("crt:", fp);
|
||||
fputs (have_secret? "crs:":"crt:", fp);
|
||||
trustletter = 0;
|
||||
#if 0
|
||||
if (is_not_valid (cert))
|
||||
|
@ -216,14 +216,21 @@ list_cert_colon (KsbaCert cert, FILE *fp)
|
|||
|
||||
|
||||
|
||||
/* List all keys or just the key given as NAMES */
|
||||
/* List all keys or just the key given as NAMES.
|
||||
MODE controls the operation mode:
|
||||
0 = list all public keys but don't flag secret ones
|
||||
1 = list only public keys
|
||||
2 = list only secret keys
|
||||
3 = list secret and public keys
|
||||
*/
|
||||
void
|
||||
gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp)
|
||||
gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp, unsigned int mode)
|
||||
{
|
||||
KEYDB_HANDLE hd;
|
||||
KsbaCert cert = NULL;
|
||||
int rc=0;
|
||||
const char *lastresname, *resname;
|
||||
int have_secret;
|
||||
|
||||
hd = keydb_new (0);
|
||||
if (!hd)
|
||||
|
@ -262,10 +269,28 @@ gpgsm_list_keys (CTRL ctrl, STRLIST names, FILE *fp)
|
|||
lastresname = resname;
|
||||
}
|
||||
}
|
||||
if (ctrl->with_colons)
|
||||
list_cert_colon (cert, fp);
|
||||
else
|
||||
list_cert_colon (cert, fp);
|
||||
|
||||
have_secret = 0;
|
||||
if (mode)
|
||||
{
|
||||
char *p = gpgsm_get_keygrip_hexstring (cert);
|
||||
if (p)
|
||||
{
|
||||
if (!gpgsm_agent_havekey (p))
|
||||
have_secret = 1;
|
||||
xfree (p);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mode
|
||||
|| ((mode & 1) && !have_secret)
|
||||
|| ((mode & 2) && have_secret) )
|
||||
{
|
||||
if (ctrl->with_colons)
|
||||
list_cert_colon (cert, fp, have_secret);
|
||||
else
|
||||
list_cert_colon (cert, fp, have_secret);
|
||||
}
|
||||
ksba_cert_release (cert);
|
||||
cert = NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue