diff options
author | Werner Koch <[email protected]> | 2004-09-20 18:38:39 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-09-20 18:38:39 +0000 |
commit | 9d17a635c977a209bee78203e3cfb85a9cb09fc6 (patch) | |
tree | 9fdd7a23c8193693c305a5f1716f02b170fc2899 /g10/keylist.c | |
parent | * cardglue.c (open_card): Use shutdown code if possible. (diff) | |
download | gnupg-9d17a635c977a209bee78203e3cfb85a9cb09fc6.tar.gz gnupg-9d17a635c977a209bee78203e3cfb85a9cb09fc6.zip |
* gpg.sgml: Document -K.
* g10.c: Make -K an alias for --list-secret-keys.
* keylist.c (print_card_serialno): New. Taken from gnupg 1.9.11.
(list_keyblock_print): Make use of it.
* keyedit.c (show_key_with_all_names): Print the card S/N.
* keyedit.c (keyedit_menu): New command ADDCARDKEY.
* card-util.c (card_generate_subkey): New.
* keygen.c (generate_card_subkeypair): New.
(gen_card_key): New arg IS_PRIMARY; changed all callers.
* cardglue.c (open_card): Use shutdown code if possible.
(check_card_serialno): Ditto.
Diffstat (limited to 'g10/keylist.c')
-rw-r--r-- | g10/keylist.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/g10/keylist.c b/g10/keylist.c index ce66a1359..cb38026e6 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -41,6 +41,7 @@ static void list_all(int); static void list_one( STRLIST names, int secret); +static void print_card_serialno (PKT_secret_key *sk); struct sig_stats { @@ -752,6 +753,7 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque ) if( !any ) { if( fpr ) print_fingerprint( pk, sk, 0 ); + print_card_serialno (sk); if( opt.with_key_data ) print_key_data( pk ); any = 1; @@ -805,6 +807,7 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque ) putchar('\n'); if( fpr ) print_fingerprint( pk, sk, 0 ); /* of the main key */ + print_card_serialno (sk); any = 1; } @@ -817,7 +820,10 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque ) printf(_(" [expires: %s]"), expirestr_from_sk( sk2 ) ); putchar('\n'); if( fpr > 1 ) - print_fingerprint( NULL, sk2, 0 ); + { + print_fingerprint( NULL, sk2, 0 ); + print_card_serialno (sk2); + } } else if( opt.list_sigs && node->pkt->pkttype == PKT_SIGNATURE @@ -861,6 +867,7 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque ) putchar('\n'); if( fpr ) print_fingerprint( pk, sk, 0 ); + print_card_serialno (sk); any=1; } @@ -1475,6 +1482,41 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode ) tty_printf ("\n"); } +/* Print the serial number of an OpenPGP card if available. */ +static void +print_card_serialno (PKT_secret_key *sk) +{ + int i; + + if (!sk) + return; + if (!sk->is_protected || sk->protect.s2k.mode != 1002) + return; /* Not a card. */ + if (opt.with_colons) + return; /* Handled elesewhere. */ + + fputs (_(" Card serial no. ="), stdout); + putchar (' '); + if (sk->protect.ivlen == 16 + && !memcmp (sk->protect.iv, "\xD2\x76\x00\x01\x24\x01", 6) ) + { /* This is an OpenPGP card. Just print the relevant part. */ + for (i=8; i < 14; i++) + { + if (i == 10) + putchar (' '); + printf ("%02X", sk->protect.iv[i]); + } + } + else + { /* Something is wrong: Print all. */ + for (i=0; i < sk->protect.ivlen; i++) + printf ("%02X", sk->protect.iv[i]); + } + putchar ('\n'); +} + + + void set_attrib_fd(int fd) { static int last_fd=-1; |