1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-06-20 20:47:58 +02:00

* 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.
This commit is contained in:
David Shaw 2003-11-01 01:13:16 +00:00
parent d3cd27c3b6
commit 5c37fd90bf
7 changed files with 94 additions and 44 deletions

View File

@ -1,3 +1,24 @@
2003-10-31 David Shaw <dshaw@jabberwocky.com>
* 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 <dshaw@jabberwocky.com> 2003-10-30 David Shaw <dshaw@jabberwocky.com>
* misc.c (compress_algo_to_string, string_to_compress_algo, * misc.c (compress_algo_to_string, string_to_compress_algo,

View File

@ -1,5 +1,6 @@
/* g10.c - The GnuPG utility (main for gpg) /* 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. * This file is part of GnuPG.
* *
@ -1399,7 +1400,10 @@ main( int argc, char **argv )
case aSearchKeys: set_cmd( &cmd, aSearchKeys); break; case aSearchKeys: set_cmd( &cmd, aSearchKeys); break;
case aRefreshKeys: set_cmd( &cmd, aRefreshKeys); break; case aRefreshKeys: set_cmd( &cmd, aRefreshKeys); break;
case aExport: set_cmd( &cmd, aExport); 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 aListKeys: set_cmd( &cmd, aListKeys); break;
case aListSigs: set_cmd( &cmd, aListSigs); break; case aListSigs: set_cmd( &cmd, aListSigs); break;
case aExportSecret: set_cmd( &cmd, aExportSecret); break; case aExportSecret: set_cmd( &cmd, aExportSecret); break;
@ -2708,7 +2712,6 @@ main( int argc, char **argv )
break; break;
case aExport: case aExport:
case aExportAll:
case aSendKeys: case aSendKeys:
case aRecvKeys: case aRecvKeys:
sl = NULL; sl = NULL;
@ -2736,7 +2739,6 @@ main( int argc, char **argv )
sl = NULL; sl = NULL;
for( ; argc; argc--, argv++ ) for( ; argc; argc--, argv++ )
append_to_strlist2( &sl, *argv, utf8_strings ); append_to_strlist2( &sl, *argv, utf8_strings );
rc=keyserver_search( sl ); rc=keyserver_search( sl );
if(rc) if(rc)
log_error(_("keyserver search failed: %s\n"),g10_errstr(rc)); log_error(_("keyserver search failed: %s\n"),g10_errstr(rc));

View File

@ -2489,14 +2489,16 @@ do_generate_keypair( struct para_data_s *para,
&& !(get_parameter_uint( para,pKEYUSAGE) & PUBKEY_USAGE_ENC); && !(get_parameter_uint( para,pKEYUSAGE) & PUBKEY_USAGE_ENC);
PKT_public_key *pk = find_kbnode (pub_root, PKT_public_key *pk = find_kbnode (pub_root,
PKT_PUBLIC_KEY)->pkt->pkt.public_key; PKT_PUBLIC_KEY)->pkt->pkt.public_key;
update_ownertrust (pk, keyid_from_pk(pk,pk->main_keyid);
((get_ownertrust (pk) & ~TRUST_MASK) register_trusted_keyid(pk->main_keyid);
| TRUST_ULTIMATE ));
update_ownertrust (pk,
((get_ownertrust (pk) & ~TRUST_MASK)
| TRUST_ULTIMATE ));
if (!opt.batch) { if (!opt.batch) {
tty_printf(_("public and secret key created and signed.\n") ); tty_printf(_("public and secret key created and signed.\n") );
tty_printf(_("key marked as ultimately trusted.\n") );
tty_printf("\n"); tty_printf("\n");
list_keyblock(pub_root,0,1,NULL); list_keyblock(pub_root,0,1,NULL);
} }

View File

@ -50,7 +50,6 @@ struct kidlist_item {
}; };
/**************** /****************
* Structure to hold the context * Structure to hold the context
*/ */
@ -72,6 +71,7 @@ struct mainproc_context {
IOBUF iobuf; /* used to get the filename etc. */ IOBUF iobuf; /* used to get the filename etc. */
int trustletter; /* temp usage in list_node */ int trustletter; /* temp usage in list_node */
ulong local_id; /* ditto */ ulong local_id; /* ditto */
ulong symkeys;
struct kidlist_item *pkenc_list; /* list of encryption packets */ struct kidlist_item *pkenc_list; /* list of encryption packets */
struct { struct {
int op; int op;
@ -327,7 +327,9 @@ proc_symkey_enc( CTX c, PACKET *pkt )
c->dek->algo_info_printed = 1; c->dek->algo_info_printed = 1;
} }
} }
leave: leave:
c->symkeys++;
free_packet(pkt); free_packet(pkt);
} }
@ -477,10 +479,15 @@ proc_encrypted( CTX c, PACKET *pkt )
{ {
int result = 0; 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, 1 );
print_pkenc_list ( c->pkenc_list, 0 ); print_pkenc_list ( c->pkenc_list, 0 );
} }
write_status( STATUS_BEGIN_DECRYPTION ); write_status( STATUS_BEGIN_DECRYPTION );

View File

@ -895,12 +895,41 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
else if(backlog) { else if(backlog) {
answer=pop_strlist(&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", answer = cpr_get_utf8("pklist.user_id.enter",
_("\nEnter the user ID. End with an empty line: ")); _("\nEnter the user ID. End with an empty line: "));
trim_spaces(answer); trim_spaces(answer);
cpr_kill_prompt(); cpr_kill_prompt();
} }
if( !answer || !*answer ) { if( !answer || !*answer ) {
m_free(answer); m_free(answer);
break; break;
@ -947,26 +976,6 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
} }
else { else {
PK_LIST r; 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 = m_alloc( sizeof *r );
r->pk = pk; pk = NULL; r->pk = pk; pk = NULL;
r->next = pk_list; r->next = pk_list;

View File

@ -204,22 +204,30 @@ release_key_array ( struct key_array *keys )
* before initializing the validation module. * before initializing the validation module.
* FIXME: Should be replaced by a function to add those keys to the trustdb. * 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 void
register_trusted_key( const char *string ) register_trusted_key( const char *string )
{ {
KEYDB_SEARCH_DESC desc; KEYDB_SEARCH_DESC desc;
struct key_item *k;
if (classify_user_id (string, &desc) != KEYDB_SEARCH_MODE_LONG_KID ) { if (classify_user_id (string, &desc) != KEYDB_SEARCH_MODE_LONG_KID )
log_error(_("`%s' is not a valid long keyID\n"), string ); {
return; log_error(_("`%s' is not a valid long keyID\n"), string );
} return;
}
k = new_key_item (); register_trusted_keyid(desc.u.kid);
k->kid[0] = desc.u.kid[0];
k->kid[1] = desc.u.kid[1];
k->next = user_utk_list;
user_utk_list = k;
} }
/* /*

View File

@ -39,6 +39,7 @@
#define TRUST_FLAG_PENDING_CHECK 256 /* a check-trustdb is pending */ #define TRUST_FLAG_PENDING_CHECK 256 /* a check-trustdb is pending */
/*-- trustdb.c --*/ /*-- trustdb.c --*/
void register_trusted_keyid(u32 *keyid);
void register_trusted_key( const char *string ); void register_trusted_key( const char *string );
void check_trustdb (void); void check_trustdb (void);
void update_trustdb (void); void update_trustdb (void);