aboutsummaryrefslogtreecommitdiffstats
path: root/agent/protect-tool.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2020-06-05 01:35:33 +0000
committerNIIBE Yutaka <[email protected]>2020-06-05 01:35:33 +0000
commit47c1c329ed823a562185f86e98ac903605104f11 (patch)
tree76c582e259525accb38469b6c3be455f883ac99b /agent/protect-tool.c
parentagent: For ECC, use opaque MPI for key representation. (diff)
downloadgnupg-47c1c329ed823a562185f86e98ac903605104f11.tar.gz
gnupg-47c1c329ed823a562185f86e98ac903605104f11.zip
agent,ecc: Use of opaque MPI for ECC, fixup 'd'.
* agent/Makefile.am: Add sexp-secret.c. * agent/agent.h: New function declarations. * agent/sexp-secret.c: New. * agent/findkey.c (agent_key_from_file): Use sexp_sscan_private_key. * agent/protect-tool.c (read_and_unprotect): Fix up private part, calling fixup_when_ecc_private_key. Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'agent/protect-tool.c')
-rw-r--r--agent/protect-tool.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/agent/protect-tool.c b/agent/protect-tool.c
index bcbe4588d..a95f418e6 100644
--- a/agent/protect-tool.c
+++ b/agent/protect-tool.c
@@ -372,7 +372,7 @@ read_and_protect (const char *fname)
static void
read_and_unprotect (ctrl_t ctrl, const char *fname)
{
- int rc;
+ gpg_error_t err;
unsigned char *key;
unsigned char *result;
size_t resultlen;
@@ -383,15 +383,15 @@ read_and_unprotect (ctrl_t ctrl, const char *fname)
if (!key)
return;
- rc = agent_unprotect (ctrl, key, (pw=get_passphrase (1)),
- protected_at, &result, &resultlen);
+ err = agent_unprotect (ctrl, key, (pw=get_passphrase (1)),
+ protected_at, &result, &resultlen);
release_passphrase (pw);
xfree (key);
- if (rc)
+ if (err)
{
if (opt_status_msg)
log_info ("[PROTECT-TOOL:] bad-passphrase\n");
- log_error ("unprotecting the key failed: %s\n", gpg_strerror (rc));
+ log_error ("unprotecting the key failed: %s\n", gpg_strerror (err));
return;
}
if (opt.verbose)
@@ -404,6 +404,12 @@ read_and_unprotect (ctrl_t ctrl, const char *fname)
log_info ("key protection done at [unknown]\n");
}
+ err = fixup_when_ecc_private_key (result, &resultlen);
+ if (err)
+ {
+ log_error ("malformed key: %s\n", gpg_strerror (err));
+ return;
+ }
if (opt_armor)
{
char *p = make_advanced (result, resultlen);