aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--agent/ChangeLog10
-rw-r--r--agent/agent.h3
-rw-r--r--agent/command.c5
-rw-r--r--agent/divert-scd.c2
-rw-r--r--agent/findkey.c2
-rw-r--r--agent/genkey.c32
-rw-r--r--agent/query.c17
7 files changed, 59 insertions, 12 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog
index 241a60964..f05685b0d 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -1,3 +1,13 @@
+2004-02-21 Werner Koch <[email protected]>
+
+ * command.c (cmd_passwd): Take acount of a key description.
+
+ * genkey.c (reenter_compare_cb): Do not set the error text.
+ (agent_protect_and_store, agent_genkey): Force a re-enter after a
+ non-matching passphrase.
+ * query.c (agent_askpin): Add new arg INITIAL_ERRTEXT; changed
+ all callers.
+
2004-02-19 Werner Koch <[email protected]>
* protect-tool.c: New options --have-cert and --prompt.
diff --git a/agent/agent.h b/agent/agent.h
index a849e873f..a4312e081 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -141,7 +141,8 @@ int agent_key_available (const unsigned char *grip);
/*-- query.c --*/
int agent_askpin (ctrl_t ctrl,
- const char *desc_text, struct pin_entry_info_s *pininfo);
+ const char *desc_text, const char *inital_errtext,
+ struct pin_entry_info_s *pininfo);
int agent_get_passphrase (ctrl_t ctrl, char **retpass,
const char *desc, const char *prompt,
const char *errtext);
diff --git a/agent/command.c b/agent/command.c
index 2fa182f63..1d1ae9704 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -664,7 +664,8 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
return rc; /* we can't jump to leave because this is already an
Assuan error code. */
- rc = agent_key_from_file (ctrl, NULL, grip, &shadow_info, 1, &s_skey);
+ rc = agent_key_from_file (ctrl, ctrl->server_local->keydesc,
+ grip, &shadow_info, 1, &s_skey);
if (rc)
;
else if (!s_skey)
@@ -675,6 +676,8 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
else
rc = agent_protect_and_store (ctrl, s_skey);
+ xfree (ctrl->server_local->keydesc);
+ ctrl->server_local->keydesc = NULL;
gcry_sexp_release (s_skey);
xfree (shadow_info);
if (rc)
diff --git a/agent/divert-scd.c b/agent/divert-scd.c
index 9c512bdcf..72cf338fe 100644
--- a/agent/divert-scd.c
+++ b/agent/divert-scd.c
@@ -202,7 +202,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
info? info:"",
info? "')":"") < 0)
desc = NULL;
- rc = agent_askpin (ctrl, desc?desc:info, pi);
+ rc = agent_askpin (ctrl, desc?desc:info, NULL, pi);
free (desc);
if (!rc)
{
diff --git a/agent/findkey.c b/agent/findkey.c
index 14ca38448..9866b54b9 100644
--- a/agent/findkey.c
+++ b/agent/findkey.c
@@ -185,7 +185,7 @@ unprotect (CTRL ctrl, const char *desc_text,
arg.unprotected_key = NULL;
pi->check_cb_arg = &arg;
- rc = agent_askpin (ctrl, desc_text, pi);
+ rc = agent_askpin (ctrl, desc_text, NULL, pi);
if (!rc)
{
assert (arg.unprotected_key);
diff --git a/agent/genkey.c b/agent/genkey.c
index 1417abb02..3c56ba33e 100644
--- a/agent/genkey.c
+++ b/agent/genkey.c
@@ -1,5 +1,5 @@
/* pksign.c - Generate a keypair
- * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -79,7 +79,6 @@ reenter_compare_cb (struct pin_entry_info_s *pi)
if (!strcmp (pin1, pi->pin))
return 0; /* okay */
- pi->cb_errtext = _("does not match - try again");
return -1;
}
@@ -109,6 +108,7 @@ agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
const char *text1 = _("Please enter the passphrase to%0A"
"to protect your new key");
const char *text2 = _("Please re-enter this passphrase");
+ const char *initial_errtext = NULL;
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
pi2 = pi + (sizeof *pi + 100);
@@ -119,9 +119,19 @@ agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
pi2->check_cb = reenter_compare_cb;
pi2->check_cb_arg = pi->pin;
- rc = agent_askpin (ctrl, text1, pi);
+ next_try:
+ rc = agent_askpin (ctrl, text1, initial_errtext, pi);
+ initial_errtext = NULL;
if (!rc)
- rc = agent_askpin (ctrl, text2, pi2);
+ {
+ rc = agent_askpin (ctrl, text2, NULL, pi2);
+ if (rc == -1)
+ { /* The re-entered one did not match and the user did not
+ hit cancel. */
+ initial_errtext = _("does not match - try again");
+ goto next_try;
+ }
+ }
if (rc)
return rc;
if (!*pi->pin)
@@ -212,6 +222,7 @@ agent_protect_and_store (CTRL ctrl, gcry_sexp_t s_skey)
{
const char *text1 = _("Please enter the new passphrase");
const char *text2 = _("Please re-enter this passphrase");
+ const char *initial_errtext = NULL;
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
pi2 = pi + (sizeof *pi + 100);
@@ -222,9 +233,18 @@ agent_protect_and_store (CTRL ctrl, gcry_sexp_t s_skey)
pi2->check_cb = reenter_compare_cb;
pi2->check_cb_arg = pi->pin;
- rc = agent_askpin (ctrl, text1, pi);
+ next_try:
+ rc = agent_askpin (ctrl, text1, initial_errtext, pi);
if (!rc)
- rc = agent_askpin (ctrl, text2, pi2);
+ {
+ rc = agent_askpin (ctrl, text2, NULL, pi2);
+ if (rc == -1)
+ { /* The re-entered one did not match and the user did not
+ hit cancel. */
+ initial_errtext = _("does not match - try again");
+ goto next_try;
+ }
+ }
if (rc)
return rc;
if (!*pi->pin)
diff --git a/agent/query.c b/agent/query.c
index 28873775a..145aaca00 100644
--- a/agent/query.c
+++ b/agent/query.c
@@ -250,7 +250,8 @@ all_digitsp( const char *s)
numbers. */
int
agent_askpin (CTRL ctrl,
- const char *desc_text, struct pin_entry_info_s *pininfo)
+ const char *desc_text, const char *initial_errtext,
+ struct pin_entry_info_s *pininfo)
{
int rc;
char line[ASSUAN_LINELENGTH];
@@ -289,6 +290,17 @@ agent_askpin (CTRL ctrl,
if (rc)
return unlock_pinentry (map_assuan_err (rc));
+
+ if (initial_errtext)
+ {
+ snprintf (line, DIM(line)-1, "SETERROR %s", initial_errtext);
+ line[DIM(line)-1] = 0;
+ rc = assuan_transact (entry_ctx, line,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ if (rc)
+ return unlock_pinentry (map_assuan_err (rc));
+ }
+
for (;pininfo->failed_tries < pininfo->max_tries; pininfo->failed_tries++)
{
memset (&parm, 0, sizeof parm);
@@ -301,7 +313,8 @@ agent_askpin (CTRL ctrl,
snprintf (line, DIM(line)-1, "SETERROR %s (try %d of %d)",
errtext, pininfo->failed_tries+1, pininfo->max_tries);
line[DIM(line)-1] = 0;
- rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
+ rc = assuan_transact (entry_ctx, line,
+ NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
errtext = NULL;