diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2022-10-28 07:44:41 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2022-10-28 07:49:47 +0200 |
commit | ed6eb9019248dbbd36f16e5b412f5a115057bcfc (patch) | |
tree | 24ade474fdd025458a1df1e92dd23838857db8df /agent | |
parent | card: New commands "gpg" and "gpgsm". (diff) | |
download | gnupg2-ed6eb9019248dbbd36f16e5b412f5a115057bcfc.tar.xz gnupg2-ed6eb9019248dbbd36f16e5b412f5a115057bcfc.zip |
agent: Automatically convert to extended key format by KEYATTR.
* agent/command.c (cmd_keyattr): Reject when disabled extended key
format. Handle the case when key is in non-extended format.
--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'agent')
-rw-r--r-- | agent/command.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/agent/command.c b/agent/command.c index b820a5528..840f9f38e 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1218,6 +1218,12 @@ cmd_keyattr (assuan_context_t ctx, char *line) if (ctrl->restricted) return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN)); + if (!opt.enable_extended_key_format) + { + err = gpg_error (GPG_ERR_NOT_SUPPORTED); + goto leave; + } + opt_delete = has_option (line, "--delete"); line = skip_options (line); @@ -1248,15 +1254,15 @@ cmd_keyattr (assuan_context_t ctx, char *line) const char *p; err = agent_raw_key_from_file (ctrl, grip, &s_key, &keymeta); - if (keymeta == NULL) /* Not extended format? */ - { - err = gpg_error (GPG_ERR_INV_DATA); - goto leave; - } + if (err) + goto leave; if (argc == 2) { - nve_t e = nvc_lookup (keymeta, argv[1]); + nve_t e = NULL; + + if (keymeta) + e = nvc_lookup (keymeta, argv[1]); if (opt_delete) { @@ -1275,6 +1281,9 @@ cmd_keyattr (assuan_context_t ctx, char *line) } else if (argc == 3) { + if (!keymeta) + keymeta = nvc_new_private_key (); + err = nvc_set (keymeta, argv[1], argv[2]); key_attr_write: if (!err) |