mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-04 20:38:50 +01:00
list key-capabilities
This commit is contained in:
parent
fb7e532861
commit
4e7a8b19dc
@ -47,6 +47,14 @@ ssb::1536:20:5CE086B5B5A18FF4:1998-07-07:0:::
|
|||||||
information may follow in some future versions.
|
information may follow in some future versions.
|
||||||
10. Field: User-ID. The value is quoted like a C string to avoid
|
10. Field: User-ID. The value is quoted like a C string to avoid
|
||||||
control characters (the colon is quoted "\x3a").
|
control characters (the colon is quoted "\x3a").
|
||||||
|
11. Field: Signature class
|
||||||
|
12. Field: Key capabilities:
|
||||||
|
e = encrypt
|
||||||
|
s = sign
|
||||||
|
c = certify
|
||||||
|
A key may have any combination of them. The primary key has in
|
||||||
|
addition to these letters, uppercase version of the letter to
|
||||||
|
denote the _usable_ capabilities of the entire key.
|
||||||
|
|
||||||
More fields may be added later.
|
More fields may be added later.
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-03-15 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* keylist.c (print_capabilities): New.
|
||||||
|
(list_keyblock_colon): and use it here.
|
||||||
|
|
||||||
2001-03-13 Werner Koch <wk@gnupg.org>
|
2001-03-13 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* main.c, options.h: New option fixed_list_mode.
|
* main.c, options.h: New option fixed_list_mode.
|
||||||
|
@ -154,6 +154,54 @@ print_key_data( PKT_public_key *pk, u32 *keyid )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
|
||||||
|
{
|
||||||
|
unsigned int usage = pk? pk->pubkey_usage : sk->pubkey_usage;
|
||||||
|
|
||||||
|
if ( usage & PUBKEY_USAGE_ENC ) {
|
||||||
|
putchar ('e');
|
||||||
|
}
|
||||||
|
if ( usage & PUBKEY_USAGE_SIG ) {
|
||||||
|
putchar ('s');
|
||||||
|
putchar ('c');
|
||||||
|
}
|
||||||
|
if ( keyblock ) { /* figure our the usable capabilities */
|
||||||
|
KBNODE k;
|
||||||
|
int enc=0, sign=0, cert=0;
|
||||||
|
|
||||||
|
for (k=keyblock; k; k = k->next ) {
|
||||||
|
if ( k->pkt->pkttype == PKT_PUBLIC_KEY
|
||||||
|
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|
||||||
|
pk = k->pkt->pkt.public_key;
|
||||||
|
if ( pk->is_valid && !pk->is_revoked && !pk->has_expired ) {
|
||||||
|
if ( pk->pubkey_usage & PUBKEY_USAGE_ENC )
|
||||||
|
enc = 1;
|
||||||
|
if ( pk->pubkey_usage & PUBKEY_USAGE_SIG )
|
||||||
|
sign = cert = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( k->pkt->pkttype == PKT_SECRET_KEY
|
||||||
|
|| k->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
||||||
|
sk = k->pkt->pkt.secret_key;
|
||||||
|
if ( sk->is_valid && !sk->is_revoked && !sk->has_expired ) {
|
||||||
|
if ( sk->pubkey_usage & PUBKEY_USAGE_ENC )
|
||||||
|
enc = 1;
|
||||||
|
if ( sk->pubkey_usage & PUBKEY_USAGE_SIG )
|
||||||
|
sign = cert = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (enc)
|
||||||
|
putchar ('E');
|
||||||
|
if (sign)
|
||||||
|
putchar ('S');
|
||||||
|
if (cert)
|
||||||
|
putchar ('C');
|
||||||
|
}
|
||||||
|
putchar(':');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_keyblock_print ( KBNODE keyblock, int secret )
|
list_keyblock_print ( KBNODE keyblock, int secret )
|
||||||
@ -393,6 +441,8 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
if (opt.fixed_list_mode) {
|
if (opt.fixed_list_mode) {
|
||||||
/* do not merge the first uid with the primary key */
|
/* do not merge the first uid with the primary key */
|
||||||
putchar(':');
|
putchar(':');
|
||||||
|
putchar(':');
|
||||||
|
print_capabilities (pk, sk, keyblock);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( opt.fingerprint )
|
if( opt.fingerprint )
|
||||||
fingerprint( pk, sk );
|
fingerprint( pk, sk );
|
||||||
@ -401,6 +451,7 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
|
for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
|
||||||
if( node->pkt->pkttype == PKT_USER_ID && !opt.fast_list_mode ) {
|
if( node->pkt->pkttype == PKT_USER_ID && !opt.fast_list_mode ) {
|
||||||
/*
|
/*
|
||||||
@ -434,8 +485,12 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
print_string( stdout, node->pkt->pkt.user_id->name,
|
print_string( stdout, node->pkt->pkt.user_id->name,
|
||||||
node->pkt->pkt.user_id->len, ':' );
|
node->pkt->pkt.user_id->len, ':' );
|
||||||
putchar(':');
|
putchar(':');
|
||||||
|
if (any)
|
||||||
|
putchar('\n');
|
||||||
|
else {
|
||||||
|
putchar(':');
|
||||||
|
print_capabilities (pk, sk, keyblock);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( !any ) {
|
|
||||||
if( opt.fingerprint )
|
if( opt.fingerprint )
|
||||||
fingerprint( pk, sk );
|
fingerprint( pk, sk );
|
||||||
if( opt.with_key_data )
|
if( opt.with_key_data )
|
||||||
@ -448,6 +503,9 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
PKT_public_key *pk2 = node->pkt->pkt.public_key;
|
PKT_public_key *pk2 = node->pkt->pkt.public_key;
|
||||||
|
|
||||||
if( !any ) {
|
if( !any ) {
|
||||||
|
putchar(':');
|
||||||
|
putchar(':');
|
||||||
|
print_capabilities (pk, sk, keyblock);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( opt.fingerprint )
|
if( opt.fingerprint )
|
||||||
fingerprint( pk, sk ); /* of the main key */
|
fingerprint( pk, sk ); /* of the main key */
|
||||||
@ -479,6 +537,9 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
printf("%lu", pk->local_id );
|
printf("%lu", pk->local_id );
|
||||||
putchar(':');
|
putchar(':');
|
||||||
putchar(':');
|
putchar(':');
|
||||||
|
putchar(':');
|
||||||
|
putchar(':');
|
||||||
|
print_capabilities (pk2, NULL, NULL);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( opt.fingerprint > 1 )
|
if( opt.fingerprint > 1 )
|
||||||
fingerprint( pk2, NULL );
|
fingerprint( pk2, NULL );
|
||||||
@ -490,6 +551,9 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
PKT_secret_key *sk2 = node->pkt->pkt.secret_key;
|
PKT_secret_key *sk2 = node->pkt->pkt.secret_key;
|
||||||
|
|
||||||
if( !any ) {
|
if( !any ) {
|
||||||
|
putchar(':');
|
||||||
|
putchar(':');
|
||||||
|
print_capabilities (pk, sk, keyblock);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( opt.fingerprint )
|
if( opt.fingerprint )
|
||||||
fingerprint( pk, sk ); /* of the main key */
|
fingerprint( pk, sk ); /* of the main key */
|
||||||
@ -497,17 +561,17 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyid_from_sk( sk2, keyid2 );
|
keyid_from_sk( sk2, keyid2 );
|
||||||
printf("ssb::%u:%d:%08lX%08lX:%s:%s:::\n",
|
printf("ssb::%u:%d:%08lX%08lX:%s:%s:::::",
|
||||||
nbits_from_sk( sk2 ),
|
nbits_from_sk( sk2 ),
|
||||||
sk2->pubkey_algo,
|
sk2->pubkey_algo,
|
||||||
(ulong)keyid2[0],(ulong)keyid2[1],
|
(ulong)keyid2[0],(ulong)keyid2[1],
|
||||||
datestr_from_sk( sk2 ),
|
datestr_from_sk( sk2 ),
|
||||||
sk2->expiredate? strtimestamp(sk2->expiredate):""
|
sk2->expiredate? strtimestamp(sk2->expiredate):""
|
||||||
/* fixme: add LID */
|
/* fixme: add LID */ );
|
||||||
);
|
print_capabilities (NULL, sk2, NULL);
|
||||||
|
putchar ('\n');
|
||||||
if( opt.fingerprint > 1 )
|
if( opt.fingerprint > 1 )
|
||||||
fingerprint( NULL, sk2 );
|
fingerprint( NULL, sk2 );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( opt.list_sigs && node->pkt->pkttype == PKT_SIGNATURE ) {
|
else if( opt.list_sigs && node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||||
PKT_signature *sig = node->pkt->pkt.signature;
|
PKT_signature *sig = node->pkt->pkt.signature;
|
||||||
@ -516,12 +580,15 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
|
|
||||||
if( !any ) { /* no user id, (maybe a revocation follows)*/
|
if( !any ) { /* no user id, (maybe a revocation follows)*/
|
||||||
if( sig->sig_class == 0x20 )
|
if( sig->sig_class == 0x20 )
|
||||||
puts("[revoked]");
|
fputs("[revoked]:", stdout);
|
||||||
else if( sig->sig_class == 0x18 )
|
else if( sig->sig_class == 0x18 )
|
||||||
puts("[key binding]");
|
fputs("[key binding]:", stdout);
|
||||||
else if( sig->sig_class == 0x28 )
|
else if( sig->sig_class == 0x28 )
|
||||||
puts("[subkey revoked]");
|
fputs("[subkey revoked]:", stdout);
|
||||||
else
|
else
|
||||||
|
putchar (':');
|
||||||
|
putchar(':');
|
||||||
|
print_capabilities (pk, sk, keyblock);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if( opt.fingerprint )
|
if( opt.fingerprint )
|
||||||
fingerprint( pk, sk );
|
fingerprint( pk, sk );
|
||||||
@ -577,6 +644,8 @@ list_keyblock_colon( KBNODE keyblock, int secret )
|
|||||||
}
|
}
|
||||||
if( !any ) {/* oops, no user id */
|
if( !any ) {/* oops, no user id */
|
||||||
putchar(':');
|
putchar(':');
|
||||||
|
putchar(':');
|
||||||
|
print_capabilities (pk, sk, keyblock);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user