mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* 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.
This commit is contained in:
parent
5576f6ef6c
commit
9d17a635c9
12 changed files with 356 additions and 14 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue