aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyedit.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2002-08-19 08:28:00 +0000
committerWerner Koch <[email protected]>2002-08-19 08:28:00 +0000
commit89f8e7ef36cdb8bab9f239f49efc70f49a050ce5 (patch)
tree82df2556872bb28040ec2bec958bd0abf4659b88 /g10/keyedit.c
parent2002-08-16 Timo Schulz <[email protected]> (diff)
downloadgnupg-89f8e7ef36cdb8bab9f239f49efc70f49a050ce5.tar.gz
gnupg-89f8e7ef36cdb8bab9f239f49efc70f49a050ce5.zip
* getkey.c (get_user_id_native): Renamed to ..
(get_user_id_printable): this. Filter out all dangerous characters. Checked all usages. (get_user_id_string_native): Renamed to.. (get_user_id_string_printable): this. Filter out all dangerous characters. Checked all usages. * keyedit.c (show_basic_key_info): New. * keylist.c (print_fingerprint): New mode 3. * import.c (import_one): Use new function to display the user ID.
Diffstat (limited to 'g10/keyedit.c')
-rw-r--r--g10/keyedit.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/g10/keyedit.c b/g10/keyedit.c
index d9c3df09f..19da4256c 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -1845,6 +1845,74 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
}
+
+/* Display basic key information. This fucntion is suitable to show
+ information on the key without any dependencies on the trustdb or
+ any other internal GnuPG stuff. KEYBLOCK may either be a public or
+ a secret key.*/
+void
+show_basic_key_info ( KBNODE keyblock )
+{
+ KBNODE node;
+ int i;
+
+ /* The primary key */
+ for (node = keyblock; node; node = node->next)
+ {
+ if (node->pkt->pkttype == PKT_PUBLIC_KEY)
+ {
+ PKT_public_key *pk = node->pkt->pkt.public_key;
+
+ /* Note, we use the same format string as in other show
+ functions to make the translation job easier. */
+ tty_printf (_("%s%c %4u%c/%08lX created: %s expires: %s"),
+ node->pkt->pkttype == PKT_PUBLIC_KEY? "pub":"sub",
+ ' ',
+ nbits_from_pk( pk ),
+ pubkey_letter( pk->pubkey_algo ),
+ (ulong)keyid_from_pk(pk,NULL),
+ datestr_from_pk(pk),
+ expirestr_from_pk(pk) );
+ tty_printf("\n");
+ print_fingerprint ( pk, NULL, 3 );
+ tty_printf("\n");
+ }
+ else if (node->pkt->pkttype == PKT_SECRET_KEY)
+ {
+ PKT_secret_key *sk = node->pkt->pkt.secret_key;
+ tty_printf(_("%s%c %4u%c/%08lX created: %s expires: %s"),
+ node->pkt->pkttype == PKT_SECRET_KEY? "sec":"ssb",
+ ' ',
+ nbits_from_sk( sk ),
+ pubkey_letter( sk->pubkey_algo ),
+ (ulong)keyid_from_sk(sk,NULL),
+ datestr_from_sk(sk),
+ expirestr_from_sk(sk) );
+ tty_printf("\n");
+ print_fingerprint (NULL, sk, 3 );
+ tty_printf("\n");
+ }
+ }
+
+ /* The user IDs. */
+ for (i=0, node = keyblock; node; node = node->next)
+ {
+ if (node->pkt->pkttype == PKT_USER_ID)
+ {
+ PKT_user_id *uid = node->pkt->pkt.user_id;
+ ++i;
+
+ tty_printf (" ");
+ if (uid->is_revoked)
+ tty_printf ("[revoked] ");
+ if ( uid->is_expired )
+ tty_printf ("[expired] ");
+ tty_print_utf8_string (uid->name, uid->len);
+ tty_printf ("\n");
+ }
+ }
+}
+
static void
show_key_and_fingerprint( KBNODE keyblock )
{