diff options
author | David Shaw <[email protected]> | 2003-01-14 18:13:22 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2003-01-14 18:13:22 +0000 |
commit | 773513c70b470f54651b77e81438d51adad6f01a (patch) | |
tree | 4391fdef87f0c721a35b928f23d711bfaecad52f /g10/trustdb.c | |
parent | * g10.c (add_group): Fixed group parsing to allow more than one (diff) | |
download | gnupg-773513c70b470f54651b77e81438d51adad6f01a.tar.gz gnupg-773513c70b470f54651b77e81438d51adad6f01a.zip |
* packet.h, parse-packet.c (setup_user_id), free-packet.c (free_user_id),
keydb.h, keyid.c (namehash_from_uid): New function to rmd160-hash the
contents of a user ID packet and cache it in the uid object.
* keylist.c (list_keyblock_colon): Use namehash in field 8 of uids. Show
dates for creation (selfsig date), and expiration in fields 6 and 7.
* trustdb.c (get_validity, get_validity_counts, update_validity): Use new
namehash function rather than hashing it locally.
Diffstat (limited to 'g10/trustdb.c')
-rw-r--r-- | g10/trustdb.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/g10/trustdb.c b/g10/trustdb.c index b5bdcf871..e0e29f1d9 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -819,12 +819,8 @@ update_validity (PKT_public_key *pk, PKT_user_id *uid, TRUSTREC trec, vrec; int rc; ulong recno; - byte namehash[20]; - if(uid->attrib_data) - rmd160_hash_buffer (namehash,uid->attrib_data,uid->attrib_len); - else - rmd160_hash_buffer (namehash, uid->name, uid->len ); + namehash_from_uid(uid); rc = read_trust_record (pk, &trec); if (rc && rc != -1) @@ -849,7 +845,7 @@ update_validity (PKT_public_key *pk, PKT_user_id *uid, while (recno) { read_record (recno, &vrec, RECTYPE_VALID); - if ( !memcmp (vrec.r.valid.namehash, namehash, 20) ) + if ( !memcmp (vrec.r.valid.namehash, uid->namehash, 20) ) break; recno = vrec.r.valid.next; } @@ -859,7 +855,7 @@ update_validity (PKT_public_key *pk, PKT_user_id *uid, memset (&vrec, 0, sizeof vrec); vrec.recnum = tdbio_new_recnum (); vrec.rectype = RECTYPE_VALID; - memcpy (vrec.r.valid.namehash, namehash, 20); + memcpy (vrec.r.valid.namehash, uid->namehash, 20); vrec.r.valid.next = trec.r.trust.validlist; } vrec.r.valid.validity = validity; @@ -970,15 +966,9 @@ get_validity (PKT_public_key *pk, PKT_user_id *uid) 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 ); - } + namehash_from_uid(uid); init_trustdb (); if (!did_nextcheck) @@ -1038,7 +1028,7 @@ get_validity (PKT_public_key *pk, PKT_user_id *uid) read_record (recno, &vrec, RECTYPE_VALID); if ( validity < (vrec.r.valid.validity & TRUST_MASK) ) validity = (vrec.r.valid.validity & TRUST_MASK); - if ( uid && !memcmp (vrec.r.valid.namehash, namehash, 20) ) + if ( uid && !memcmp (vrec.r.valid.namehash, uid->namehash, 20) ) break; recno = vrec.r.valid.next; } @@ -1095,15 +1085,11 @@ get_validity_counts (PKT_public_key *pk, PKT_user_id *uid) { TRUSTREC trec, vrec; ulong recno; - byte namehash[20]; if(pk==NULL || uid==NULL) BUG(); - if(uid->attrib_data) - rmd160_hash_buffer (namehash,uid->attrib_data,uid->attrib_len); - else - rmd160_hash_buffer (namehash, uid->name, uid->len ); + namehash_from_uid(uid); uid->help_marginal_count=uid->help_full_count=0; @@ -1118,7 +1104,7 @@ get_validity_counts (PKT_public_key *pk, PKT_user_id *uid) { read_record (recno, &vrec, RECTYPE_VALID); - if(memcmp(vrec.r.valid.namehash,namehash,20)==0) + if(memcmp(vrec.r.valid.namehash,uid->namehash,20)==0) { uid->help_marginal_count=vrec.r.valid.marginal_count; uid->help_full_count=vrec.r.valid.full_count; |