1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-04 20:38:50 +01:00

* options.h, main.h, keygen.c (keygen_set_set_prefs, keygen_get_std_prefs,

keygen_upd_std_prefs), keyedit.c (keyedit_menu), g10.c (main), pkclist.c
(select_algo_from_prefs): Add --personal-preference-list which allows the
user to factor in their own preferred algorithms when the preference lists
are consulted.  Obviously, this does not let the user violate a
recepient's preferences (and the RFC) - this only influences the ranking
of the agreed-on (and available) algorithms from the recepients.
Suggested by David Hollenberg.

* options.h, keygen.c (keygen_set_std_prefs), g10.c (main): Rename
--preference-list to --default-preference-list (as that is what it really
is), and make it a true default in that if the user selects "default" they
get this list and not the compiled-in list.
This commit is contained in:
David Shaw 2002-05-22 14:07:12 +00:00
parent eb2c0d6864
commit 2656589782
7 changed files with 80 additions and 15 deletions

View File

@ -1,3 +1,20 @@
2002-05-22 David Shaw <dshaw@jabberwocky.com>
* options.h, main.h, keygen.c (keygen_set_set_prefs,
keygen_get_std_prefs, keygen_upd_std_prefs), keyedit.c
(keyedit_menu), g10.c (main), pkclist.c (select_algo_from_prefs):
Add --personal-preference-list which allows the user to factor in
their own preferred algorithms when the preference lists are
consulted. Obviously, this does not let the user violate a
recepient's preferences (and the RFC) - this only influences the
ranking of the agreed-on (and available) algorithms from the
recepients. Suggested by David Hollenberg.
* options.h, keygen.c (keygen_set_std_prefs), g10.c (main): Rename
--preference-list to --default-preference-list (as that is what it
really is), and make it a true default in that if the user selects
"default" they get this list and not the compiled-in list.
2002-05-22 Werner Koch <wk@gnupg.org>
* g10.c (main): Add missing LF in a info printout and made it

View File

@ -279,7 +279,8 @@ enum cmd_and_opt_values { aNull = 0,
oAutoCheckTrustDB,
oNoAutoCheckTrustDB,
oPreservePermissions,
oPreferenceList,
oDefaultPreferenceList,
oPersonalPreferenceList,
oEmu3DESS2KBug, /* will be removed in 1.1 */
oEmuMDEncodeBug,
oDisplay,
@ -556,7 +557,8 @@ static ARGPARSE_OPTS opts[] = {
{ aDeleteSecretAndPublicKeys, "delete-secret-and-public-keys",256, "@" },
{ aRebuildKeydbCaches, "rebuild-keydb-caches", 256, "@"},
{ oPreservePermissions, "preserve-permissions", 0, "@"},
{ oPreferenceList, "preference-list", 2, "@"},
{ oDefaultPreferenceList, "default-preference-list", 2, "@"},
{ oPersonalPreferenceList, "personal-preference-list", 2, "@"},
{ oEmu3DESS2KBug, "emulate-3des-s2k-bug", 0, "@"},
{ oEmuMDEncodeBug, "emulate-md-encode-bug", 0, "@"},
{ oDisplay, "display", 2, "@" },
@ -784,7 +786,7 @@ main( int argc, char **argv )
char *cert_digest_string = NULL;
char *s2k_cipher_string = NULL;
char *s2k_digest_string = NULL;
char *preference_list = NULL;
char *pers_pref_list = NULL;
int eyes_only=0;
int pwfd = -1;
int with_fpr = 0; /* make an option out of --fingerprint */
@ -1320,7 +1322,10 @@ main( int argc, char **argv )
case oAutoCheckTrustDB: opt.no_auto_check_trustdb=0; break;
case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break;
case oPreservePermissions: opt.preserve_permissions=1; break;
case oPreferenceList: preference_list = pargs.r.ret_str; break;
case oDefaultPreferenceList:
opt.def_preference_list = pargs.r.ret_str;
break;
case oPersonalPreferenceList: pers_pref_list=pargs.r.ret_str; break;
case oDisplay: opt.display = pargs.r.ret_str; break;
case oTTYname: opt.ttyname = pargs.r.ret_str; break;
case oTTYtype: opt.ttytype = pargs.r.ret_str; break;
@ -1549,8 +1554,14 @@ main( int argc, char **argv )
if(opt.def_cert_check_level<0 || opt.def_cert_check_level>3)
log_error(_("invalid default-check-level; must be 0, 1, 2, or 3\n"));
if (preference_list && keygen_set_std_prefs (preference_list))
log_error(_("invalid preferences\n"));
/* This isn't actually needed, but does serve to error out if the
string is invalid. */
if(opt.def_preference_list &&
keygen_set_std_prefs(opt.def_preference_list,0))
log_error(_("invalid default preferences\n"));
if(pers_pref_list && keygen_set_std_prefs(pers_pref_list,1))
log_error(_("invalid personal preferences\n"));
if( log_get_errorcount(0) )
g10_exit(2);

View File

@ -1325,7 +1325,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands,
break;
case cmdSETPREF:
keygen_set_std_prefs ( !*arg_string? "default" : arg_string );
keygen_set_std_prefs ( !*arg_string? "default" : arg_string, 0);
break;
case cmdUPDPREF:

View File

@ -212,7 +212,7 @@ check_zip_algo (int algo)
* Returns: 0 = okay
*/
int
keygen_set_std_prefs (const char *string)
keygen_set_std_prefs (const char *string,int personal)
{
byte sym[MAX_PREFS], hash[MAX_PREFS], zip[MAX_PREFS];
int nsym=0, nhash=0, nzip=0;
@ -221,7 +221,9 @@ keygen_set_std_prefs (const char *string)
int rc = 0;
if (!string || !ascii_strcasecmp (string, "default")) {
if ( !check_cipher_algo(CIPHER_ALGO_IDEA) )
if (opt.def_preference_list)
string=opt.def_preference_list;
else if ( !check_cipher_algo(CIPHER_ALGO_IDEA) )
string = "S7 S3 S2 S1 H2 H3 Z2 Z1";
else
string = "S7 S3 S2 H2 H3 Z2 Z1";
@ -262,10 +264,38 @@ keygen_set_std_prefs (const char *string)
}
if (!rc) {
if(personal) {
m_free(opt.personal_prefs);
if((nsym+nhash+nzip)==0)
opt.personal_prefs=NULL;
else {
int i,n=0;
opt.personal_prefs=m_alloc(sizeof(prefitem_t *)*(nsym+nhash+nzip+1));
for (i=0; i<nsym; i++, n++) {
opt.personal_prefs[n].type = PREFTYPE_SYM;
opt.personal_prefs[n].value = sym[i];
}
for (i=0; i<nhash; i++, n++) {
opt.personal_prefs[n].type = PREFTYPE_HASH;
opt.personal_prefs[n].value = hash[i];
}
for (i=0; i<nzip; i++, n++) {
opt.personal_prefs[n].type = PREFTYPE_ZIP;
opt.personal_prefs[n].value = zip[i];
}
opt.personal_prefs[n].type = PREFTYPE_NONE; /* end of list marker */
opt.personal_prefs[n].value = 0;
}
}
else {
memcpy (sym_prefs, sym, (nsym_prefs=nsym));
memcpy (hash_prefs, hash, (nhash_prefs=nhash));
memcpy (zip_prefs, zip, (nzip_prefs=nzip));
prefs_initialized = 1;
}
}
return rc;
}
@ -281,7 +311,7 @@ keygen_get_std_prefs ()
int i;
if (!prefs_initialized)
keygen_set_std_prefs (NULL);
keygen_set_std_prefs (NULL,0);
buf = m_alloc ( MAX_PREFS*3*5 + 1);
*buf = 0;
@ -326,7 +356,7 @@ int
keygen_upd_std_prefs( PKT_signature *sig, void *opaque )
{
if (!prefs_initialized)
keygen_set_std_prefs (NULL);
keygen_set_std_prefs (NULL, 0);
if (nsym_prefs)
build_sig_subpkt (sig, SIGSUBPKT_PREF_SYM, sym_prefs, nsym_prefs);
@ -1599,7 +1629,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
}
/* Set preferences, if any. */
keygen_set_std_prefs(get_parameter_value( para, pPREFERENCES ));
keygen_set_std_prefs(get_parameter_value( para, pPREFERENCES ), 0);
/* Set revoker, if any. */
if (parse_revocation_key (fname, para, pREVOKER))

View File

@ -112,7 +112,7 @@ void keyedit_menu( const char *username, STRLIST locusr, STRLIST cmds,
u32 ask_expire_interval(int object);
u32 ask_expiredate(void);
void generate_keypair( const char *fname );
int keygen_set_std_prefs (const char *string);
int keygen_set_std_prefs (const char *string,int personal);
char *keygen_get_std_prefs (void);
int keygen_add_key_expire( PKT_signature *sig, void *opaque );
int keygen_add_std_prefs( PKT_signature *sig, void *opaque );

View File

@ -21,6 +21,7 @@
#define G10_OPTIONS_H
#include <types.h>
#include "packet.h"
#undef ENABLE_COMMENT_PACKETS /* don't create comment packets */
@ -124,6 +125,8 @@ struct {
STRLIST other;
} keyserver_options;
int exec_disable;
char *def_preference_list;
prefitem_t *personal_prefs;
int no_perm_warn;
char *temp_dir;
int no_encrypt_to;

View File

@ -1033,8 +1033,7 @@ select_algo_from_prefs( PK_LIST pk_list, int preftype )
else
mask[0] |= (1<<2); /* 3DES is implicitly there for everyone else */
}
if( preftype == PREFTYPE_ZIP )
else if( preftype == PREFTYPE_ZIP )
mask[0] |= (1<<0); /* Uncompressed is implicit */
if (pkr->pk->user_id) /* selected by user ID */
@ -1078,6 +1077,11 @@ select_algo_from_prefs( PK_LIST pk_list, int preftype )
*/
i = -1;
any = 0;
/* If we have personal prefs set, use them instead of the last key */
if(opt.personal_prefs)
prefs=opt.personal_prefs;
if( prefs ) {
for(j=0; prefs[j].type; j++ ) {
if( prefs[j].type == preftype ) {