diff --git a/g10/ChangeLog b/g10/ChangeLog index a111af56c..7ab7b43f0 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,13 @@ +2003-01-08 David Shaw + + * packet.h, pkclist.c (build_pk_list), free-packet.c + (release_public_key_parts): Remove unused namehash element for + public keys. + + * trustdb.h, gpgv.c, trustdb.c (get_validity, get_validity_info): + Pass a user ID in rather than a namehash, so we only have to do + the hashing in one place. + 2003-01-06 David Shaw * packet.h, tdbio.h, tdbio.c (tdbio_read_record, diff --git a/g10/free-packet.c b/g10/free-packet.c index e760999be..89a67eb1f 100644 --- a/g10/free-packet.c +++ b/g10/free-packet.c @@ -68,7 +68,6 @@ free_seckey_enc( PKT_signature *sig ) } - void release_public_key_parts( PKT_public_key *pk ) { @@ -84,10 +83,6 @@ release_public_key_parts( PKT_public_key *pk ) m_free (pk->prefs); pk->prefs = NULL; } - if( pk->namehash ) { - m_free(pk->namehash); - pk->namehash = NULL; - } if (pk->user_id) { free_user_id (pk->user_id); pk->user_id = NULL; diff --git a/g10/gpgv.c b/g10/gpgv.c index 6de5d7267..5ab1ed1b6 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -248,7 +248,7 @@ is_disabled(void *dummy,u32 *keyid) } int -get_validity_info (PKT_public_key *pk, const byte *namehash ) +get_validity_info (PKT_public_key *pk, PKT_user_id *uid) { return '?'; } diff --git a/g10/keyedit.c b/g10/keyedit.c index 6f6240580..afbda995d 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1660,18 +1660,10 @@ show_key_with_all_names_colon (KBNODE keyblock) printf("::::::::"); else { - byte namehash[20]; int uid_validity; if( primary && !ulti_hack ) - { - if( uid->attrib_data ) - rmd160_hash_buffer(namehash, - uid->attrib_data, uid->attrib_len); - else - rmd160_hash_buffer( namehash, uid->name, uid->len ); - uid_validity = get_validity_info( primary, namehash ); - } + uid_validity = get_validity_info( primary, uid ); else uid_validity = 'u'; printf("%c::::::::",uid_validity); diff --git a/g10/keylist.c b/g10/keylist.c index cce269cd8..49c7afdb5 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -722,20 +722,11 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr ) printf("%s:::::::::",str); } else { - byte namehash[20]; int uid_validity; - if( pk && !ulti_hack ) { - if( node->pkt->pkt.user_id->attrib_data ) - rmd160_hash_buffer( namehash, - node->pkt->pkt.user_id->attrib_data, - node->pkt->pkt.user_id->attrib_len); - else - rmd160_hash_buffer( namehash, - node->pkt->pkt.user_id->name, - node->pkt->pkt.user_id->len ); - uid_validity = get_validity_info( pk, namehash ); - } + if( pk && !ulti_hack ) + uid_validity=get_validity_info (pk, + node->pkt->pkt.user_id); else uid_validity = 'u'; printf("%s:%c::::::::",str,uid_validity); diff --git a/g10/packet.h b/g10/packet.h index b217bacbb..492e8aa85 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -207,7 +207,6 @@ typedef struct { byte is_primary; prefitem_t *prefs; /* list of preferences (may be NULL) */ int mdc_feature; /* mdc feature set */ - byte *namehash; /* if != NULL: found by this name */ PKT_user_id *user_id; /* if != NULL: found by that uid */ struct revocation_key *revkey; int numrevkeys; diff --git a/g10/pkclist.c b/g10/pkclist.c index 6385d3bf7..5b01ecf1a 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -984,7 +984,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use ) else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) { int trustlevel; - trustlevel = get_validity (pk, pk->namehash); + trustlevel = get_validity (pk, NULL); if( (trustlevel & TRUST_FLAG_DISABLED) ) { free_public_key(pk); pk = NULL; log_info(_("%s: skipped: public key is disabled\n"), diff --git a/g10/trustdb.c b/g10/trustdb.c index b9527ec71..cfd2dd922 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -785,7 +785,7 @@ is_disabled(void *dummy,u32 *keyid) * otherwise, a reasonable value for the entire key is returned. */ unsigned int -get_validity (PKT_public_key *pk, const byte *namehash) +get_validity (PKT_public_key *pk, PKT_user_id *uid) { static int did_nextcheck; TRUSTREC trec, vrec; @@ -794,6 +794,15 @@ get_validity (PKT_public_key *pk, const byte *namehash) unsigned int validity; u32 kid[2]; PKT_public_key *main_pk; + byte namehash[20]; + + if(uid) + { + if( uid->attrib_data ) + rmd160_hash_buffer (namehash,uid->attrib_data,uid->attrib_len); + else + rmd160_hash_buffer (namehash, uid->name, uid->len ); + } init_trustdb (); if (!did_nextcheck) @@ -853,7 +862,7 @@ get_validity (PKT_public_key *pk, const byte *namehash) read_record (recno, &vrec, RECTYPE_VALID); if ( validity < (vrec.r.valid.validity & TRUST_MASK) ) validity = (vrec.r.valid.validity & TRUST_MASK); - if ( namehash && !memcmp (vrec.r.valid.namehash, namehash, 20) ) + if ( uid && !memcmp (vrec.r.valid.namehash, namehash, 20) ) break; recno = vrec.r.valid.next; } @@ -884,12 +893,12 @@ get_validity (PKT_public_key *pk, const byte *namehash) } int -get_validity_info (PKT_public_key *pk, const byte *namehash) +get_validity_info (PKT_public_key *pk, PKT_user_id *uid) { int trustlevel; int c; - trustlevel = get_validity (pk, namehash); + trustlevel = get_validity (pk, uid); if( trustlevel & TRUST_FLAG_DISABLED ) return 'd'; if( trustlevel & TRUST_FLAG_REVOKED ) diff --git a/g10/trustdb.h b/g10/trustdb.h index 859e37255..1757a30d2 100644 --- a/g10/trustdb.h +++ b/g10/trustdb.h @@ -50,8 +50,8 @@ int trust_letter( unsigned value ); void revalidation_mark (void); int is_disabled(void *dummy,u32 *keyid); -unsigned int get_validity (PKT_public_key *pk, const byte *namehash); -int get_validity_info (PKT_public_key *pk, const byte *namehash); +unsigned int get_validity (PKT_public_key *pk, PKT_user_id *uid); +int get_validity_info (PKT_public_key *pk, PKT_user_id *uid); void list_trust_path( const char *username );