From 53f2944998bebf174a19ce25d7dd7b1b477ecba4 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Wed, 7 May 2003 14:04:27 +0000 Subject: [PATCH] * keyedit.c (sign_uids): Show keyid of the key making the signature. * trustdb.h, trustdb.c (is_disabled), keylist.c (print_capabilities), gpgv.c (is_disabled): is_disabled now takes a pk and not just the keyid. This is for speed since there is no need to re-fetch a key when we already have that key handy. * getkey.c (skip_disabled): New function to get a pk and call is_disabled on it. (key_byname): Use it here. --- g10/ChangeLog | 14 ++++++++++++++ g10/getkey.c | 23 ++++++++++++++++++++++- g10/gpgv.c | 2 +- g10/keyedit.c | 2 +- g10/keylist.c | 12 +++--------- g10/trustdb.c | 18 ++++-------------- g10/trustdb.h | 2 +- 7 files changed, 46 insertions(+), 27 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 7615bdce7..7449ce88b 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,17 @@ +2003-05-07 David Shaw + + * keyedit.c (sign_uids): Show keyid of the key making the + signature. + + * trustdb.h, trustdb.c (is_disabled), keylist.c + (print_capabilities), gpgv.c (is_disabled): is_disabled now takes + a pk and not just the keyid. This is for speed since there is no + need to re-fetch a key when we already have that key handy. + + * getkey.c (skip_disabled): New function to get a pk and call + is_disabled on it. + (key_byname): Use it here. + 2003-05-02 David Shaw * g10.c (main): Show errors for failure in export, send-keys, diff --git a/g10/getkey.c b/g10/getkey.c index ff26d05d9..13bbda366 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -733,6 +733,27 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) return classify_user_id2 (name, desc, &dummy); } +static int +skip_disabled(void *dummy,u32 *keyid) +{ + int rc,disabled=0; + PKT_public_key *pk=m_alloc_clear(sizeof(PKT_public_key)); + + rc = get_pubkey(pk, keyid); + if(rc) + { + log_error("error checking disabled status of %08lX: %s\n", + (ulong)keyid[1],g10_errstr(rc)); + goto leave; + } + + disabled=is_disabled(pk); + + leave: + free_public_key(pk); + return disabled; +} + /**************** * Try to get the pubkey by the userid. This function looks for the * first pubkey certificate which has the given name in a user_id. @@ -784,7 +805,7 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist, && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16 && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20 && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR) - ctx->items[n].skipfnc=is_disabled; + ctx->items[n].skipfnc=skip_disabled; } ctx->kr_handle = keydb_new (secmode); diff --git a/g10/gpgv.c b/g10/gpgv.c index 6838ce74c..f0509ba3f 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -243,7 +243,7 @@ check_signatures_trust( PKT_signature *sig ) */ int -is_disabled(void *dummy,u32 *keyid) +is_disabled(PKT_public_key *pk) { return 0; } diff --git a/g10/keyedit.c b/g10/keyedit.c index b06506496..60614e378 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -637,7 +637,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified, p = get_user_id( sk_keyid, &n ); tty_print_utf8_string( p, n ); m_free(p); p = NULL; - tty_printf("\"\n"); + tty_printf("\" (%08lX)\n",(ulong)sk_keyid[1]); if(selfsig) { diff --git a/g10/keylist.c b/g10/keylist.c index 49c7afdb5..54296e7b8 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -315,23 +315,17 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock) } } - if ( keyblock ) { /* figure our the usable capabilities */ + if ( keyblock ) { /* figure out the usable capabilities */ KBNODE k; int enc=0, sign=0, cert=0, disabled=0; for (k=keyblock; k; k = k->next ) { if ( k->pkt->pkttype == PKT_PUBLIC_KEY || k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) { - u32 kid[2]; pk = k->pkt->pkt.public_key; - if(k->pkt->pkttype==PKT_PUBLIC_KEY) - { - keyid_from_pk(pk,kid); - - if(is_disabled(NULL,kid)) - disabled=1; - } + if(pk->is_primary) + disabled=is_disabled(pk); if ( pk->is_valid && !pk->is_revoked && !pk->has_expired ) { if ( pk->pubkey_usage & PUBKEY_USAGE_ENC ) diff --git a/g10/trustdb.c b/g10/trustdb.c index c148cfd2d..5edc10d5b 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -745,23 +745,14 @@ clear_validity (PKT_public_key *pk) /* Return true if key is disabled */ int -is_disabled(void *dummy,u32 *keyid) +is_disabled(PKT_public_key *pk) { int rc; TRUSTREC trec; - int disabled=0; /* default to not disabled */ - PKT_public_key *pk=m_alloc_clear(sizeof(PKT_public_key)); + int disabled=0; - init_trustdb (); + init_trustdb(); - rc = get_pubkey(pk, keyid); - if(rc) - { - log_error("error checking disabled status of %08lX: %s\n", - (ulong)keyid[1],g10_errstr(rc)); - goto leave; - } - rc = read_trust_record (pk, &trec); if (rc && rc != -1) { @@ -775,8 +766,7 @@ is_disabled(void *dummy,u32 *keyid) disabled=1; leave: - free_public_key(pk); - return disabled; + return disabled; } /* diff --git a/g10/trustdb.h b/g10/trustdb.h index 41f2af57f..9f8dd9dea 100644 --- a/g10/trustdb.h +++ b/g10/trustdb.h @@ -48,7 +48,7 @@ void sync_trustdb( void ); void revalidation_mark (void); -int is_disabled(void *dummy,u32 *keyid); +int is_disabled(PKT_public_key *pk); unsigned int get_validity (PKT_public_key *pk, PKT_user_id *uid); int get_validity_info (PKT_public_key *pk, PKT_user_id *uid);