diff options
author | NIIBE Yutaka <[email protected]> | 2019-05-29 07:19:46 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2019-05-29 07:19:46 +0000 |
commit | 6790eaf9529209e36099d9520821a3b8ad02ccef (patch) | |
tree | 712ff0174874cadf5e111e7829aecd62cfbcdcc0 | |
parent | Add changes from 2.2 to NEWS. (diff) | |
download | gnupg-6790eaf9529209e36099d9520821a3b8ad02ccef.tar.gz gnupg-6790eaf9529209e36099d9520821a3b8ad02ccef.zip |
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 <[email protected]>
-rw-r--r-- | agent/command.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/agent/command.c b/agent/command.c index c056eb3f0..460aa1dec 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1120,13 +1120,14 @@ static const char hlp_keyinfo[] = " 'D' - The key has been disabled,\n" " 'S' - The key is listed in sshcontrol (requires --with-ssh),\n" " 'c' - Use of the key needs to be confirmed,\n" + " 'A' - The key is available on card,\n" " '-' - No flags given.\n" "\n" "More information may be added in the future."; static gpg_error_t do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx, 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; 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"); if (confirm) strcat (flagsbuf, "c"); + if (on_card) + strcat (flagsbuf, "A"); if (!*flagsbuf) strcpy (flagsbuf, "-"); @@ -1271,6 +1274,9 @@ cmd_keyinfo (assuan_context_t ctx, char *line) ssh_control_file_t cf = NULL; char hexgrip[41]; 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) 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) cf = ssh_open_control_file (); + agent_card_keyinfo (ctrl, NULL, &keyinfo_on_cards); + if (list_mode == 2) { if (cf) @@ -1310,8 +1318,14 @@ cmd_keyinfo (assuan_context_t ctx, char *line) { if (hex2bin (hexgrip, grip, 20) < 0 ) 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, - ttl, disabled, confirm); + ttl, disabled, confirm, on_card); if (err) goto leave; } @@ -1361,8 +1375,13 @@ cmd_keyinfo (assuan_context_t ctx, char *line) 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, - ttl, disabled, confirm); + ttl, disabled, confirm, on_card); if (err) goto leave; } @@ -1384,11 +1403,17 @@ cmd_keyinfo (assuan_context_t ctx, char *line) 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, - ttl, disabled, confirm); + ttl, disabled, confirm, on_card); } leave: + agent_card_free_keyinfo (keyinfo_on_cards); ssh_close_control_file (cf); if (dir) closedir (dir); |