aboutsummaryrefslogtreecommitdiffstats
path: root/g10/seckey-cert.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/seckey-cert.c')
-rw-r--r--g10/seckey-cert.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c
index 4984c888b..32c54498d 100644
--- a/g10/seckey-cert.c
+++ b/g10/seckey-cert.c
@@ -36,7 +36,8 @@
static int
-do_check( PKT_secret_key *sk, const char *tryagain_text, int mode )
+do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
+ int *canceled )
{
byte *buffer;
u16 csum=0;
@@ -69,7 +70,11 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode )
keyid[3] = sk->main_keyid[1];
}
dek = passphrase_to_dek( keyid, sk->pubkey_algo, sk->protect.algo,
- &sk->protect.s2k, mode, tryagain_text );
+ &sk->protect.s2k, mode,
+ 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 );
@@ -229,12 +234,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 = 0;
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, mode );
+ rc = do_check( sk, tryagain, mode, &canceled );
if( rc == G10ERR_BAD_PASS && is_status_enabled() ) {
u32 kid[2];
char buf[50];
@@ -243,7 +249,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;
}