aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog5
-rw-r--r--g10/seckey-cert.c19
2 files changed, 22 insertions, 2 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index b2b395da1..aed7b32f3 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-20 Werner Koch <[email protected]>
+
+ * seckey-cert.c (do_check): Handle case when checksum was okay but
+ passphrase still wrong. Roman Pavlik found such a case.
+
2004-12-20 David Shaw <[email protected]>
* keyedit.c (keyedit_menu): Invisible alias "passwd" as
diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c
index 84533bd3e..9153b9508 100644
--- a/g10/seckey-cert.c
+++ b/g10/seckey-cert.c
@@ -147,12 +147,20 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
}
}
- /* must check it here otherwise the mpi_read_xx would fail
+ /* Must check it here otherwise the mpi_read_xx would fail
because the length may have an arbitrary value */
if( sk->csum == csum ) {
for( ; i < pubkey_get_nskey(sk->pubkey_algo); i++ ) {
nbytes = ndata;
sk->skey[i] = mpi_read_from_buffer(p, &nbytes, 1 );
+ if (!sk->skey[i])
+ {
+ /* Checksum was okay, but not correctly
+ decrypted. */
+ sk->csum = 0;
+ csum = 1;
+ break;
+ }
ndata -= nbytes;
p += nbytes;
}
@@ -179,8 +187,15 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
csum += checksum (buffer, ndata);
mpi_free (sk->skey[i]);
sk->skey[i] = mpi_read_from_buffer (buffer, &ndata, 1);
- assert (sk->skey[i]);
m_free (buffer);
+ if (!sk->skey[i])
+ {
+ /* Checksum was okay, but not correctly
+ decrypted. */
+ sk->csum = 0;
+ csum = 1;
+ break;
+ }
/* csum += checksum_mpi (sk->skey[i]); */
}
}