mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
card: New subcommand "checkkeys".
* agent/command.c (cmd_havekey): Add new option --info. * tools/card-call-scd.c (scd_readkey): Allow using without result arg. (struct havekey_status_parm_s): New. (havekey_status_cb): New. (scd_havekey_info): New. (scd_delete_key): New. * tools/gpg-card.c (print_keygrip): Add arg with_lf. (cmd_checkkeys): New. (cmdCHECKKEYS): New. (cmds): Add command "checkkeys". (dispatch_command, interactive_loop): Call cmd_checkkeys. -- GnuPG-bug-id: 6943
This commit is contained in:
parent
c8060a8f23
commit
adeb17e375
4 changed files with 265 additions and 11 deletions
|
@ -634,10 +634,12 @@ cmd_marktrusted (assuan_context_t ctx, char *line)
|
|||
static const char hlp_havekey[] =
|
||||
"HAVEKEY <hexstrings_with_keygrips>\n"
|
||||
"HAVEKEY --list[=<limit>]\n"
|
||||
"HAVEKEY --info <hexkeygrip>\n"
|
||||
"\n"
|
||||
"Return success if at least one of the secret keys with the given\n"
|
||||
"keygrips is available. With --list return all available keygrips\n"
|
||||
"as binary data; with <limit> bail out at this number of keygrips";
|
||||
"as binary data; with <limit> bail out at this number of keygrips.\n"
|
||||
"In --info mode check just one keygrip.";
|
||||
static gpg_error_t
|
||||
cmd_havekey (assuan_context_t ctx, char *line)
|
||||
{
|
||||
|
@ -645,7 +647,8 @@ cmd_havekey (assuan_context_t ctx, char *line)
|
|||
gpg_error_t err;
|
||||
unsigned char grip[20];
|
||||
char *p;
|
||||
int list_mode; /* Less than 0 for no limit. */
|
||||
int list_mode = 0; /* Less than 0 for no limit. */
|
||||
int info_mode = 0;
|
||||
int counter;
|
||||
char *dirname;
|
||||
gnupg_dir_t dir;
|
||||
|
@ -653,15 +656,46 @@ cmd_havekey (assuan_context_t ctx, char *line)
|
|||
char hexgrip[41];
|
||||
struct card_key_info_s *keyinfo_on_cards, *l;
|
||||
|
||||
if (has_option_name (line, "--list"))
|
||||
if (has_option (line, "--info"))
|
||||
info_mode = 1;
|
||||
else if (has_option_name (line, "--list"))
|
||||
{
|
||||
if ((p = option_value (line, "--list")))
|
||||
list_mode = atoi (p);
|
||||
else
|
||||
list_mode = -1;
|
||||
}
|
||||
else
|
||||
list_mode = 0;
|
||||
|
||||
line = skip_options (line);
|
||||
|
||||
|
||||
if (info_mode)
|
||||
{
|
||||
int keytype;
|
||||
const char *infostring;
|
||||
|
||||
ctrl = assuan_get_pointer (ctx);
|
||||
|
||||
err = parse_keygrip (ctx, line, grip);
|
||||
if (err)
|
||||
goto leave;
|
||||
|
||||
err = agent_key_info_from_file (ctrl, grip, &keytype, NULL, NULL);
|
||||
if (err)
|
||||
goto leave;
|
||||
|
||||
switch (keytype)
|
||||
{
|
||||
case PRIVATE_KEY_CLEAR:
|
||||
case PRIVATE_KEY_OPENPGP_NONE: infostring = "clear"; break;
|
||||
case PRIVATE_KEY_PROTECTED: infostring = "protected"; break;
|
||||
case PRIVATE_KEY_SHADOWED: infostring = "shadowed"; break;
|
||||
default: infostring = "unknown"; break;
|
||||
}
|
||||
|
||||
err = agent_write_status (ctrl, "KEYFILEINFO", infostring, NULL);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
||||
if (!list_mode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue