mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
* main.h, g10.c (main), keygen.c (build_personal_digest_list): Put in a
default digest preference list consisting of SHA-1, followed by every other installed digest except MD5. Note this is the same as having no digest preference at all except for SHA-1 being favored. * options.h, g10.c (main), keygen.c (keygen_set_std_prefs), pkclist.c (select_algo_from_prefs): Split --personal-preference-list into three: --personal-{cipher|digest|compress}-preferences. This allows a user to set one without affecting another (i.e. setting only a digest pref doesn't imply an empty cipher pref). * exec.c (exec_read): This is a safer way of guessing the return value of system(). Noted by Stefan Bellon.
This commit is contained in:
parent
e6e35d9937
commit
005d2cc4a8
@ -1,3 +1,21 @@
|
||||
2002-06-06 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* main.h, g10.c (main), keygen.c (build_personal_digest_list): Put
|
||||
in a default digest preference list consisting of SHA-1, followed
|
||||
by every other installed digest except MD5. Note this is the same
|
||||
as having no digest preference at all except for SHA-1 being
|
||||
favored.
|
||||
|
||||
* options.h, g10.c (main), keygen.c (keygen_set_std_prefs),
|
||||
pkclist.c (select_algo_from_prefs): Split
|
||||
--personal-preference-list into three:
|
||||
--personal-{cipher|digest|compress}-preferences. This allows a
|
||||
user to set one without affecting another (i.e. setting only a
|
||||
digest pref doesn't imply an empty cipher pref).
|
||||
|
||||
* exec.c (exec_read): This is a safer way of guessing the return
|
||||
value of system(). Noted by Stefan Bellon.
|
||||
|
||||
2002-06-05 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* hkp.c (parse_hkp_index): Be more robust with keyservers
|
||||
|
@ -485,7 +485,7 @@ int exec_read(struct exec_info *info)
|
||||
}
|
||||
#else
|
||||
/* If we don't have the macros, do the best we can. */
|
||||
info->progreturn/=256;
|
||||
info->progreturn = (info->progreturn & 0xff00) >> 8;
|
||||
#endif
|
||||
|
||||
/* 127 is the magic value returned from system() to indicate
|
||||
|
39
g10/g10.c
39
g10/g10.c
@ -281,7 +281,9 @@ enum cmd_and_opt_values { aNull = 0,
|
||||
oNoAutoCheckTrustDB,
|
||||
oPreservePermissions,
|
||||
oDefaultPreferenceList,
|
||||
oPersonalPreferenceList,
|
||||
oPersonalCipherPreferences,
|
||||
oPersonalDigestPreferences,
|
||||
oPersonalCompressPreferences,
|
||||
oEmu3DESS2KBug, /* will be removed in 1.1 */
|
||||
oEmuMDEncodeBug,
|
||||
oDisplay,
|
||||
@ -560,7 +562,9 @@ static ARGPARSE_OPTS opts[] = {
|
||||
{ aRebuildKeydbCaches, "rebuild-keydb-caches", 256, "@"},
|
||||
{ oPreservePermissions, "preserve-permissions", 0, "@"},
|
||||
{ oDefaultPreferenceList, "default-preference-list", 2, "@"},
|
||||
{ oPersonalPreferenceList, "personal-preference-list", 2, "@"},
|
||||
{ oPersonalCipherPreferences, "personal-cipher-preferences", 2, "@"},
|
||||
{ oPersonalDigestPreferences, "personal-digest-preferences", 2, "@"},
|
||||
{ oPersonalCompressPreferences, "personal-compress-preferences", 2, "@"},
|
||||
{ oEmu3DESS2KBug, "emulate-3des-s2k-bug", 0, "@"},
|
||||
{ oEmuMDEncodeBug, "emulate-md-encode-bug", 0, "@"},
|
||||
{ oDisplay, "display", 2, "@" },
|
||||
@ -819,7 +823,9 @@ main( int argc, char **argv )
|
||||
char *cert_digest_string = NULL;
|
||||
char *s2k_cipher_string = NULL;
|
||||
char *s2k_digest_string = NULL;
|
||||
char *pers_pref_list = NULL;
|
||||
char *pers_cipher_list = NULL;
|
||||
char *pers_digest_list = NULL;
|
||||
char *pers_compress_list = NULL;
|
||||
int eyes_only=0;
|
||||
int pwfd = -1;
|
||||
int with_fpr = 0; /* make an option out of --fingerprint */
|
||||
@ -1362,7 +1368,15 @@ main( int argc, char **argv )
|
||||
case oDefaultPreferenceList:
|
||||
opt.def_preference_list = pargs.r.ret_str;
|
||||
break;
|
||||
case oPersonalPreferenceList: pers_pref_list=pargs.r.ret_str; break;
|
||||
case oPersonalCipherPreferences:
|
||||
pers_cipher_list=pargs.r.ret_str;
|
||||
break;
|
||||
case oPersonalDigestPreferences:
|
||||
pers_digest_list=pargs.r.ret_str;
|
||||
break;
|
||||
case oPersonalCompressPreferences:
|
||||
pers_compress_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;
|
||||
@ -1597,8 +1611,21 @@ main( int argc, char **argv )
|
||||
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"));
|
||||
/* We provide defaults for the personal digest list */
|
||||
if(!pers_digest_list)
|
||||
pers_digest_list=build_personal_digest_list();
|
||||
|
||||
if(pers_cipher_list &&
|
||||
keygen_set_std_prefs(pers_cipher_list,PREFTYPE_SYM))
|
||||
log_error(_("invalid personal cipher preferences\n"));
|
||||
|
||||
if(pers_digest_list &&
|
||||
keygen_set_std_prefs(pers_digest_list,PREFTYPE_HASH))
|
||||
log_error(_("invalid personal digest preferences\n"));
|
||||
|
||||
if(pers_compress_list &&
|
||||
keygen_set_std_prefs(pers_compress_list,PREFTYPE_ZIP))
|
||||
log_error(_("invalid personal compress preferences\n"));
|
||||
|
||||
if( log_get_errorcount(0) )
|
||||
g10_exit(2);
|
||||
|
133
g10/keygen.c
133
g10/keygen.c
@ -271,43 +271,92 @@ keygen_set_std_prefs (const char *string,int personal)
|
||||
}
|
||||
}
|
||||
|
||||
if (!rc) {
|
||||
if(personal) {
|
||||
m_free(opt.personal_prefs);
|
||||
if (!rc)
|
||||
{
|
||||
if(personal)
|
||||
{
|
||||
if(personal==PREFTYPE_SYM)
|
||||
{
|
||||
m_free(opt.personal_cipher_prefs);
|
||||
|
||||
if((nsym+nhash+nzip)==0)
|
||||
opt.personal_prefs=NULL;
|
||||
else {
|
||||
int i,n=0;
|
||||
if(nsym==0)
|
||||
opt.personal_cipher_prefs=NULL;
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
opt.personal_prefs=m_alloc(sizeof(prefitem_t *)*(nsym+nhash+nzip+1));
|
||||
opt.personal_cipher_prefs=
|
||||
m_alloc(sizeof(prefitem_t *)*(nsym+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<nsym; i++)
|
||||
{
|
||||
opt.personal_cipher_prefs[i].type = PREFTYPE_SYM;
|
||||
opt.personal_cipher_prefs[i].value = sym[i];
|
||||
}
|
||||
|
||||
opt.personal_cipher_prefs[i].type = PREFTYPE_NONE;
|
||||
opt.personal_cipher_prefs[i].value = 0;
|
||||
}
|
||||
}
|
||||
else if(personal==PREFTYPE_HASH)
|
||||
{
|
||||
m_free(opt.personal_digest_prefs);
|
||||
|
||||
if(nhash==0)
|
||||
opt.personal_digest_prefs=NULL;
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
opt.personal_digest_prefs=
|
||||
m_alloc(sizeof(prefitem_t *)*(nhash+1));
|
||||
|
||||
for (i=0; i<nhash; i++)
|
||||
{
|
||||
opt.personal_digest_prefs[i].type = PREFTYPE_HASH;
|
||||
opt.personal_digest_prefs[i].value = hash[i];
|
||||
}
|
||||
|
||||
opt.personal_digest_prefs[i].type = PREFTYPE_NONE;
|
||||
opt.personal_digest_prefs[i].value = 0;
|
||||
}
|
||||
}
|
||||
else if(personal==PREFTYPE_ZIP)
|
||||
{
|
||||
m_free(opt.personal_compress_prefs);
|
||||
|
||||
if(nzip==0)
|
||||
opt.personal_compress_prefs=NULL;
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
opt.personal_compress_prefs=
|
||||
m_alloc(sizeof(prefitem_t *)*(nzip+1));
|
||||
|
||||
for (i=0; i<nzip; i++)
|
||||
{
|
||||
opt.personal_compress_prefs[i].type = PREFTYPE_ZIP;
|
||||
opt.personal_compress_prefs[i].value = zip[i];
|
||||
}
|
||||
|
||||
opt.personal_compress_prefs[i].type = PREFTYPE_NONE;
|
||||
opt.personal_compress_prefs[i].value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
opt.personal_mdc = mdc;
|
||||
}
|
||||
for (i=0; i<nhash; i++, n++) {
|
||||
opt.personal_prefs[n].type = PREFTYPE_HASH;
|
||||
opt.personal_prefs[n].value = hash[i];
|
||||
else
|
||||
{
|
||||
memcpy (sym_prefs, sym, (nsym_prefs=nsym));
|
||||
memcpy (hash_prefs, hash, (nhash_prefs=nhash));
|
||||
memcpy (zip_prefs, zip, (nzip_prefs=nzip));
|
||||
mdc_available = mdc;
|
||||
prefs_initialized = 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
opt.personal_mdc = mdc;
|
||||
}
|
||||
else {
|
||||
memcpy (sym_prefs, sym, (nsym_prefs=nsym));
|
||||
memcpy (hash_prefs, hash, (nhash_prefs=nhash));
|
||||
memcpy (zip_prefs, zip, (nzip_prefs=nzip));
|
||||
mdc_available = mdc;
|
||||
prefs_initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -2368,3 +2417,25 @@ write_keyblock( IOBUF out, KBNODE node )
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
build_personal_digest_list(void)
|
||||
{
|
||||
int i,n=0;
|
||||
static char pers_digest_list[(MAX_PREFS*5)+1];
|
||||
|
||||
/* The end result of this is to favor SHA-1 over everything, and put
|
||||
MD5 at the very end of the list. */
|
||||
|
||||
/* Don't put in 100-110 automatically */
|
||||
for(i=2;i<100 && n<MAX_PREFS;i++)
|
||||
{
|
||||
if(check_digest_algo(i)==0)
|
||||
{
|
||||
sprintf(pers_digest_list+strlen(pers_digest_list),"H%d ",i);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
return pers_digest_list;
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ int keygen_add_std_prefs( PKT_signature *sig, void *opaque );
|
||||
int keygen_upd_std_prefs( PKT_signature *sig, void *opaque );
|
||||
int keygen_add_revkey(PKT_signature *sig, void *opaque);
|
||||
int generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock );
|
||||
char *build_personal_digest_list(void);
|
||||
|
||||
/*-- openfile.c --*/
|
||||
int overwrite_filep( const char *fname );
|
||||
|
@ -126,7 +126,9 @@ struct {
|
||||
} keyserver_options;
|
||||
int exec_disable;
|
||||
char *def_preference_list;
|
||||
prefitem_t *personal_prefs;
|
||||
prefitem_t *personal_cipher_prefs,
|
||||
*personal_digest_prefs,
|
||||
*personal_compress_prefs;
|
||||
int personal_mdc;
|
||||
int no_perm_warn;
|
||||
char *temp_dir;
|
||||
|
@ -1102,8 +1102,12 @@ select_algo_from_prefs( PK_LIST pk_list, int preftype, void *hint )
|
||||
any = 0;
|
||||
|
||||
/* If we have personal prefs set, use them instead of the last key */
|
||||
if(opt.personal_prefs)
|
||||
prefs=opt.personal_prefs;
|
||||
if(preftype==PREFTYPE_SYM && opt.personal_cipher_prefs)
|
||||
prefs=opt.personal_cipher_prefs;
|
||||
else if(preftype==PREFTYPE_HASH && opt.personal_digest_prefs)
|
||||
prefs=opt.personal_digest_prefs;
|
||||
else if(preftype==PREFTYPE_ZIP && opt.personal_compress_prefs)
|
||||
prefs=opt.personal_compress_prefs;
|
||||
|
||||
if( prefs ) {
|
||||
for(j=0; prefs[j].type; j++ ) {
|
||||
@ -1151,10 +1155,10 @@ select_algo_from_prefs( PK_LIST pk_list, int preftype, void *hint )
|
||||
{
|
||||
i=DIGEST_ALGO_SHA1;
|
||||
|
||||
if(opt.personal_prefs)
|
||||
if(opt.personal_digest_prefs)
|
||||
for(j=0; prefs[j].type; j++ )
|
||||
if(opt.personal_prefs[j].type==PREFTYPE_HASH &&
|
||||
opt.personal_prefs[j].value==DIGEST_ALGO_MD5)
|
||||
if(opt.personal_digest_prefs[j].type==PREFTYPE_HASH &&
|
||||
opt.personal_digest_prefs[j].value==DIGEST_ALGO_MD5)
|
||||
{
|
||||
i=DIGEST_ALGO_MD5;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user