mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +01:00
* keydb.h, keyid.c (keystr_from_pk, keystr_from_sk): New functions to pull
a key string from a key in one step. This isn't faster than before, but makes for neater code. * keylist.c (list_keyblock_print): Use keystr_from_xx here. (print_key_data): No need to pass a keyid in.
This commit is contained in:
parent
efec599797
commit
b8cd31217e
@ -1,3 +1,12 @@
|
|||||||
|
2004-03-06 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* keydb.h, keyid.c (keystr_from_pk, keystr_from_sk): New functions
|
||||||
|
to pull a key string from a key in one step. This isn't faster
|
||||||
|
than before, but makes for neater code.
|
||||||
|
|
||||||
|
* keylist.c (list_keyblock_print): Use keystr_from_xx here.
|
||||||
|
(print_key_data): No need to pass a keyid in.
|
||||||
|
|
||||||
2004-03-05 David Shaw <dshaw@jabberwocky.com>
|
2004-03-05 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* keyid.c (keyid_from_sk): Minor performance boost by caching
|
* keyid.c (keyid_from_sk): Minor performance boost by caching
|
||||||
|
@ -241,6 +241,8 @@ int pubkey_letter( int algo );
|
|||||||
void hash_public_key( MD_HANDLE md, PKT_public_key *pk );
|
void hash_public_key( MD_HANDLE md, PKT_public_key *pk );
|
||||||
size_t keystrlen(void);
|
size_t keystrlen(void);
|
||||||
const char *keystr(u32 *keyid);
|
const char *keystr(u32 *keyid);
|
||||||
|
const char *keystr_from_pk(PKT_public_key *pk);
|
||||||
|
const char *keystr_from_sk(PKT_secret_key *sk);
|
||||||
u32 keyid_from_sk( PKT_secret_key *sk, u32 *keyid );
|
u32 keyid_from_sk( PKT_secret_key *sk, u32 *keyid );
|
||||||
u32 keyid_from_pk( PKT_public_key *pk, u32 *keyid );
|
u32 keyid_from_pk( PKT_public_key *pk, u32 *keyid );
|
||||||
u32 keyid_from_sig( PKT_signature *sig, u32 *keyid );
|
u32 keyid_from_sig( PKT_signature *sig, u32 *keyid );
|
||||||
|
26
g10/keyid.c
26
g10/keyid.c
@ -196,6 +196,21 @@ keystr(u32 *keyid)
|
|||||||
return keyid_str;
|
return keyid_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
keystr_from_pk(PKT_public_key *pk)
|
||||||
|
{
|
||||||
|
keyid_from_pk(pk,NULL);
|
||||||
|
|
||||||
|
return keystr(pk->keyid);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
keystr_from_sk(PKT_secret_key *sk)
|
||||||
|
{
|
||||||
|
keyid_from_sk(sk,NULL);
|
||||||
|
|
||||||
|
return keystr(sk->keyid);
|
||||||
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Get the keyid from the secret key and put it into keyid
|
* Get the keyid from the secret key and put it into keyid
|
||||||
@ -264,7 +279,8 @@ keyid_from_pk( PKT_public_key *pk, u32 *keyid )
|
|||||||
if( !keyid )
|
if( !keyid )
|
||||||
keyid = dummy_keyid;
|
keyid = dummy_keyid;
|
||||||
|
|
||||||
if( pk->keyid[0] || pk->keyid[1] ) {
|
if( pk->keyid[0] || pk->keyid[1] )
|
||||||
|
{
|
||||||
keyid[0] = pk->keyid[0];
|
keyid[0] = pk->keyid[0];
|
||||||
keyid[1] = pk->keyid[1];
|
keyid[1] = pk->keyid[1];
|
||||||
lowbits = keyid[1];
|
lowbits = keyid[1];
|
||||||
@ -281,10 +297,13 @@ keyid_from_pk( PKT_public_key *pk, u32 *keyid )
|
|||||||
else
|
else
|
||||||
pk->keyid[0]=pk->keyid[1]=keyid[0]=keyid[1]=lowbits=0;
|
pk->keyid[0]=pk->keyid[1]=keyid[0]=keyid[1]=lowbits=0;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
const byte *dp;
|
const byte *dp;
|
||||||
MD_HANDLE md;
|
MD_HANDLE md;
|
||||||
md = do_fingerprint_md(pk);
|
md = do_fingerprint_md(pk);
|
||||||
|
if(md)
|
||||||
|
{
|
||||||
dp = md_read( md, 0 );
|
dp = md_read( md, 0 );
|
||||||
keyid[0] = dp[12] << 24 | dp[13] << 16 | dp[14] << 8 | dp[15] ;
|
keyid[0] = dp[12] << 24 | dp[13] << 16 | dp[14] << 8 | dp[15] ;
|
||||||
keyid[1] = dp[16] << 24 | dp[17] << 16 | dp[18] << 8 | dp[19] ;
|
keyid[1] = dp[16] << 24 | dp[17] << 16 | dp[18] << 8 | dp[19] ;
|
||||||
@ -293,6 +312,9 @@ keyid_from_pk( PKT_public_key *pk, u32 *keyid )
|
|||||||
pk->keyid[0] = keyid[0];
|
pk->keyid[0] = keyid[0];
|
||||||
pk->keyid[1] = keyid[1];
|
pk->keyid[1] = keyid[1];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
pk->keyid[0]=pk->keyid[1]=keyid[0]=keyid[1]=lowbits=0;
|
||||||
|
}
|
||||||
|
|
||||||
return lowbits;
|
return lowbits;
|
||||||
}
|
}
|
||||||
|
@ -460,7 +460,7 @@ list_one( STRLIST names, int secret )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_key_data( PKT_public_key *pk, u32 *keyid )
|
print_key_data( PKT_public_key *pk )
|
||||||
{
|
{
|
||||||
int n = pk ? pubkey_get_npkey( pk->pubkey_algo ) : 0;
|
int n = pk ? pubkey_get_npkey( pk->pubkey_algo ) : 0;
|
||||||
int i;
|
int i;
|
||||||
@ -600,7 +600,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
|
|||||||
KBNODE node;
|
KBNODE node;
|
||||||
PKT_public_key *pk;
|
PKT_public_key *pk;
|
||||||
PKT_secret_key *sk;
|
PKT_secret_key *sk;
|
||||||
u32 keyid[2];
|
|
||||||
int any=0;
|
int any=0;
|
||||||
struct sig_stats *stats=opaque;
|
struct sig_stats *stats=opaque;
|
||||||
int skip_sigs=0;
|
int skip_sigs=0;
|
||||||
@ -621,12 +620,11 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
|
|||||||
{
|
{
|
||||||
pk = NULL;
|
pk = NULL;
|
||||||
sk = node->pkt->pkt.secret_key;
|
sk = node->pkt->pkt.secret_key;
|
||||||
keyid_from_sk( sk, keyid );
|
|
||||||
|
|
||||||
printf("sec%c %4u%c/%s %s%s",(sk->protect.s2k.mode==1001)?'#':
|
printf("sec%c %4u%c/%s %s%s",(sk->protect.s2k.mode==1001)?'#':
|
||||||
(sk->protect.s2k.mode==1002)?'>':' ',
|
(sk->protect.s2k.mode==1002)?'>':' ',
|
||||||
nbits_from_sk( sk ),pubkey_letter( sk->pubkey_algo ),
|
nbits_from_sk( sk ),pubkey_letter( sk->pubkey_algo ),
|
||||||
keystr(keyid),datestr_from_sk( sk ),newformat?"":" " );
|
keystr_from_sk(sk),datestr_from_sk( sk ),newformat?"":" " );
|
||||||
|
|
||||||
if(newformat && sk->expiredate )
|
if(newformat && sk->expiredate )
|
||||||
printf(_(" [expires: %s]"), expirestr_from_sk( sk ) );
|
printf(_(" [expires: %s]"), expirestr_from_sk( sk ) );
|
||||||
@ -638,7 +636,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
|
|||||||
#endif
|
#endif
|
||||||
pk = node->pkt->pkt.public_key;
|
pk = node->pkt->pkt.public_key;
|
||||||
sk = NULL;
|
sk = NULL;
|
||||||
keyid_from_pk( pk, keyid );
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
validity=get_validity(pk,NULL);
|
validity=get_validity(pk,NULL);
|
||||||
@ -648,7 +645,7 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
|
|||||||
|
|
||||||
printf("pub %4u%c/%s %s%s",
|
printf("pub %4u%c/%s %s%s",
|
||||||
nbits_from_pk(pk),pubkey_letter(pk->pubkey_algo),
|
nbits_from_pk(pk),pubkey_letter(pk->pubkey_algo),
|
||||||
keystr(keyid),datestr_from_pk( pk ),newformat?"":" " );
|
keystr_from_pk(pk),datestr_from_pk( pk ),newformat?"":" " );
|
||||||
|
|
||||||
/* We didn't include this before in the key listing, but there
|
/* We didn't include this before in the key listing, but there
|
||||||
is room in the new format, so why not? */
|
is room in the new format, so why not? */
|
||||||
@ -721,15 +718,15 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
|
|||||||
if( fpr )
|
if( fpr )
|
||||||
print_fingerprint( pk, sk, 0 );
|
print_fingerprint( pk, sk, 0 );
|
||||||
if( opt.with_key_data )
|
if( opt.with_key_data )
|
||||||
print_key_data( pk, keyid );
|
print_key_data( pk );
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((opt.list_options&LIST_SHOW_PHOTOS) && uid->attribs!=NULL)
|
if((opt.list_options&LIST_SHOW_PHOTOS) && uid->attribs!=NULL)
|
||||||
show_photos(uid->attribs,uid->numattribs,pk,sk);
|
show_photos(uid->attribs,uid->numattribs,pk,sk);
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
|
||||||
u32 keyid2[2];
|
{
|
||||||
PKT_public_key *pk2 = node->pkt->pkt.public_key;
|
PKT_public_key *pk2 = node->pkt->pkt.public_key;
|
||||||
|
|
||||||
if((pk2->is_revoked || pk2->has_expired)
|
if((pk2->is_revoked || pk2->has_expired)
|
||||||
@ -741,17 +738,17 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
|
|||||||
else
|
else
|
||||||
skip_sigs=0;
|
skip_sigs=0;
|
||||||
|
|
||||||
if( !any ) {
|
if( !any )
|
||||||
|
{
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( fpr )
|
if( fpr )
|
||||||
print_fingerprint( pk, sk, 0 ); /* of the main key */
|
print_fingerprint( pk, sk, 0 ); /* of the main key */
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyid_from_pk( pk2, keyid2 );
|
|
||||||
printf("sub %4u%c/%s %s",
|
printf("sub %4u%c/%s %s",
|
||||||
nbits_from_pk( pk2 ),pubkey_letter( pk2->pubkey_algo ),
|
nbits_from_pk( pk2 ),pubkey_letter( pk2->pubkey_algo ),
|
||||||
keystr(keyid2),datestr_from_pk(pk2));
|
keystr_from_pk(pk2),datestr_from_pk(pk2));
|
||||||
if( pk2->is_revoked )
|
if( pk2->is_revoked )
|
||||||
printf(_(" [revoked: %s]"), revokestr_from_pk(pk2));
|
printf(_(" [revoked: %s]"), revokestr_from_pk(pk2));
|
||||||
else if( pk2->has_expired )
|
else if( pk2->has_expired )
|
||||||
@ -762,25 +759,25 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
|
|||||||
if( fpr > 1 )
|
if( fpr > 1 )
|
||||||
print_fingerprint( pk2, NULL, 0 );
|
print_fingerprint( pk2, NULL, 0 );
|
||||||
if( opt.with_key_data )
|
if( opt.with_key_data )
|
||||||
print_key_data( pk2, keyid2 );
|
print_key_data( pk2 );
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY )
|
||||||
u32 keyid2[2];
|
{
|
||||||
PKT_secret_key *sk2 = node->pkt->pkt.secret_key;
|
PKT_secret_key *sk2 = node->pkt->pkt.secret_key;
|
||||||
|
|
||||||
if( !any ) {
|
if( !any )
|
||||||
|
{
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( fpr )
|
if( fpr )
|
||||||
print_fingerprint( pk, sk, 0 ); /* of the main key */
|
print_fingerprint( pk, sk, 0 ); /* of the main key */
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyid_from_sk( sk2, keyid2 );
|
|
||||||
printf("ssb%c %4u%c/%s %s",
|
printf("ssb%c %4u%c/%s %s",
|
||||||
(sk->protect.s2k.mode==1001)?'#':
|
(sk->protect.s2k.mode==1001)?'#':
|
||||||
(sk->protect.s2k.mode==1002)?'>':' ',
|
(sk->protect.s2k.mode==1002)?'>':' ',
|
||||||
nbits_from_sk( sk2 ),pubkey_letter( sk2->pubkey_algo ),
|
nbits_from_sk( sk2 ),pubkey_letter( sk2->pubkey_algo ),
|
||||||
keystr(keyid2),datestr_from_sk( sk2 ) );
|
keystr_from_sk(sk2),datestr_from_sk( sk2 ) );
|
||||||
if( sk2->expiredate )
|
if( sk2->expiredate )
|
||||||
printf(_(" [expires: %s]"), expirestr_from_sk( sk2 ) );
|
printf(_(" [expires: %s]"), expirestr_from_sk( sk2 ) );
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
@ -980,7 +977,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
|
|||||||
if( fpr )
|
if( fpr )
|
||||||
print_fingerprint( pk, sk, 0 );
|
print_fingerprint( pk, sk, 0 );
|
||||||
if( opt.with_key_data )
|
if( opt.with_key_data )
|
||||||
print_key_data( pk, keyid );
|
print_key_data( pk );
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1040,7 +1037,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
|
|||||||
if( fpr )
|
if( fpr )
|
||||||
print_fingerprint( pk, sk, 0 );
|
print_fingerprint( pk, sk, 0 );
|
||||||
if( opt.with_key_data )
|
if( opt.with_key_data )
|
||||||
print_key_data( pk, keyid );
|
print_key_data( pk );
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1086,7 +1083,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
|
|||||||
if( fpr > 1 )
|
if( fpr > 1 )
|
||||||
print_fingerprint( pk2, NULL, 0 );
|
print_fingerprint( pk2, NULL, 0 );
|
||||||
if( opt.with_key_data )
|
if( opt.with_key_data )
|
||||||
print_key_data( pk2, keyid2 );
|
print_key_data( pk2 );
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
||||||
u32 keyid2[2];
|
u32 keyid2[2];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user