1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

* encode.c (encode_simple): Fix problem with using compression algo 2 and

symmetric compressed files.

* encode.c (encode_simple, encode_crypt): If we are not using a MDC,
compress even if a file is already compressed.  This is to help against
the chosen ciphertext attack.

* pkclist.c (select_algo_from_prefs): Fix requested algorithm bug so the
request succeeds even if the requested algorithm is not the first found.

* cipher.c (write_header), encode.c (use_mdc, encode_simple, encode_crypt,
encrypt_filter), g10.c (main): Be more eager to use a MDC.  We use a MDC
if the keys directly support it, if the keys list AES (any) or TWOFISH
anywhere in the prefs, or if the cipher chosen does not have a 64 bit
blocksize.
This commit is contained in:
David Shaw 2002-08-13 19:00:23 +00:00
parent d1f6ccd154
commit 1111da19a8
5 changed files with 114 additions and 47 deletions

View file

@ -47,31 +47,16 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
byte temp[18];
unsigned blocksize;
unsigned nprefix;
int use_mdc;
blocksize = cipher_get_blocksize( cfx->dek->algo );
if( blocksize < 8 || blocksize > 16 )
log_fatal("unsupported blocksize %u\n", blocksize );
use_mdc = cfx->dek->use_mdc;
if( blocksize != 8 )
use_mdc = 1; /* Hack: enable it for all modern ciphers */
/* Note: We should remove this hack as soon as a reasonable number of keys
are carrying the MDC flag. But always keep the hack for conventional
encryption */
if (opt.force_mdc)
use_mdc = 1;
if( opt.rfc2440 || opt.rfc1991 || opt.disable_mdc )
use_mdc = 0; /* override - rfc2440 does not know about MDC */
memset( &ed, 0, sizeof ed );
ed.len = cfx->datalen;
ed.extralen = blocksize+2;
ed.new_ctb = !ed.len && !opt.rfc1991;
if( use_mdc ) {
if( cfx->dek->use_mdc ) {
ed.mdc_method = DIGEST_ALGO_SHA1;
cfx->mdc_hash = md_open( DIGEST_ALGO_SHA1, 0 );
if ( DBG_HASHING )
@ -86,7 +71,7 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
}
init_packet( &pkt );
pkt.pkttype = use_mdc? PKT_ENCRYPTED_MDC : PKT_ENCRYPTED;
pkt.pkttype = cfx->dek->use_mdc? PKT_ENCRYPTED_MDC : PKT_ENCRYPTED;
pkt.pkt.encrypted = &ed;
if( build_packet( a, &pkt ))
log_bug("build_packet(ENCR_DATA) failed\n");
@ -96,7 +81,7 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
temp[nprefix+1] = temp[nprefix-1];
print_cipher_algo_note( cfx->dek->algo );
cfx->cipher_hd = cipher_open( cfx->dek->algo,
use_mdc? CIPHER_MODE_CFB
cfx->dek->use_mdc? CIPHER_MODE_CFB
: CIPHER_MODE_AUTO_CFB, 1 );
/* log_hexdump( "thekey", cfx->dek->key, cfx->dek->keylen );*/
cipher_setkey( cfx->cipher_hd, cfx->dek->key, cfx->dek->keylen );