From 5c37fd90bf81b401b6ce5a79bed4fe1cd0d8796d Mon Sep 17 00:00:00 2001 From: David Shaw Date: Sat, 1 Nov 2003 01:13:16 +0000 Subject: [PATCH] * trustdb.h, trustdb.c (register_trusted_keyid): New. Adds a keyid to the list of ultimately trusted keys. * keygen.c (do_generate_keypair): Use it here so that the ultimate ownertrust happens before the trustdb (might be) rebuilt. Also fix an error where the newly generated pk is thought to be a subkey by the trustdb. * g10.c (main): Fix --export-all do actually do something different than --export. * pkclist.c (build_pk_list): Show all recipients rather than showing each recipient as they are added. * mainproc.c (proc_symkey_enc, proc_encrypted): Keep a count of the number of passphrases that can decrypt a symmetric or mixed symmetric/pk message and include it in the list of keys shown to the user. --- g10/ChangeLog | 21 ++++++++++++++++++++ g10/g10.c | 10 ++++++---- g10/keygen.c | 12 +++++++----- g10/mainproc.c | 13 ++++++++++--- g10/pkclist.c | 53 +++++++++++++++++++++++++++++--------------------- g10/trustdb.c | 28 ++++++++++++++++---------- g10/trustdb.h | 1 + 7 files changed, 94 insertions(+), 44 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index b7ffc151f..4c9f29f6e 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,24 @@ +2003-10-31 David Shaw + + * trustdb.h, trustdb.c (register_trusted_keyid): New. Adds a + keyid to the list of ultimately trusted keys. + + * keygen.c (do_generate_keypair): Use it here so that the ultimate + ownertrust happens before the trustdb (might be) rebuilt. Also + fix an error where the newly generated pk is thought to be a + subkey by the trustdb. + + * g10.c (main): Fix --export-all do actually do something + different than --export. + + * pkclist.c (build_pk_list): Show all recipients rather than + showing each recipient as they are added. + + * mainproc.c (proc_symkey_enc, proc_encrypted): Keep a count of + the number of passphrases that can decrypt a symmetric or mixed + symmetric/pk message and include it in the list of keys shown to + the user. + 2003-10-30 David Shaw * misc.c (compress_algo_to_string, string_to_compress_algo, diff --git a/g10/g10.c b/g10/g10.c index 28ebc8ddb..d0ef9e5af 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -1,5 +1,6 @@ /* g10.c - The GnuPG utility (main for gpg) - * Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, + * 2003 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1399,7 +1400,10 @@ main( int argc, char **argv ) case aSearchKeys: set_cmd( &cmd, aSearchKeys); break; case aRefreshKeys: set_cmd( &cmd, aRefreshKeys); break; case aExport: set_cmd( &cmd, aExport); break; - case aExportAll: set_cmd( &cmd, aExportAll); break; + case aExportAll: + opt.export_options|=EXPORT_INCLUDE_NON_RFC; + set_cmd(&cmd,aExport); + break; case aListKeys: set_cmd( &cmd, aListKeys); break; case aListSigs: set_cmd( &cmd, aListSigs); break; case aExportSecret: set_cmd( &cmd, aExportSecret); break; @@ -2708,7 +2712,6 @@ main( int argc, char **argv ) break; case aExport: - case aExportAll: case aSendKeys: case aRecvKeys: sl = NULL; @@ -2736,7 +2739,6 @@ main( int argc, char **argv ) sl = NULL; for( ; argc; argc--, argv++ ) append_to_strlist2( &sl, *argv, utf8_strings ); - rc=keyserver_search( sl ); if(rc) log_error(_("keyserver search failed: %s\n"),g10_errstr(rc)); diff --git a/g10/keygen.c b/g10/keygen.c index b57206f88..51354af4c 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -2489,14 +2489,16 @@ do_generate_keypair( struct para_data_s *para, && !(get_parameter_uint( para,pKEYUSAGE) & PUBKEY_USAGE_ENC); PKT_public_key *pk = find_kbnode (pub_root, PKT_PUBLIC_KEY)->pkt->pkt.public_key; - - update_ownertrust (pk, - ((get_ownertrust (pk) & ~TRUST_MASK) - | TRUST_ULTIMATE )); + + keyid_from_pk(pk,pk->main_keyid); + register_trusted_keyid(pk->main_keyid); + + update_ownertrust (pk, + ((get_ownertrust (pk) & ~TRUST_MASK) + | TRUST_ULTIMATE )); if (!opt.batch) { tty_printf(_("public and secret key created and signed.\n") ); - tty_printf(_("key marked as ultimately trusted.\n") ); tty_printf("\n"); list_keyblock(pub_root,0,1,NULL); } diff --git a/g10/mainproc.c b/g10/mainproc.c index aefaad6c3..6fb459608 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -50,7 +50,6 @@ struct kidlist_item { }; - /**************** * Structure to hold the context */ @@ -72,6 +71,7 @@ struct mainproc_context { IOBUF iobuf; /* used to get the filename etc. */ int trustletter; /* temp usage in list_node */ ulong local_id; /* ditto */ + ulong symkeys; struct kidlist_item *pkenc_list; /* list of encryption packets */ struct { int op; @@ -327,7 +327,9 @@ proc_symkey_enc( CTX c, PACKET *pkt ) c->dek->algo_info_printed = 1; } } + leave: + c->symkeys++; free_packet(pkt); } @@ -477,10 +479,15 @@ proc_encrypted( CTX c, PACKET *pkt ) { int result = 0; - if (!opt.quiet) { + if (!opt.quiet) + { + if(c->symkeys>1) + log_info(_("encrypted with %lu passphrases\n"),c->symkeys); + else if(c->symkeys==1) + log_info(_("encrypted with 1 passphrase\n")); print_pkenc_list ( c->pkenc_list, 1 ); print_pkenc_list ( c->pkenc_list, 0 ); - } + } write_status( STATUS_BEGIN_DECRYPTION ); diff --git a/g10/pkclist.c b/g10/pkclist.c index b11cda529..5f28f5fcd 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -895,12 +895,41 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use ) else if(backlog) { answer=pop_strlist(&backlog); } - else { + else + { + PK_LIST iter; + + tty_printf("\n"); + tty_printf(_("Current recipients:\n")); + for(iter=pk_list;iter;iter=iter->next) + { + u32 keyid[2]; + + keyid_from_pk(iter->pk,keyid); + tty_printf("%4u%c/%08lX %s \"", + nbits_from_pk(iter->pk), + pubkey_letter(iter->pk->pubkey_algo), + (ulong)keyid[1], + datestr_from_pk(iter->pk)); + + if(iter->pk->user_id) + tty_print_utf8_string(iter->pk->user_id->name, + iter->pk->user_id->len); + else + { + size_t n; + char *p = get_user_id( keyid, &n ); + tty_print_utf8_string( p, n ); + m_free(p); + } + tty_printf("\"\n"); + } + answer = cpr_get_utf8("pklist.user_id.enter", _("\nEnter the user ID. End with an empty line: ")); trim_spaces(answer); cpr_kill_prompt(); - } + } if( !answer || !*answer ) { m_free(answer); break; @@ -947,26 +976,6 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use ) } else { PK_LIST r; - u32 keyid[2]; - - keyid_from_pk( pk, keyid); - tty_printf("Added %4u%c/%08lX %s \"", - nbits_from_pk( pk ), - pubkey_letter( pk->pubkey_algo ), - (ulong)keyid[1], - datestr_from_pk( pk ) ); - if(pk->user_id) - tty_print_utf8_string(pk->user_id->name, - pk->user_id->len); - else - { - size_t n; - char *p = get_user_id( keyid, &n ); - tty_print_utf8_string( p, n ); - m_free(p); - } - tty_printf("\"\n"); - r = m_alloc( sizeof *r ); r->pk = pk; pk = NULL; r->next = pk_list; diff --git a/g10/trustdb.c b/g10/trustdb.c index 743d9c771..be8835807 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -204,22 +204,30 @@ release_key_array ( struct key_array *keys ) * before initializing the validation module. * FIXME: Should be replaced by a function to add those keys to the trustdb. */ +void +register_trusted_keyid(u32 *keyid) +{ + struct key_item *k; + + k = new_key_item (); + k->kid[0] = keyid[0]; + k->kid[1] = keyid[1]; + k->next = user_utk_list; + user_utk_list = k; +} + void register_trusted_key( const char *string ) { KEYDB_SEARCH_DESC desc; - struct key_item *k; - if (classify_user_id (string, &desc) != KEYDB_SEARCH_MODE_LONG_KID ) { - log_error(_("`%s' is not a valid long keyID\n"), string ); - return; - } + if (classify_user_id (string, &desc) != KEYDB_SEARCH_MODE_LONG_KID ) + { + log_error(_("`%s' is not a valid long keyID\n"), string ); + return; + } - k = new_key_item (); - k->kid[0] = desc.u.kid[0]; - k->kid[1] = desc.u.kid[1]; - k->next = user_utk_list; - user_utk_list = k; + register_trusted_keyid(desc.u.kid); } /* diff --git a/g10/trustdb.h b/g10/trustdb.h index bd7344bc9..ad192758e 100644 --- a/g10/trustdb.h +++ b/g10/trustdb.h @@ -39,6 +39,7 @@ #define TRUST_FLAG_PENDING_CHECK 256 /* a check-trustdb is pending */ /*-- trustdb.c --*/ +void register_trusted_keyid(u32 *keyid); void register_trusted_key( const char *string ); void check_trustdb (void); void update_trustdb (void);