mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
* keydb.h, pkclist.c (select_algo_from_prefs): Allow passing a suggested
algorithm which will be used if available. * encode.c (encode_crypt, encrypt_filter), sign.c (sign_file): Use new select_algo_from_prefs feature to check if forcing an algorithm would violate the recipient preferences. * photoid.c (get_default_photo_command, show_photos): Use different default viewers on different platforms. Currently we have Win 9x, Win NT (2k, xp), Mac OSX, RISC OS, and "everybody else". These are #ifdefs as much as possible to avoid clutter. * g10.c (strusage, build_list), keyedit.c (show_prefs), main.h, misc.c (compress_algo_to_string, check_compress_algo), pkclist.c (algo_available), keygen.c (keygen_set_std_prefs): New algo_to_string and check functions for compress algorithms.
This commit is contained in:
parent
e2b8455014
commit
0f1c325c1c
11 changed files with 181 additions and 73 deletions
39
g10/encode.c
39
g10/encode.c
|
@ -387,7 +387,7 @@ encode_crypt( const char *filename, STRLIST remusr )
|
|||
/* create a session key */
|
||||
cfx.dek = m_alloc_secure_clear (sizeof *cfx.dek);
|
||||
if( !opt.def_cipher_algo ) { /* try to get it from the prefs */
|
||||
cfx.dek->algo = select_algo_from_prefs( pk_list, PREFTYPE_SYM, NULL );
|
||||
cfx.dek->algo = select_algo_from_prefs(pk_list,PREFTYPE_SYM,-1,NULL);
|
||||
/* The only way select_algo_from_prefs can fail here is when
|
||||
mixing v3 and v4 keys, as v4 keys have an implicit
|
||||
preference entry for 3DES, and the pk_list cannot be empty.
|
||||
|
@ -406,8 +406,17 @@ encode_crypt( const char *filename, STRLIST remusr )
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
cfx.dek->algo = opt.def_cipher_algo;
|
||||
else {
|
||||
if(!opt.expert &&
|
||||
select_algo_from_prefs(pk_list,PREFTYPE_SYM,
|
||||
opt.def_cipher_algo,NULL)!=opt.def_cipher_algo)
|
||||
log_info(_("forcing symmetric cipher %s (%d) "
|
||||
"violates recipient preferences\n"),
|
||||
cipher_algo_to_string(opt.def_cipher_algo),
|
||||
opt.def_cipher_algo);
|
||||
|
||||
cfx.dek->algo = opt.def_cipher_algo;
|
||||
}
|
||||
cfx.dek->use_mdc = select_mdc_from_pklist (pk_list);
|
||||
|
||||
make_session_key( cfx.dek );
|
||||
|
@ -467,9 +476,15 @@ encode_crypt( const char *filename, STRLIST remusr )
|
|||
if(compr_algo==-1)
|
||||
{
|
||||
if((compr_algo=
|
||||
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,NULL))==-1)
|
||||
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,-1,NULL))==-1)
|
||||
compr_algo=DEFAULT_COMPRESS_ALGO;
|
||||
}
|
||||
else if(!opt.expert &&
|
||||
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,
|
||||
compr_algo,NULL)!=compr_algo)
|
||||
log_info(_("forcing compression algorithm %s (%d) "
|
||||
"violates recipient preferences\n"),
|
||||
compress_algo_to_string(compr_algo),compr_algo);
|
||||
|
||||
/* algo 0 means no compression */
|
||||
if( compr_algo )
|
||||
|
@ -537,15 +552,25 @@ encrypt_filter( void *opaque, int control,
|
|||
|
||||
if( !opt.def_cipher_algo ) { /* try to get it from the prefs */
|
||||
efx->cfx.dek->algo =
|
||||
select_algo_from_prefs( efx->pk_list, PREFTYPE_SYM, NULL );
|
||||
select_algo_from_prefs(efx->pk_list,PREFTYPE_SYM,-1,NULL);
|
||||
if( efx->cfx.dek->algo == -1 ) {
|
||||
/* because 3DES is implicitly in the prefs, this can only
|
||||
* happen if we do not have any public keys in the list */
|
||||
efx->cfx.dek->algo = DEFAULT_CIPHER_ALGO;
|
||||
}
|
||||
}
|
||||
else
|
||||
efx->cfx.dek->algo = opt.def_cipher_algo;
|
||||
else {
|
||||
if(!opt.expert &&
|
||||
select_algo_from_prefs(efx->pk_list,PREFTYPE_SYM,
|
||||
opt.def_cipher_algo,
|
||||
NULL)!=opt.def_cipher_algo)
|
||||
log_info(_("forcing symmetric cipher %s (%d) "
|
||||
"violates recipient preferences\n"),
|
||||
cipher_algo_to_string(opt.def_cipher_algo),
|
||||
opt.def_cipher_algo);
|
||||
|
||||
efx->cfx.dek->algo = opt.def_cipher_algo;
|
||||
}
|
||||
|
||||
efx->cfx.dek->use_mdc = select_mdc_from_pklist (efx->pk_list);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue