mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
* 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.
This commit is contained in:
parent
ffd5cd0368
commit
a425334f48
@ -1,3 +1,13 @@
|
|||||||
|
2004-02-21 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* 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 <wk@gnupg.org>
|
2004-02-19 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* protect-tool.c: New options --have-cert and --prompt.
|
* protect-tool.c: New options --have-cert and --prompt.
|
||||||
|
@ -141,7 +141,8 @@ int agent_key_available (const unsigned char *grip);
|
|||||||
|
|
||||||
/*-- query.c --*/
|
/*-- query.c --*/
|
||||||
int agent_askpin (ctrl_t ctrl,
|
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,
|
int agent_get_passphrase (ctrl_t ctrl, char **retpass,
|
||||||
const char *desc, const char *prompt,
|
const char *desc, const char *prompt,
|
||||||
const char *errtext);
|
const char *errtext);
|
||||||
|
@ -664,7 +664,8 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
|
|||||||
return rc; /* we can't jump to leave because this is already an
|
return rc; /* we can't jump to leave because this is already an
|
||||||
Assuan error code. */
|
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)
|
if (rc)
|
||||||
;
|
;
|
||||||
else if (!s_skey)
|
else if (!s_skey)
|
||||||
@ -675,6 +676,8 @@ cmd_passwd (ASSUAN_CONTEXT ctx, char *line)
|
|||||||
else
|
else
|
||||||
rc = agent_protect_and_store (ctrl, s_skey);
|
rc = agent_protect_and_store (ctrl, s_skey);
|
||||||
|
|
||||||
|
xfree (ctrl->server_local->keydesc);
|
||||||
|
ctrl->server_local->keydesc = NULL;
|
||||||
gcry_sexp_release (s_skey);
|
gcry_sexp_release (s_skey);
|
||||||
xfree (shadow_info);
|
xfree (shadow_info);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
@ -202,7 +202,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
|
|||||||
info? info:"",
|
info? info:"",
|
||||||
info? "')":"") < 0)
|
info? "')":"") < 0)
|
||||||
desc = NULL;
|
desc = NULL;
|
||||||
rc = agent_askpin (ctrl, desc?desc:info, pi);
|
rc = agent_askpin (ctrl, desc?desc:info, NULL, pi);
|
||||||
free (desc);
|
free (desc);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
{
|
{
|
||||||
|
@ -185,7 +185,7 @@ unprotect (CTRL ctrl, const char *desc_text,
|
|||||||
arg.unprotected_key = NULL;
|
arg.unprotected_key = NULL;
|
||||||
pi->check_cb_arg = &arg;
|
pi->check_cb_arg = &arg;
|
||||||
|
|
||||||
rc = agent_askpin (ctrl, desc_text, pi);
|
rc = agent_askpin (ctrl, desc_text, NULL, pi);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
{
|
{
|
||||||
assert (arg.unprotected_key);
|
assert (arg.unprotected_key);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* pksign.c - Generate a keypair
|
/* 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.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -79,7 +79,6 @@ reenter_compare_cb (struct pin_entry_info_s *pi)
|
|||||||
|
|
||||||
if (!strcmp (pin1, pi->pin))
|
if (!strcmp (pin1, pi->pin))
|
||||||
return 0; /* okay */
|
return 0; /* okay */
|
||||||
pi->cb_errtext = _("does not match - try again");
|
|
||||||
return -1;
|
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"
|
const char *text1 = _("Please enter the passphrase to%0A"
|
||||||
"to protect your new key");
|
"to protect your new key");
|
||||||
const char *text2 = _("Please re-enter this passphrase");
|
const char *text2 = _("Please re-enter this passphrase");
|
||||||
|
const char *initial_errtext = NULL;
|
||||||
|
|
||||||
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
|
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
|
||||||
pi2 = pi + (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 = reenter_compare_cb;
|
||||||
pi2->check_cb_arg = pi->pin;
|
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)
|
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)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
if (!*pi->pin)
|
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 *text1 = _("Please enter the new passphrase");
|
||||||
const char *text2 = _("Please re-enter this passphrase");
|
const char *text2 = _("Please re-enter this passphrase");
|
||||||
|
const char *initial_errtext = NULL;
|
||||||
|
|
||||||
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
|
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
|
||||||
pi2 = pi + (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 = reenter_compare_cb;
|
||||||
pi2->check_cb_arg = pi->pin;
|
pi2->check_cb_arg = pi->pin;
|
||||||
|
|
||||||
rc = agent_askpin (ctrl, text1, pi);
|
next_try:
|
||||||
|
rc = agent_askpin (ctrl, text1, initial_errtext, pi);
|
||||||
if (!rc)
|
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)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
if (!*pi->pin)
|
if (!*pi->pin)
|
||||||
|
@ -250,7 +250,8 @@ all_digitsp( const char *s)
|
|||||||
numbers. */
|
numbers. */
|
||||||
int
|
int
|
||||||
agent_askpin (CTRL ctrl,
|
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;
|
int rc;
|
||||||
char line[ASSUAN_LINELENGTH];
|
char line[ASSUAN_LINELENGTH];
|
||||||
@ -289,6 +290,17 @@ agent_askpin (CTRL ctrl,
|
|||||||
if (rc)
|
if (rc)
|
||||||
return unlock_pinentry (map_assuan_err (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++)
|
for (;pininfo->failed_tries < pininfo->max_tries; pininfo->failed_tries++)
|
||||||
{
|
{
|
||||||
memset (&parm, 0, sizeof parm);
|
memset (&parm, 0, sizeof parm);
|
||||||
@ -301,7 +313,8 @@ agent_askpin (CTRL ctrl,
|
|||||||
snprintf (line, DIM(line)-1, "SETERROR %s (try %d of %d)",
|
snprintf (line, DIM(line)-1, "SETERROR %s (try %d of %d)",
|
||||||
errtext, pininfo->failed_tries+1, pininfo->max_tries);
|
errtext, pininfo->failed_tries+1, pininfo->max_tries);
|
||||||
line[DIM(line)-1] = 0;
|
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)
|
if (rc)
|
||||||
return unlock_pinentry (map_assuan_err (rc));
|
return unlock_pinentry (map_assuan_err (rc));
|
||||||
errtext = NULL;
|
errtext = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user