gnupg/g10 (ChangeLog mainproc.c)
cvs user dshaw
cvs at cvs.gnupg.org
Fri Apr 22 05:04:13 CEST 2005
Date: Friday, April 22, 2005 @ 05:21:14
Author: dshaw
Path: /cvs/gnupg/gnupg/g10
Modified: ChangeLog mainproc.c
* mainproc.c (symkey_decrypt_seskey): There is no need to have an
extra check for a bad passphrase and/or unknown cipher algorithm here.
We'll fail quite happily later, and usually with a better error
message to boot.
------------+
ChangeLog | 7 ++++++
mainproc.c | 66 +++++++++++++++++++++++++++++------------------------------
2 files changed, 40 insertions(+), 33 deletions(-)
Index: gnupg/g10/ChangeLog
diff -u gnupg/g10/ChangeLog:1.722 gnupg/g10/ChangeLog:1.723
--- gnupg/g10/ChangeLog:1.722 Sun Apr 17 06:10:03 2005
+++ gnupg/g10/ChangeLog Fri Apr 22 05:21:14 2005
@@ -1,3 +1,10 @@
+2005-04-21 David Shaw <dshaw at jabberwocky.com>
+
+ * mainproc.c (symkey_decrypt_seskey): There is no need to have an
+ extra check for a bad passphrase and/or unknown cipher algorithm
+ here. We'll fail quite happily later, and usually with a better
+ error message to boot.
+
2005-04-16 David Shaw <dshaw at jabberwocky.com>
* keyserver.c (keyserver_spawn): Free some memory.
Index: gnupg/g10/mainproc.c
diff -u gnupg/g10/mainproc.c:1.164 gnupg/g10/mainproc.c:1.165
--- gnupg/g10/mainproc.c:1.164 Fri Apr 1 18:22:34 2005
+++ gnupg/g10/mainproc.c Fri Apr 22 05:21:14 2005
@@ -241,41 +241,41 @@
static int
symkey_decrypt_seskey( DEK *dek, byte *seskey, size_t slen )
{
- CIPHER_HANDLE hd;
- unsigned int n;
+ CIPHER_HANDLE hd;
- if ( slen < 17 || slen > 33 ) {
- log_error ( _("weird size for an encrypted session key (%d)\n"),
- (int)slen);
- return G10ERR_BAD_KEY;
- }
- hd = cipher_open( dek->algo, CIPHER_MODE_CFB, 1 );
- cipher_setkey( hd, dek->key, dek->keylen );
- cipher_setiv( hd, NULL, 0 );
- cipher_decrypt( hd, seskey, seskey, slen );
- cipher_close( hd );
- /* check first byte (the cipher algo) */
- if(check_cipher_algo(seskey[0]))
- {
- /* There is no way to tell the difference here between a bad
- passphrase and a cipher algorithm that we don't have. */
- log_error(_("bad passphrase or unknown cipher algorithm (%d)\n"),
- seskey[0]);
- if(seskey[0]==CIPHER_ALGO_IDEA)
- idea_cipher_warn(0);
- return G10ERR_PASSPHRASE;
- }
- n = cipher_get_keylen (seskey[0]) / 8;
- if (n > DIM(dek->key))
- BUG ();
- /* now we replace the dek components with the real session key
- to decrypt the contents of the sequencing packet. */
- dek->keylen = cipher_get_keylen( seskey[0] ) / 8;
- dek->algo = seskey[0];
- memcpy( dek->key, seskey + 1, dek->keylen );
- /*log_hexdump( "thekey", dek->key, dek->keylen );*/
+ if(slen < 17 || slen > 33)
+ {
+ log_error ( _("weird size for an encrypted session key (%d)\n"),
+ (int)slen);
+ return G10ERR_BAD_KEY;
+ }
+
+ hd = cipher_open( dek->algo, CIPHER_MODE_CFB, 1 );
+ cipher_setkey( hd, dek->key, dek->keylen );
+ cipher_setiv( hd, NULL, 0 );
+ cipher_decrypt( hd, seskey, seskey, slen );
+ cipher_close( hd );
+
+ /* now we replace the dek components with the real session key to
+ decrypt the contents of the sequencing packet. */
+
+ dek->keylen=slen-1;
+ dek->algo=seskey[0];
+
+ if(dek->keylen > DIM(dek->key))
+ BUG ();
+
+ /* This is not completely accurate, since a bad passphrase may have
+ resulted in a garbage algorithm byte, but it's close enough since
+ a bogus byte here will fail later. */
+ if(dek->algo==CIPHER_ALGO_IDEA)
+ idea_cipher_warn(0);
+
+ memcpy(dek->key, seskey + 1, dek->keylen);
+
+ /*log_hexdump( "thekey", dek->key, dek->keylen );*/
- return 0;
+ return 0;
}
static void
More information about the Gnupg-commits
mailing list