mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-12 23:01:14 +01:00
* 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.
This commit is contained in:
parent
2a9bd94734
commit
773513c70b
@ -1,3 +1,17 @@
|
||||
2003-01-14 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* 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.
|
||||
|
||||
2003-01-14 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* g10.c (add_group): Fixed group parsing to allow more than one
|
||||
|
@ -298,9 +298,8 @@ free_user_id (PKT_user_id *uid)
|
||||
return;
|
||||
|
||||
free_attributes(uid);
|
||||
|
||||
if (uid->prefs)
|
||||
m_free (uid->prefs);
|
||||
m_free (uid->prefs);
|
||||
m_free (uid->namehash);
|
||||
m_free (uid);
|
||||
}
|
||||
|
||||
|
@ -237,6 +237,7 @@ u32 keyid_from_sk( PKT_secret_key *sk, u32 *keyid );
|
||||
u32 keyid_from_pk( PKT_public_key *pk, u32 *keyid );
|
||||
u32 keyid_from_sig( PKT_signature *sig, u32 *keyid );
|
||||
u32 keyid_from_fingerprint( const byte *fprint, size_t fprint_len, u32 *keyid );
|
||||
byte *namehash_from_uid(PKT_user_id *uid);
|
||||
unsigned nbits_from_pk( PKT_public_key *pk );
|
||||
unsigned nbits_from_sk( PKT_secret_key *sk );
|
||||
const char *datestr_from_pk( PKT_public_key *pk );
|
||||
|
16
g10/keyid.c
16
g10/keyid.c
@ -241,6 +241,22 @@ keyid_from_sig( PKT_signature *sig, u32 *keyid )
|
||||
return sig->keyid[1];
|
||||
}
|
||||
|
||||
byte *
|
||||
namehash_from_uid(PKT_user_id *uid)
|
||||
{
|
||||
if(uid->namehash==NULL)
|
||||
{
|
||||
uid->namehash=m_alloc(20);
|
||||
|
||||
if(uid->attrib_data)
|
||||
rmd160_hash_buffer(uid->namehash,uid->attrib_data,uid->attrib_len);
|
||||
else
|
||||
rmd160_hash_buffer(uid->namehash,uid->name,uid->len);
|
||||
}
|
||||
|
||||
return uid->namehash;
|
||||
}
|
||||
|
||||
/****************
|
||||
* return the number of bits used in the pk
|
||||
*/
|
||||
|
@ -752,38 +752,46 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
|
||||
|
||||
for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
|
||||
if( node->pkt->pkttype == PKT_USER_ID && !opt.fast_list_mode ) {
|
||||
PKT_user_id *uid=node->pkt->pkt.user_id;
|
||||
if(attrib_fp && node->pkt->pkt.user_id->attrib_data!=NULL)
|
||||
dump_attribs(node->pkt->pkt.user_id,pk,sk);
|
||||
/*
|
||||
* Fixme: We need a is_valid flag here too
|
||||
*/
|
||||
if( any ) {
|
||||
char *str=node->pkt->pkt.user_id->attrib_data?"uat":"uid";
|
||||
if ( node->pkt->pkt.user_id->is_revoked )
|
||||
printf("%s:r::::::::",str);
|
||||
else if ( node->pkt->pkt.user_id->is_expired )
|
||||
printf("%s:e::::::::",str);
|
||||
int i;
|
||||
char *str=uid->attrib_data?"uat":"uid";
|
||||
if ( uid->is_revoked )
|
||||
printf("%s:r::::",str);
|
||||
else if ( uid->is_expired )
|
||||
printf("%s:e::::",str);
|
||||
else if ( opt.no_expensive_trust_checks ) {
|
||||
printf("%s:::::::::",str);
|
||||
printf("%s:::::",str);
|
||||
}
|
||||
else {
|
||||
int uid_validity;
|
||||
|
||||
if( pk && !ulti_hack )
|
||||
uid_validity=get_validity_info (pk,
|
||||
node->pkt->pkt.user_id);
|
||||
uid_validity=get_validity_info (pk, uid);
|
||||
else
|
||||
uid_validity = 'u';
|
||||
printf("%s:%c::::::::",str,uid_validity);
|
||||
printf("%s:%c::::",str,uid_validity);
|
||||
}
|
||||
|
||||
printf("%s:",colon_strtime(uid->created));
|
||||
printf("%s:",colon_strtime(uid->expiredate));
|
||||
|
||||
namehash_from_uid(uid);
|
||||
|
||||
for(i=0; i < 20; i++ )
|
||||
printf("%02X",uid->namehash[i]);
|
||||
|
||||
printf("::");
|
||||
}
|
||||
if(node->pkt->pkt.user_id->attrib_data)
|
||||
printf("%u %lu",
|
||||
node->pkt->pkt.user_id->numattribs,
|
||||
node->pkt->pkt.user_id->attrib_len);
|
||||
if(uid->attrib_data)
|
||||
printf("%u %lu",uid->numattribs,uid->attrib_len);
|
||||
else
|
||||
print_string( stdout, node->pkt->pkt.user_id->name,
|
||||
node->pkt->pkt.user_id->len, ':' );
|
||||
print_string(stdout,uid->name,uid->len, ':' );
|
||||
putchar(':');
|
||||
if (any)
|
||||
putchar('\n');
|
||||
|
@ -168,6 +168,7 @@ typedef struct {
|
||||
int numattribs;
|
||||
byte *attrib_data; /* if this is not NULL, the packet is an attribute */
|
||||
unsigned long attrib_len;
|
||||
byte *namehash;
|
||||
int help_key_usage;
|
||||
u32 help_key_expire;
|
||||
int help_full_count;
|
||||
|
@ -1877,6 +1877,7 @@ static void setup_user_id(PACKET *packet)
|
||||
packet->pkt.user_id->help_key_usage = 0;
|
||||
packet->pkt.user_id->help_key_expire = 0;
|
||||
packet->pkt.user_id->prefs = NULL;
|
||||
packet->pkt.user_id->namehash = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user