diff --git a/g10/ChangeLog b/g10/ChangeLog index 25f20014c..ff4b53186 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,27 @@ +2004-02-10 David Shaw + + * keygen.c (keygen_set_std_prefs): Build the default preferences + list at runtime as it properly handles algorithms disabled at + build or run time. + + * getkey.c (merge_selfsigs_main): Properly handle expired user IDs + when the expired self-sig is not the only self-sig. + + * misc.c (compress_algo_to_string): Return NULL on failure like + all of the other xxxx_algo_to_string() functions. + + * mainproc.c (list_node): Minor spacing tweak to match --list-keys + output. + + * keylist.c (list_keyblock_print), mainproc.c (list_node): Mark + revoked subkeys as revoked. Requested by Matthew Wilcox. Revoked + overrides expiration when both apply. + + * keyedit.c (show_prefs): Use compress algo constants. + (show_basic_key_info): Make revoked and expired tags translatable. + + * g10.c (rm_group): Properly ungroup from a list of groups. + 2004-01-30 David Shaw * g10.c (main, rm_group): Add --ungroup command to remove a diff --git a/g10/g10.c b/g10/g10.c index 3b537710b..25be39abf 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -993,6 +993,7 @@ rm_group(char *name) free_strlist(item->values); m_free(item); + break; } } } diff --git a/g10/getkey.c b/g10/getkey.c index 3f0997e2d..14a459df6 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -1585,19 +1585,21 @@ merge_selfsigs_main( KBNODE keyblock, int *r_revoked ) * the same email address may become valid again (hired, * fired, hired again). */ - if(sig->flags.expired) { - /* Expired uids don't get to be primary unless - they are the only uid there is. */ - uidnode->pkt->pkt.user_id->is_primary=0; - uidnode->pkt->pkt.user_id->is_expired=1; - uidnode->pkt->pkt.user_id->expiredate=sig->expiredate; - } - else { - sigdate = sig->timestamp; - signode = k; - if( sig->version > sigversion ) - sigversion = sig->version; - } + if(sig->flags.expired) + { + uidnode->pkt->pkt.user_id->is_expired=1; + signode = NULL; + } + else + { + uidnode->pkt->pkt.user_id->is_expired=0; + signode = k; + } + + sigdate = sig->timestamp; + uidnode->pkt->pkt.user_id->expiredate=sig->expiredate; + if( sig->version > sigversion ) + sigversion = sig->version; } } } diff --git a/g10/keyedit.c b/g10/keyedit.c index 45b097c8b..9edad21ad 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1,6 +1,6 @@ /* keyedit.c - keyedit stuff - * Copyright (C) 1998, 1999, 2000, 2001, 2002, - * 2003 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, + * 2004 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1788,7 +1788,7 @@ show_prefs (PKT_user_id *uid, int verbose) tty_printf ("%s", s ); else tty_printf ("[%d]", prefs[i].value); - if (prefs[i].value == 0 ) + if (prefs[i].value == COMPRESS_ALGO_NONE ) uncomp_seen = 1; } } @@ -1796,10 +1796,10 @@ show_prefs (PKT_user_id *uid, int verbose) if (any) tty_printf (", "); else { - tty_printf ("%s",compress_algo_to_string(1)); + tty_printf ("%s",compress_algo_to_string(COMPRESS_ALGO_ZIP)); tty_printf (", "); } - tty_printf ("%s",compress_algo_to_string(0)); + tty_printf ("%s",compress_algo_to_string(COMPRESS_ALGO_NONE)); } if(uid->mdc_feature || !uid->ks_modify) { @@ -2255,9 +2255,9 @@ show_basic_key_info ( KBNODE keyblock ) tty_printf (" "); if (uid->is_revoked) - tty_printf ("[revoked] "); - if ( uid->is_expired ) - tty_printf ("[expired] "); + tty_printf (_("[revoked] ")); + else if ( uid->is_expired ) + tty_printf (_("[expired] ")); tty_print_utf8_string (uid->name, uid->len); tty_printf ("\n"); } diff --git a/g10/keygen.c b/g10/keygen.c index 970d4766c..dea3aceea 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -1,6 +1,6 @@ /* keygen.c - generate a key pair - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 - * Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, + * 2004 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -223,18 +223,6 @@ set_one_pref (int val, int type, const char *item, byte *buf, int *nbuf) return 0; } -#ifdef USE_AES -#define AES "S9 S8 S7 " -#else -#define AES "" -#endif - -#ifdef USE_CAST5 -#define CAST5 "S3 " -#else -#define CAST5 "" -#endif - /* * Parse the supplied string and use it to set the standard * preferences. The string may be in a form like the one printed by @@ -248,23 +236,43 @@ 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, val, rc=0; int mdc=1, modify=0; /* mdc defaults on, modify defaults off. */ + char dummy_string[45]; /* enough for 15 items */ - if (!string || !ascii_strcasecmp (string, "default")) { - if (opt.def_preference_list) - string=opt.def_preference_list; - else if ( !check_cipher_algo(CIPHER_ALGO_IDEA) ) - string = AES CAST5 "S2 S1 H2 H3 Z2 Z1"; - else - string = AES CAST5 "S2 H2 H3 Z2 Z1"; + if (!string || !ascii_strcasecmp (string, "default")) + { + if (opt.def_preference_list) + string=opt.def_preference_list; + else + { + dummy_string[0]='\0'; - /* If we have it, IDEA goes *after* 3DES so it won't be used - unless we're encrypting along with a V3 key. Ideally, we - would only put the S1 preference in if the key was RSA and - <=2048 bits, as that is what won't break PGP2, but that is - difficult with the current code, and not really worth - checking as a non-RSA <=2048 bit key wouldn't be usable by - PGP2 anyway. -dms */ - } + /* Make sure we do not add more than 15 items here, as we + could overflow the size of dummy_string. */ + if(!check_cipher_algo(CIPHER_ALGO_AES256)) + strcat(dummy_string,"S9 "); + if(!check_cipher_algo(CIPHER_ALGO_AES192)) + strcat(dummy_string,"S8 "); + if(!check_cipher_algo(CIPHER_ALGO_AES)) + strcat(dummy_string,"S7 "); + if(!check_cipher_algo(CIPHER_ALGO_CAST5)) + strcat(dummy_string,"S3 "); + strcat(dummy_string,"S2 "); /* 3DES */ + /* If we have it, IDEA goes *after* 3DES so it won't be + used unless we're encrypting along with a V3 key. + Ideally, we would only put the S1 preference in if the + key was RSA and <=2048 bits, as that is what won't + break PGP2, but that is difficult with the current + code, and not really worth checking as a non-RSA <=2048 + bit key wouldn't be usable by PGP2 anyway. -dms */ + if(!check_cipher_algo(CIPHER_ALGO_IDEA)) + strcat(dummy_string,"S1 "); + + /* SHA-1, RIPEMD160, ZLIB, ZIP */ + strcat(dummy_string,"H2 H3 Z2 Z1"); + + string=dummy_string; + } + } else if (!ascii_strcasecmp (string, "none")) string = ""; @@ -403,9 +411,6 @@ keygen_set_std_prefs (const char *string,int personal) return rc; } -#undef CAST5 -#undef AES - /* Return a fake user ID containing the preferences. Caller must free. */ PKT_user_id *keygen_get_std_prefs(void) diff --git a/g10/keylist.c b/g10/keylist.c index 5983e9656..3f372f163 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -750,8 +750,15 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque ) else printf("%08lX",(ulong)keyid2[1]); printf(" %s",datestr_from_pk(pk2)); - if( pk2->expiredate ) - printf(_(" [expires: %s]"), expirestr_from_pk( pk2 ) ); + /* Yes, this is an odd way to print the revoked string, + but we already have translations for "[revoked] " (with + the trailing space) and this is a simple way to take + advantage of it. In devel, this will be done rather + more elegantly. */ + if( pk2->is_revoked ) + printf(" %s",_("[revoked] ")); + else if( pk2->expiredate ) + printf(_(" [expires: %s]"), expirestr_from_pk( pk2 ) ); putchar('\n'); if( fpr > 1 ) print_fingerprint( pk2, NULL, 0 ); diff --git a/g10/mainproc.c b/g10/mainproc.c index 1f95d80b9..bca9240e7 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -1,6 +1,6 @@ /* mainproc.c - handle packets - * Copyright (C) 1998, 1999, 2000, 2001, 2002, - * 2003 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, + * 2004 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -866,12 +866,13 @@ list_node( CTX c, KBNODE node ) } } else - printf("%s %4u%c/%08lX %s ", + printf("%s %4u%c/%08lX %s%s", mainkey? "pub":"sub", nbits_from_pk( pk ), pubkey_letter( pk->pubkey_algo ), (ulong)keyid_from_pk( pk, NULL ), - datestr_from_pk( pk ) ); + datestr_from_pk( pk ), + mainkey?" ":""); if( mainkey ) { /* and now list all userids with their signatures */ @@ -916,9 +917,14 @@ list_node( CTX c, KBNODE node ) } } } - else if( pk->expiredate ) { /* of subkey */ - printf(_(" [expires: %s]"), expirestr_from_pk( pk ) ); - } + else + { + /* of subkey */ + if( pk->is_revoked ) + printf(" %s",_("[revoked] ")); + else if( pk->expiredate ) + printf(_(" [expires: %s]"), expirestr_from_pk( pk ) ); + } if( !any ) putchar('\n'); diff --git a/g10/misc.c b/g10/misc.c index e3713a062..2a8e29211 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -1,5 +1,6 @@ /* misc.c - miscellaneous functions - * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 + * 2004 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -524,7 +525,7 @@ deprecated_warning(const char *configname,unsigned int configlineno, const char * compress_algo_to_string(int algo) { - const char *s="?"; + const char *s=NULL; switch(algo) {