1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-01 16:33:02 +01:00

Print the secret keyinfo stuff with --card-status again.

This commit is contained in:
Werner Koch 2011-03-03 16:16:24 +01:00
parent aeb324273a
commit 35205e1300
3 changed files with 77 additions and 63 deletions

View File

@ -1,5 +1,9 @@
2011-03-03 Werner Koch <wk@g10code.com> 2011-03-03 Werner Koch <wk@g10code.com>
* keylist.c (print_card_key_info): Re-implement using the agent.
* card-util.c (card_status) [GNUPG_MAJOR_VERSION!=1]: Call
print_card_key_info.
* keyid.c (hash_public_key): Remove shadowing NBITS. * keyid.c (hash_public_key): Remove shadowing NBITS.
* misc.c (pubkey_nbits): Replace GCRY_PK_ by PUBKEY_ALGO_. * misc.c (pubkey_nbits): Replace GCRY_PK_ by PUBKEY_ALGO_.

View File

@ -581,32 +581,34 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen)
if ( thefpr && !fpr_is_ff (thefpr) if ( thefpr && !fpr_is_ff (thefpr)
&& !get_pubkey_byfprint (pk, thefpr, 20)) && !get_pubkey_byfprint (pk, thefpr, 20))
{ {
kbnode_t keyblock = NULL;
print_pubkey_info (fp, pk); print_pubkey_info (fp, pk);
#if GNUPG_MAJOR_VERSION == 1 #if GNUPG_MAJOR_VERSION == 1
{ if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
kbnode_t keyblock = NULL; print_card_key_info (fp, keyblock);
else if ( !get_keyblock_byfprint (&keyblock, thefpr, 20) )
{
release_kbnode (keyblock);
keyblock = NULL;
if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) ) if (!auto_create_card_key_stub (info.serialno,
print_card_key_info (fp, keyblock); info.fpr1valid? info.fpr1:NULL,
else if ( !get_keyblock_byfprint (&keyblock, thefpr, 20) ) info.fpr2valid? info.fpr2:NULL,
{ info.fpr3valid? info.fpr3:NULL))
release_kbnode (keyblock); {
keyblock = NULL; if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
print_card_key_info (fp, keyblock);
}
}
if (!auto_create_card_key_stub (info.serialno, #else /* GNUPG_MAJOR_VERSION != 1 */
info.fpr1valid? info.fpr1:NULL, if (!get_keyblock_byfprint (&keyblock, thefpr, 20))
info.fpr2valid? info.fpr2:NULL, print_card_key_info (fp, keyblock);
info.fpr3valid? info.fpr3:NULL)) #endif /* GNUPG_MAJOR_VERSION != 1 */
{
if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
print_card_key_info (fp, keyblock);
}
}
release_kbnode (keyblock); release_kbnode (keyblock);
}
#endif /* GNUPG_MAJOR_VERSION == 1 */
} }
else else
tty_fprintf (fp, "[none]\n"); tty_fprintf (fp, "[none]\n");

View File

@ -180,50 +180,58 @@ print_pubkey_info (estream_t fp, PKT_public_key * pk)
void void
print_card_key_info (estream_t fp, kbnode_t keyblock) print_card_key_info (estream_t fp, kbnode_t keyblock)
{ {
/* KBNODE node; */ kbnode_t node;
/* int i; */ char *hexgrip;
#warning Fixme: Needs to be adjusted to gpg-agent char *serialno;
/* for (node = keyblock; node; node = node->next) */ int s2k_char;
/* { */
/* if (node->pkt->pkttype == PKT_SECRET_KEY */
/* || (node->pkt->pkttype == PKT_SECRET_SUBKEY)) */
/* { */
/* PKT_public_key *pk = node->pkt->pkt.public_key; */
/* tty_fprintf (fp, "%s%c %4u%c/%s ", */ for (node = keyblock; node; node = node->next)
/* node->pkt->pkttype == PKT_SECRET_KEY ? "sec" : "ssb", */ {
/* (sk->protect.s2k.mode == 1001) ? '#' : */ if (node->pkt->pkttype == PKT_PUBLIC_KEY
/* (sk->protect.s2k.mode == 1002) ? '>' : ' ', */ || node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
/* nbits_from_sk (sk), */ {
/* pubkey_letter (sk->pubkey_algo), keystr_from_sk (sk)); */ int rc;
/* tty_fprintf (fp, _("created: %s"), datestr_from_sk (sk)); */ PKT_public_key *pk = node->pkt->pkt.public_key;
/* tty_fprintf (fp, " "); */
/* tty_fprintf (fp, _("expires: %s"), expirestr_from_sk (sk)); */ serialno = NULL;
/* if (sk->is_protected && sk->protect.s2k.mode == 1002) */ rc = hexkeygrip_from_pk (pk, &hexgrip);
/* { */ if (rc)
/* tty_fprintf (fp, "\n "); */ {
/* tty_fprintf (fp, _("card-no: ")); */ log_error ("error computing a keygrip: %s\n", gpg_strerror (rc));
/* if (sk->protect.ivlen == 16 */ s2k_char = '?';
/* && !memcmp (sk->protect.iv, "\xD2\x76\x00\x01\x24\x01", 6)) */ }
/* { */ else if (!agent_get_keyinfo (NULL, hexgrip, &serialno))
/* /\* This is an OpenPGP card. *\/ */ s2k_char = serialno? '>':' ';
/* for (i = 8; i < 14; i++) */ else
/* { */ s2k_char = '#'; /* Key not found. */
/* if (i == 10) */
/* tty_fprintf (fp, " "); */ tty_fprintf (fp, "%s%c %4u%c/%s ",
/* tty_fprintf (fp, "%02X", sk->protect.iv[i]); */ node->pkt->pkttype == PKT_PUBLIC_KEY ? "sec" : "ssb",
/* } */ s2k_char, nbits_from_pk (pk),
/* } */ pubkey_letter (pk->pubkey_algo), keystr_from_pk (pk));
/* else */ tty_fprintf (fp, _("created: %s"), datestr_from_pk (pk));
/* { */ tty_fprintf (fp, " ");
/* /\* Something is wrong: Print all. *\/ */ tty_fprintf (fp, _("expires: %s"), expirestr_from_pk (pk));
/* for (i = 0; i < sk->protect.ivlen; i++) */ if (serialno)
/* tty_fprintf (fp, "%02X", sk->protect.iv[i]); */ {
/* } */ tty_fprintf (fp, "\n ");
/* } */ tty_fprintf (fp, _("card-no: "));
/* tty_fprintf (fp, "\n"); */ if (strlen (serialno) == 32
/* } */ && !strncmp (serialno, "D27600012401", 12))
/* } */ {
/* This is an OpenPGP card. Print the relevant part. */
/* Example: D2760001240101010001000003470000 */
/* xxxxyyyyyyyy */
tty_fprintf (fp, "%.*s %.*s", 4, serialno+16, 8, serialno+20);
}
else
tty_fprintf (fp, "%s", serialno);
}
tty_fprintf (fp, "\n");
xfree (hexgrip);
xfree (serialno);
}
}
} }
#endif /*ENABLE_CARD_SUPPORT*/ #endif /*ENABLE_CARD_SUPPORT*/