mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
agent: Add A-flag for KEYINFO output for card.
* agent/command.c (do_one_keyinfo): Add ON_CARD argument to put A-flag. (cmd_keyinfo): Call agent_card_keyinfo to offer additional information if it's on card. -- This is a modification in gpg-agent, intended for better enum_secret_keys in gpg frontend. GnuPG-bug-id: 4244 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
6b06fb3cc5
commit
6790eaf952
@ -1120,13 +1120,14 @@ static const char hlp_keyinfo[] =
|
|||||||
" 'D' - The key has been disabled,\n"
|
" 'D' - The key has been disabled,\n"
|
||||||
" 'S' - The key is listed in sshcontrol (requires --with-ssh),\n"
|
" 'S' - The key is listed in sshcontrol (requires --with-ssh),\n"
|
||||||
" 'c' - Use of the key needs to be confirmed,\n"
|
" 'c' - Use of the key needs to be confirmed,\n"
|
||||||
|
" 'A' - The key is available on card,\n"
|
||||||
" '-' - No flags given.\n"
|
" '-' - No flags given.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"More information may be added in the future.";
|
"More information may be added in the future.";
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
||||||
int data, int with_ssh_fpr, int in_ssh,
|
int data, int with_ssh_fpr, int in_ssh,
|
||||||
int ttl, int disabled, int confirm)
|
int ttl, int disabled, int confirm, int on_card)
|
||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
char hexgrip[40+1];
|
char hexgrip[40+1];
|
||||||
@ -1167,6 +1168,8 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
|||||||
strcat (flagsbuf, "S");
|
strcat (flagsbuf, "S");
|
||||||
if (confirm)
|
if (confirm)
|
||||||
strcat (flagsbuf, "c");
|
strcat (flagsbuf, "c");
|
||||||
|
if (on_card)
|
||||||
|
strcat (flagsbuf, "A");
|
||||||
if (!*flagsbuf)
|
if (!*flagsbuf)
|
||||||
strcpy (flagsbuf, "-");
|
strcpy (flagsbuf, "-");
|
||||||
|
|
||||||
@ -1271,6 +1274,9 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||||||
ssh_control_file_t cf = NULL;
|
ssh_control_file_t cf = NULL;
|
||||||
char hexgrip[41];
|
char hexgrip[41];
|
||||||
int disabled, ttl, confirm, is_ssh;
|
int disabled, ttl, confirm, is_ssh;
|
||||||
|
struct card_key_info_s *keyinfo_on_cards;
|
||||||
|
struct card_key_info_s *l;
|
||||||
|
int on_card;
|
||||||
|
|
||||||
if (ctrl->restricted)
|
if (ctrl->restricted)
|
||||||
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
||||||
@ -1301,6 +1307,8 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||||||
if (opt_with_ssh || list_mode == 2)
|
if (opt_with_ssh || list_mode == 2)
|
||||||
cf = ssh_open_control_file ();
|
cf = ssh_open_control_file ();
|
||||||
|
|
||||||
|
agent_card_keyinfo (ctrl, NULL, &keyinfo_on_cards);
|
||||||
|
|
||||||
if (list_mode == 2)
|
if (list_mode == 2)
|
||||||
{
|
{
|
||||||
if (cf)
|
if (cf)
|
||||||
@ -1310,8 +1318,14 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||||||
{
|
{
|
||||||
if (hex2bin (hexgrip, grip, 20) < 0 )
|
if (hex2bin (hexgrip, grip, 20) < 0 )
|
||||||
continue; /* Bad hex string. */
|
continue; /* Bad hex string. */
|
||||||
|
|
||||||
|
on_card = 0;
|
||||||
|
for (l = keyinfo_on_cards; l; l = l->next)
|
||||||
|
if (!memcmp (l->keygrip, hexgrip, 40))
|
||||||
|
on_card = 1;
|
||||||
|
|
||||||
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, 1,
|
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, 1,
|
||||||
ttl, disabled, confirm);
|
ttl, disabled, confirm, on_card);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
@ -1361,8 +1375,13 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
on_card = 0;
|
||||||
|
for (l = keyinfo_on_cards; l; l = l->next)
|
||||||
|
if (!memcmp (l->keygrip, hexgrip, 40))
|
||||||
|
on_card = 1;
|
||||||
|
|
||||||
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, is_ssh,
|
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, is_ssh,
|
||||||
ttl, disabled, confirm);
|
ttl, disabled, confirm, on_card);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
@ -1384,11 +1403,17 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
on_card = 0;
|
||||||
|
for (l = keyinfo_on_cards; l; l = l->next)
|
||||||
|
if (!memcmp (l->keygrip, line, 40))
|
||||||
|
on_card = 1;
|
||||||
|
|
||||||
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, is_ssh,
|
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, is_ssh,
|
||||||
ttl, disabled, confirm);
|
ttl, disabled, confirm, on_card);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
|
agent_card_free_keyinfo (keyinfo_on_cards);
|
||||||
ssh_close_control_file (cf);
|
ssh_close_control_file (cf);
|
||||||
if (dir)
|
if (dir)
|
||||||
closedir (dir);
|
closedir (dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user