1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

* passphrase .c (agent_get_passphrase): New arg CANCELED.

(passphrase_to_dek): Ditto.  Passed to above.  Changed all
callers to pass NULL.
* seckey-cert.c (do_check): New arg CANCELED.
(check_secret_key): Terminate loop when canceled.

* keyedit.c (change_passphrase): Pass ERRTEXT untranslated to
passphrase_to_dek and translate where appropriate.

* seckey-cert.c (check_secret_key): Ditto.
* keygen.c (ask_passphrase): Ditto.
* passphrase.c (agent_get_passphrase): Translate the TRYAGAIN_TEXT.
Switch the codeset to utf-8.
This commit is contained in:
Werner Koch 2003-04-09 15:17:20 +00:00
parent 5a9e7663c1
commit 3ff3ac5ba4
11 changed files with 126 additions and 38 deletions

View file

@ -1,5 +1,5 @@
/* seckey-cert.c - secret key certificate packet handling
* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
* Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -36,7 +36,7 @@
static int
do_check( PKT_secret_key *sk, const char *tryagain_text )
do_check( PKT_secret_key *sk, const char *tryagain_text, int *canceled )
{
byte *buffer;
u16 csum=0;
@ -72,7 +72,11 @@ do_check( PKT_secret_key *sk, const char *tryagain_text )
keyid[3] = sk->main_keyid[1];
}
dek = passphrase_to_dek( keyid, sk->pubkey_algo, sk->protect.algo,
&sk->protect.s2k, 0, tryagain_text );
&sk->protect.s2k, 0,
tryagain_text, canceled);
if (!dek && canceled && *canceled)
return G10ERR_GENERAL;
cipher_hd = cipher_open( sk->protect.algo,
CIPHER_MODE_AUTO_CFB, 1);
cipher_setkey( cipher_hd, dek->key, dek->keylen );
@ -223,12 +227,13 @@ check_secret_key( PKT_secret_key *sk, int n )
n = (opt.batch && !opt.use_agent)? 1 : 3; /* use the default value */
for(i=0; i < n && rc == G10ERR_BAD_PASS; i++ ) {
int canceled;
const char *tryagain = NULL;
if (i) {
tryagain = _("Invalid passphrase; please try again");
log_info (_("%s ...\n"), tryagain);
tryagain = N_("Invalid passphrase; please try again");
log_info (_("%s ...\n"), _(tryagain));
}
rc = do_check( sk, tryagain );
rc = do_check( sk, tryagain, &canceled );
if( rc == G10ERR_BAD_PASS && is_status_enabled() ) {
u32 kid[2];
char buf[50];
@ -237,7 +242,7 @@ check_secret_key( PKT_secret_key *sk, int n )
sprintf(buf, "%08lX%08lX", (ulong)kid[0], (ulong)kid[1]);
write_status_text( STATUS_BAD_PASSPHRASE, buf );
}
if( have_static_passphrase() )
if( have_static_passphrase() || canceled )
break;
}