1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-27 21:41:23 +02:00

* main.h, misc.c (default_cipher_algo, default_compress_algo): New.

Return the default algorithm by trying --cipher-algo/--compress-algo, then
the first item in the pref list, then s2k-cipher-algo or ZIP.

* sign.c (sign_file, sign_symencrypt_file), encode.c (encode_simple,
encode_crypt): Call default_cipher_algo and default_compress_algo to get
algorithms.

* g10.c (main): Allow pref selection for compress algo with --openpgp.
This commit is contained in:
David Shaw 2002-11-25 04:24:41 +00:00
parent bd23076c5e
commit 0819797911
6 changed files with 50 additions and 23 deletions

View File

@ -1,5 +1,17 @@
2002-11-24 David Shaw <dshaw@jabberwocky.com>
* main.h, misc.c (default_cipher_algo, default_compress_algo):
New. Return the default algorithm by trying
--cipher-algo/--compress-algo, then the first item in the pref
list, then s2k-cipher-algo or ZIP.
* sign.c (sign_file, sign_symencrypt_file), encode.c
(encode_simple, encode_crypt): Call default_cipher_algo and
default_compress_algo to get algorithms.
* g10.c (main): Allow pref selection for compress algo with
--openpgp.
* mainproc.c (proc_encrypted): Use --s2k-digest-algo for
passphrase mangling rather than --digest-algo.

View File

@ -194,8 +194,7 @@ encode_simple( const char *filename, int mode, int compat )
s2k->mode = opt.rfc1991? 0:opt.s2k_mode;
s2k->hash_algo = opt.s2k_digest_algo;
cfx.dek = passphrase_to_dek( NULL, 0,
opt.def_cipher_algo ? opt.def_cipher_algo
: opt.s2k_cipher_algo , s2k, 2, NULL );
default_cipher_algo(), s2k, 2, NULL );
if( !cfx.dek || !cfx.dek->keylen ) {
rc = G10ERR_PASSPHRASE;
m_free(cfx.dek);
@ -211,9 +210,7 @@ encode_simple( const char *filename, int mode, int compat )
}
if ( !compat ) {
seskeylen = cipher_get_keylen( opt.def_cipher_algo ?
opt.def_cipher_algo:
opt.s2k_cipher_algo ) / 8;
seskeylen = cipher_get_keylen( default_cipher_algo() ) / 8;
encode_sesskey( cfx.dek, &dek, enckey );
m_free( cfx.dek ); cfx.dek = dek;
}
@ -332,9 +329,7 @@ encode_simple( const char *filename, int mode, int compat )
{
if (cfx.dek && cfx.dek->use_mdc)
zfx.new_ctb = 1;
zfx.algo=opt.def_compress_algo;
if(zfx.algo==-1)
zfx.algo=DEFAULT_COMPRESS_ALGO;
zfx.algo=default_compress_algo();
iobuf_push_filter( out, compress_filter, &zfx );
}
@ -564,6 +559,8 @@ encode_crypt( const char *filename, STRLIST remusr )
if((compr_algo=
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,-1,NULL))==-1)
compr_algo=DEFAULT_COMPRESS_ALGO;
/* Theoretically impossible to get here since uncompressed
is implicit. */
}
else if(!opt.expert &&
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,

View File

@ -1515,7 +1515,7 @@ main( int argc, char **argv )
opt.def_cipher_algo = 0;
opt.def_digest_algo = 0;
opt.cert_digest_algo = 0;
opt.def_compress_algo = 1;
opt.def_compress_algo = -1;
opt.s2k_mode = 3; /* iterated+salted */
opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
opt.s2k_cipher_algo = CIPHER_ALGO_CAST5;

View File

@ -88,6 +88,8 @@ void deprecated_warning(const char *configname,unsigned int configlineno,
const char *compress_algo_to_string(int algo);
int string_to_compress_algo(const char *string);
int check_compress_algo(int algo);
int default_cipher_algo(void);
int default_compress_algo(void);
/*-- helptext.c --*/
void display_online_help( const char *keyword );

View File

@ -565,3 +565,28 @@ check_compress_algo(int algo)
return G10ERR_COMPR_ALGO;
}
int
default_cipher_algo(void)
{
if(opt.def_cipher_algo)
return opt.def_cipher_algo;
else if(opt.personal_cipher_prefs)
return opt.personal_cipher_prefs[0].value;
else
return opt.s2k_cipher_algo;
}
/* There is no default_digest_algo function, but see
sign.c:hash_for */
int
default_compress_algo(void)
{
if(opt.def_compress_algo!=-1)
return opt.def_compress_algo;
else if(opt.personal_compress_prefs)
return opt.personal_compress_prefs[0].value;
else
return DEFAULT_COMPRESS_ALGO;
}

View File

@ -775,7 +775,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
if((compr_algo=
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,-1,NULL))==-1)
compr_algo=DEFAULT_COMPRESS_ALGO;
compr_algo=default_compress_algo();
}
else if(!opt.expert &&
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,
@ -1048,7 +1048,7 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
s2k->mode = opt.rfc1991? 0:opt.s2k_mode;
s2k->hash_algo = opt.s2k_digest_algo;
algo = opt.def_cipher_algo ? opt.def_cipher_algo : opt.s2k_cipher_algo;
algo = default_cipher_algo();
if (!opt.quiet || !opt.batch)
log_info (_("%s encryption will be used\n"),
cipher_algo_to_string(algo) );
@ -1099,19 +1099,10 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
iobuf_push_filter( out, cipher_filter, &cfx );
/* Push the Zip filter */
if (opt.compress)
if (opt.compress && default_compress_algo())
{
int compr_algo=opt.def_compress_algo;
/* Default */
if(compr_algo==-1)
compr_algo=DEFAULT_COMPRESS_ALGO;
if (compr_algo)
{
zfx.algo = compr_algo;
iobuf_push_filter( out, compress_filter, &zfx );
}
zfx.algo = default_compress_algo();
iobuf_push_filter( out, compress_filter, &zfx );
}
/* Write the one-pass signature packets */