diff options
author | Werner Koch <[email protected]> | 2001-09-20 07:12:52 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2001-09-20 07:12:52 +0000 |
commit | abdd248af945983c2b9906c98f2ae899c616f67f (patch) | |
tree | 9525fd586f367deba6f5d3789dae84b202227a76 | |
parent | Bug fixes and Timo's patches (diff) | |
download | gnupg-abdd248af945983c2b9906c98f2ae899c616f67f.tar.gz gnupg-abdd248af945983c2b9906c98f2ae899c616f67f.zip |
Code cleanups
-rw-r--r-- | TODO | 21 | ||||
-rw-r--r-- | g10/ChangeLog | 11 | ||||
-rw-r--r-- | g10/Makefile.am | 2 | ||||
-rw-r--r-- | g10/keydb.c | 2 | ||||
-rw-r--r-- | g10/keyedit.c | 31 | ||||
-rw-r--r-- | g10/keylist.c | 120 | ||||
-rw-r--r-- | g10/main.h | 1 | ||||
-rw-r--r-- | g10/mainproc.c | 47 | ||||
-rw-r--r-- | g10/passphrase.c | 5 | ||||
-rw-r--r-- | g10/pkclist.c | 75 | ||||
-rw-r--r-- | include/util.h | 3 |
11 files changed, 134 insertions, 184 deletions
@@ -45,14 +45,10 @@ * g10/trustdb.c (make_sig_records): fix the fixme. - * Replace Valid/Invalid by Known/Unknown? - * Fix the bug in the mips assembler code * Add a way to show the fingerprint of an key signator's keys - * New option --file-remove path-to-wipe-program ? - * Add an is_valid flag to each user ID. * Do not create a secring.gpg if it is not needed; I have fixed this @@ -84,10 +80,11 @@ * --passphrase-fd can't work with -cs: document this or find a way to work around. -Scheduled for 1.1 ------------------ * export by user-IDs does only export the first matching name which leads - to a problem in cases where there are 2 keys with identically user-IDs. + to a problem in cases where there are 2 keys with identically + user-IDs. + --> Check whether this is still true. + * With option -i prompt before adding a key to the keyring and show some info what we are about to add. @@ -95,9 +92,12 @@ Scheduled for 1.1 * --disable-asm should still assemble _udiv_qrnnd when needed * Skip RO keyrings when importing a key. + [Do an access(2) when registering a keyring and add code to + keydb_locate_writable()] * replace the keyserver stuff either by a call to a specialized utility and SOCKSify this utility. + [David is working on this] * Check the beginning of file to detect already compressed files (gzip, bzip2, xdelta and some picture formats) @@ -105,7 +105,7 @@ Scheduled for 1.1 * Get new assembler stuff from gmp 3.1 * Use new-format headers for compressed packets. - + The advantage is that a garbled zip file can be better detected. Nice to have @@ -118,11 +118,14 @@ Nice to have * add test cases for invalid data (scrambled armor or other random data) * add checking of armor trailers * the pubkey encrypt functions should do some sanity checks. - * dynload: implement the hint stuff. * "gpg filename.tar.gz.asc" should work like --verify (-sab). * for messages created with "-t", it might make sense to append the verification status of the message to the output (i.e. write something to the --output file and not only to stderr. +Things we won't do +------------------ + + * New option --file-remove path-to-wipe-program ? diff --git a/g10/ChangeLog b/g10/ChangeLog index abb59df05..47df95b87 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,5 +1,16 @@ +2001-09-20 Werner Koch <[email protected]> + + * passphrase.c (agent_open): Add missing bracket. Include windows.h. + 2001-09-19 Werner Koch <[email protected]> + * keylist.c (print_fingerprint): Renamed from fingerprint, made + global available. Added new arg to control the print style. + * mainproc.c (print_fingerprint): Removed. + * pkclist.c (print_fpr, fpr_info): Removed and changed callers to + use print_fingerprint. + * keyedit.c (show_fingerprint): Ditto. + * passphrase.c (writen, readn) (agent_open, agent_close) (agent_get_passphrase) diff --git a/g10/Makefile.am b/g10/Makefile.am index b7ead7e76..7ad0afdc6 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -54,6 +54,7 @@ common_source = \ status.h \ plaintext.c \ sig-check.c \ + keylist.c \ signal.c gpg_SOURCES = g10.c \ @@ -65,7 +66,6 @@ gpg_SOURCES = g10.c \ seckey-cert.c \ encr-data.c \ cipher.c \ - keylist.c \ encode.c \ sign.c \ verify.c \ diff --git a/g10/keydb.c b/g10/keydb.c index e26a6f75a..7a7a43e3e 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -499,7 +499,7 @@ keydb_delete_keyblock (KEYDB_HANDLE hd) /* * Locate the default writable key resource, so that the next - * operation (which is only releavnt for inserts) will be onde on this + * operation (which is only relevant for inserts) will be done on this * resource. */ int diff --git a/g10/keyedit.c b/g10/keyedit.c index 87a971bf7..9656385a6 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -44,7 +44,6 @@ static void show_prefs( PKT_user_id *uid, int verbose ); static void show_key_with_all_names( KBNODE keyblock, int only_marked, int with_fpr, int with_subkeys, int with_prefs ); static void show_key_and_fingerprint( KBNODE keyblock ); -static void show_fingerprint( PKT_public_key *pk ); static int menu_adduid( KBNODE keyblock, KBNODE sec_keyblock ); static void menu_deluid( KBNODE pub_keyblock, KBNODE sec_keyblock ); static int menu_delsig( KBNODE pub_keyblock ); @@ -1166,7 +1165,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, if( with_fpr ) { tty_printf("\n"); - show_fingerprint( pk ); + print_fingerprint ( pk, NULL, 2 ); } } tty_printf("\n"); @@ -1248,36 +1247,10 @@ show_key_and_fingerprint( KBNODE keyblock ) } tty_printf("\n"); if( pk ) - show_fingerprint( pk ); + print_fingerprint( pk, NULL, 2 ); } -static void -show_fingerprint( PKT_public_key *pk ) -{ - byte array[MAX_FINGERPRINT_LEN], *p; - size_t i, n; - - fingerprint_from_pk( pk, array, &n ); - p = array; - tty_printf(_(" Fingerprint:")); - if( n == 20 ) { - for(i=0; i < n ; i++, i++, p += 2 ) { - if( i == 10 ) - tty_printf(" "); - tty_printf(" %02X%02X", *p, p[1] ); - } - } - else { - for(i=0; i < n ; i++, p++ ) { - if( i && !(i%8) ) - tty_printf(" "); - tty_printf(" %02X", *p ); - } - } - tty_printf("\n"); -} - /**************** * Ask for a new user id, do the selfsignature and put it into diff --git a/g10/keylist.c b/g10/keylist.c index 29893b489..ff726e160 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -31,6 +31,7 @@ #include "keydb.h" #include "memory.h" #include "util.h" +#include "ttyio.h" #include "trustdb.h" #include "main.h" #include "i18n.h" @@ -38,7 +39,6 @@ static void list_all(int); static void list_one( STRLIST names, int secret); static void list_keyblock( KBNODE keyblock, int secret ); -static void fingerprint( PKT_public_key *pk, PKT_secret_key *sk ); /**************** @@ -268,7 +268,7 @@ list_keyblock_print ( KBNODE keyblock, int secret ) putchar('\n'); if( !any ) { if( opt.fingerprint ) - fingerprint( pk, sk ); + print_fingerprint( pk, sk, 0 ); if( opt.with_key_data ) print_key_data( pk, keyid ); any = 1; @@ -281,7 +281,7 @@ list_keyblock_print ( KBNODE keyblock, int secret ) if( !any ) { putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); /* of the main key */ + print_fingerprint( pk, sk, 0 ); /* of the main key */ any = 1; } @@ -295,7 +295,7 @@ list_keyblock_print ( KBNODE keyblock, int secret ) } putchar('\n'); if( opt.fingerprint > 1 ) - fingerprint( pk2, NULL ); + print_fingerprint( pk2, NULL, 0 ); if( opt.with_key_data ) print_key_data( pk2, keyid2 ); } @@ -306,7 +306,7 @@ list_keyblock_print ( KBNODE keyblock, int secret ) if( !any ) { putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); /* of the main key */ + print_fingerprint( pk, sk, 0 ); /* of the main key */ any = 1; } @@ -316,7 +316,7 @@ list_keyblock_print ( KBNODE keyblock, int secret ) (ulong)keyid2[1], datestr_from_sk( sk2 ) ); if( opt.fingerprint > 1 ) - fingerprint( NULL, sk2 ); + print_fingerprint( NULL, sk2, 0 ); } else if( opt.list_sigs && node->pkt->pkttype == PKT_SIGNATURE ) { PKT_signature *sig = node->pkt->pkt.signature; @@ -333,7 +333,7 @@ list_keyblock_print ( KBNODE keyblock, int secret ) else putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); + print_fingerprint( pk, sk, 0 ); any=1; } @@ -460,7 +460,7 @@ list_keyblock_colon( KBNODE keyblock, int secret ) print_capabilities (pk, sk, keyblock); putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); + print_fingerprint( pk, sk, 0 ); if( opt.with_key_data ) print_key_data( pk, keyid ); any = 1; @@ -507,7 +507,7 @@ list_keyblock_colon( KBNODE keyblock, int secret ) print_capabilities (pk, sk, keyblock); putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); + print_fingerprint( pk, sk, 0 ); if( opt.with_key_data ) print_key_data( pk, keyid ); any = 1; @@ -523,7 +523,7 @@ list_keyblock_colon( KBNODE keyblock, int secret ) print_capabilities (pk, sk, keyblock); putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); /* of the main key */ + print_fingerprint( pk, sk, 0 ); /* of the main key */ any = 1; } @@ -557,7 +557,7 @@ list_keyblock_colon( KBNODE keyblock, int secret ) print_capabilities (pk2, NULL, NULL); putchar('\n'); if( opt.fingerprint > 1 ) - fingerprint( pk2, NULL ); + print_fingerprint( pk2, NULL, 0 ); if( opt.with_key_data ) print_key_data( pk2, keyid2 ); } @@ -571,7 +571,7 @@ list_keyblock_colon( KBNODE keyblock, int secret ) print_capabilities (pk, sk, keyblock); putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); /* of the main key */ + print_fingerprint( pk, sk, 0 ); /* of the main key */ any = 1; } @@ -586,7 +586,7 @@ list_keyblock_colon( KBNODE keyblock, int secret ) print_capabilities (NULL, sk2, NULL); putchar ('\n'); if( opt.fingerprint > 1 ) - fingerprint( NULL, sk2 ); + print_fingerprint( NULL, sk2, 0 ); } else if( opt.list_sigs && node->pkt->pkttype == PKT_SIGNATURE ) { PKT_signature *sig = node->pkt->pkt.signature; @@ -606,7 +606,7 @@ list_keyblock_colon( KBNODE keyblock, int secret ) print_capabilities (pk, sk, keyblock); putchar('\n'); if( opt.fingerprint ) - fingerprint( pk, sk ); + print_fingerprint( pk, sk, 0 ); any=1; } @@ -718,38 +718,86 @@ list_keyblock( KBNODE keyblock, int secret ) list_keyblock_print (keyblock, secret ); } -static void -fingerprint( PKT_public_key *pk, PKT_secret_key *sk ) +/* + * standard function to print the finperprint. + * mode 0: as used in key listings, opt.with_colons is honored + * 1: print using log_info () + * 2: direct use of tty + */ +void +print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode ) { - byte *array, *p; + byte array[MAX_FINGERPRINT_LEN], *p; size_t i, n; + FILE *fp; + const char *text; - p = array = pk? fingerprint_from_pk( pk, NULL, &n ) - : fingerprint_from_sk( sk, NULL, &n ); - if( opt.with_colons ) { - printf("fpr:::::::::"); - for(i=0; i < n ; i++, p++ ) - printf("%02X", *p ); - putchar(':'); + if (mode == 1) { + fp = log_stream (); + text = _("Fingerprint:"); + } + else if (mode == 2) { + fp = NULL; /* use tty */ + /* Translators: this should fit into 24 bytes to that the fingerprint + * data is properly aligned with the user ID */ + text = _(" Fingerprint:"); } else { - printf(" Key fingerprint ="); - if( n == 20 ) { - for(i=0; i < n ; i++, i++, p += 2 ) { - if( i == 10 ) - putchar(' '); - printf(" %02X%02X", *p, p[1] ); + fp = stdout; + text = _(" Key fingerprint ="); + } + + if (sk) + fingerprint_from_sk (sk, array, &n); + else + fingerprint_from_pk (pk, array, &n); + p = array; + if (opt.with_colons && !mode) { + fprintf (fp, "fpr:::::::::"); + for (i=0; i < n ; i++, p++ ) + fprintf (fp, "%02X", *p ); + putc(':', fp); + } + else { + if (fp) + fputs (text, fp); + else + tty_printf ("%s", text); + if (n == 20) { + for (i=0; i < n ; i++, i++, p += 2 ) { + if (fp) { + if (i == 10 ) + putc(' ', fp); + fprintf (fp, " %02X%02X", *p, p[1] ); + } + else { + if (i == 10 ) + tty_printf (" "); + tty_printf (" %02X%02X", *p, p[1]); + } } } else { - for(i=0; i < n ; i++, p++ ) { - if( i && !(i%8) ) - putchar(' '); - printf(" %02X", *p ); + for (i=0; i < n ; i++, p++ ) { + if (fp) { + if (i && !(i%8) ) + putc (' ', fp); + fprintf (fp, " %02X", *p ); + } + else { + if (i && !(i%8) ) + tty_printf (" "); + tty_printf (" %02X", *p ); + } } } } - putchar('\n'); - m_free(array); + if (fp) + putc ('\n', fp); + else + tty_printf ("\n"); } + + + diff --git a/g10/main.h b/g10/main.h index 02248a69f..4ffe3b5da 100644 --- a/g10/main.h +++ b/g10/main.h @@ -154,6 +154,7 @@ void release_revocation_reason_info( struct revocation_reason_info *reason ); /*-- keylist.c --*/ void public_key_list( STRLIST list ); void secret_key_list( STRLIST list ); +void print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode); /*-- verify.c --*/ int verify_signatures( int nfiles, char **files ); diff --git a/g10/mainproc.c b/g10/mainproc.c index 25d1c60cc..6e19825f1 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -684,43 +684,6 @@ print_userid( PACKET *pkt ) static void -print_fingerprint( PKT_public_key *pk, PKT_secret_key *sk ) -{ - byte array[MAX_FINGERPRINT_LEN], *p; - size_t i, n; - - if( sk ) - fingerprint_from_sk( sk, array, &n ); - else - fingerprint_from_pk( pk, array, &n ); - p = array; - if( opt.with_colons ) { - printf("fpr:::::::::"); - for(i=0; i < n ; i++, p++ ) - printf("%02X", *p ); - putchar(':'); - } - else { - printf(" Key fingerprint ="); - if( n == 20 ) { - for(i=0; i < n ; i++, i++, p += 2 ) { - if( i == 10 ) - putchar(' '); - printf(" %02X%02X", *p, p[1] ); - } - } - else { - for(i=0; i < n ; i++, p++ ) { - if( i && !(i%8) ) - putchar(' '); - printf(" %02X", *p ); - } - } - } - putchar('\n'); -} - -static void print_notation_data( PKT_signature *sig ) { size_t n, n1, n2; @@ -805,7 +768,7 @@ list_node( CTX c, KBNODE node ) if( node->next && node->next->pkt->pkttype == PKT_RING_TRUST) { putchar('\n'); any=1; if( opt.fingerprint ) - print_fingerprint( pk, NULL ); + print_fingerprint( pk, NULL, 0 ); printf("rtv:1:%u:\n", node->next->pkt->pkt.ring_trust->trustval ); } @@ -843,7 +806,7 @@ list_node( CTX c, KBNODE node ) putchar(':'); putchar('\n'); if( opt.fingerprint && !any ) - print_fingerprint( pk, NULL ); + print_fingerprint( pk, NULL, 0 ); if( node->next && node->next->pkt->pkttype == PKT_RING_TRUST ) { printf("rtv:2:%u:\n", @@ -867,7 +830,7 @@ list_node( CTX c, KBNODE node ) if( !any ) putchar('\n'); if( !mainkey && opt.fingerprint > 1 ) - print_fingerprint( pk, NULL ); + print_fingerprint( pk, NULL, 0 ); } else if( (mainkey = (node->pkt->pkttype == PKT_SECRET_KEY) ) || node->pkt->pkttype == PKT_SECRET_SUBKEY ) { @@ -917,7 +880,7 @@ list_node( CTX c, KBNODE node ) putchar(':'); putchar('\n'); if( opt.fingerprint && !any ) - print_fingerprint( NULL, sk ); + print_fingerprint( NULL, sk, 0 ); any=1; } else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) { @@ -932,7 +895,7 @@ list_node( CTX c, KBNODE node ) if( !any ) putchar('\n'); if( !mainkey && opt.fingerprint > 1 ) - print_fingerprint( NULL, sk ); + print_fingerprint( NULL, sk, 0 ); } else if( node->pkt->pkttype == PKT_SIGNATURE ) { PKT_signature *sig = node->pkt->pkt.signature; diff --git a/g10/passphrase.c b/g10/passphrase.c index a9631bb2b..64e7cd87c 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -29,6 +29,9 @@ #include <sys/socket.h> #include <sys/un.h> #endif +#ifdef __MINGW32__ +# include <windows.h> +#endif #include <errno.h> #include "util.h" @@ -303,7 +306,7 @@ agent_open (void) if ( writen ( fd, "GPGA\0\0\0\x01", 8 ) ) { fd = -1; - + } #else /* Posix */ int fd; diff --git a/g10/pkclist.c b/g10/pkclist.c index cad60c059..d596d166b 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -31,6 +31,7 @@ #include "keydb.h" #include "memory.h" #include "util.h" +#include "main.h" #include "trustdb.h" #include "ttyio.h" #include "status.h" @@ -39,62 +40,6 @@ #define CONTROL_D ('D' - 'A' + 1) -/* fixme: we have nearly the same code in keyedit.c */ -static void -print_fpr( PKT_public_key *pk ) -{ - byte array[MAX_FINGERPRINT_LEN], *p; - size_t i, n; - - fingerprint_from_pk( pk, array, &n ); - p = array; - /* Translators: this shoud fit into 24 bytes to that the fingerprint - * data is properly aligned with the user ID */ - tty_printf(_(" Fingerprint:")); - if( n == 20 ) { - for(i=0; i < n ; i++, i++, p += 2 ) { - if( i == 10 ) - tty_printf(" "); - tty_printf(" %02X%02X", *p, p[1] ); - } - } - else { - for(i=0; i < n ; i++, p++ ) { - if( i && !(i%8) ) - tty_printf(" "); - tty_printf(" %02X", *p ); - } - } - tty_printf("\n"); -} - -static void -fpr_info( PKT_public_key *pk ) -{ - byte array[MAX_FINGERPRINT_LEN], *p; - size_t i, n; - FILE *fp = log_stream(); - - fingerprint_from_pk( pk, array, &n ); - p = array; - log_info(_("Fingerprint:")); - if( n == 20 ) { - for(i=0; i < n ; i++, i++, p += 2 ) { - if( i == 10 ) - putc(' ', fp); - fprintf(fp, " %02X%02X", *p, p[1] ); - } - } - else { - for(i=0; i < n ; i++, p++ ) { - if( i && !(i%8) ) - putc(' ', fp); - fprintf(fp, " %02X", *p ); - } - } - putc('\n', fp ); -} - /**************** * Show the revocation reason as it is stored with the given signature @@ -312,7 +257,7 @@ do_edit_ownertrust( ulong lid, int mode, unsigned *new_trust, int defer_help ) tty_print_utf8_string( p, n ), m_free(p); tty_printf("\"\n"); - print_fpr( pk ); + print_fingerprint (pk, NULL, 2); tty_printf("\n"); } tty_printf(_( @@ -586,7 +531,7 @@ do_we_trust_pre( PKT_public_key *pk, int trustlevel ) tty_print_utf8_string( p, n ), m_free(p); tty_printf("\"\n"); - print_fpr( pk ); + print_fingerprint (pk, NULL, 2); tty_printf("\n"); tty_printf(_( @@ -629,7 +574,7 @@ check_signatures_trust( PKT_signature *sig ) if( !opt.quiet ) log_info(_("WARNING: Using untrusted key!\n")); if (opt.with_fingerprint) - fpr_info (pk); + print_fingerprint (pk, NULL, 1); rc = 0; goto leave; } @@ -680,7 +625,7 @@ check_signatures_trust( PKT_signature *sig ) case TRUST_EXPIRED: log_info(_("Note: This key has expired!\n")); - fpr_info( pk ); + print_fingerprint (pk, NULL, 1); break; case TRUST_UNDEFINED: @@ -691,7 +636,7 @@ check_signatures_trust( PKT_signature *sig ) log_info(_( " There is no indication that the " "signature belongs to the owner.\n" )); - fpr_info( pk ); + print_fingerprint (pk, NULL, 1); } else { int quit; @@ -709,7 +654,7 @@ check_signatures_trust( PKT_signature *sig ) log_info(_("WARNING: We do NOT trust this key!\n")); log_info(_(" The signature is probably a FORGERY.\n")); if (opt.with_fingerprint) - fpr_info (pk); + print_fingerprint (pk, NULL, 1); rc = G10ERR_BAD_SIGN; break; @@ -721,19 +666,19 @@ check_signatures_trust( PKT_signature *sig ) log_info(_( " It is not certain that the signature belongs to the owner.\n" )); - fpr_info( pk ); + print_fingerprint (pk, NULL, 1); break; case TRUST_FULLY: write_status( STATUS_TRUST_FULLY ); if (opt.with_fingerprint) - fpr_info (pk); + print_fingerprint (pk, NULL, 1); break; case TRUST_ULTIMATE: write_status( STATUS_TRUST_ULTIMATE ); if (opt.with_fingerprint) - fpr_info (pk); + print_fingerprint (pk, NULL, 1); break; default: BUG(); diff --git a/include/util.h b/include/util.h index bd236796e..d8263dd0f 100644 --- a/include/util.h +++ b/include/util.h @@ -224,6 +224,9 @@ int strcasecmp( const char *, const char *b); /*-- w32reg.c --*/ char *read_w32_registry_string( const char *root, const char *dir, const char *name ); +int write_w32_registry_string(const char *root, const char *dir, + const char *name, const char *value); + /*-- strgutil.c --*/ int vasprintf ( char **result, const char *format, va_list args); #endif |