[git] GnuPG - branch, master, updated. post-nuke-of-trailing-ws-29-g35205e1

by Werner Koch cvs at cvs.gnupg.org
Thu Mar 3 16:44:13 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  35205e13005248178da145944671f28f600be7be (commit)
      from  aeb324273afdb1999e2b3ea3471fe28856a6d3b1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 35205e13005248178da145944671f28f600be7be
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Mar 3 16:16:24 2011 +0100

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

diff --git a/g10/ChangeLog b/g10/ChangeLog
index df424a3..9026077 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,5 +1,9 @@
 2011-03-03  Werner Koch  <wk at 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.
 
 	* misc.c (pubkey_nbits): Replace GCRY_PK_ by PUBKEY_ALGO_.
diff --git a/g10/card-util.c b/g10/card-util.c
index 2b7ac74..0ffb18d 100644
--- a/g10/card-util.c
+++ b/g10/card-util.c
@@ -581,32 +581,34 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen)
       if ( thefpr && !fpr_is_ff (thefpr)
            && !get_pubkey_byfprint (pk, thefpr, 20))
         {
+          kbnode_t keyblock = NULL;
+
           print_pubkey_info (fp, pk);
 
 #if GNUPG_MAJOR_VERSION == 1
-          {
-            kbnode_t keyblock = NULL;
+          if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
+            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) )
-              print_card_key_info (fp, keyblock);
-            else if ( !get_keyblock_byfprint (&keyblock, thefpr, 20) )
-              {
-                release_kbnode (keyblock);
-                keyblock = NULL;
-
-                if (!auto_create_card_key_stub (info.serialno,
-                                                info.fpr1valid? info.fpr1:NULL,
-                                                info.fpr2valid? info.fpr2:NULL,
-                                                info.fpr3valid? info.fpr3:NULL))
-                  {
-                    if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
-                      print_card_key_info (fp, keyblock);
-                  }
-              }
+              if (!auto_create_card_key_stub (info.serialno,
+                                              info.fpr1valid? info.fpr1:NULL,
+                                              info.fpr2valid? info.fpr2:NULL,
+                                              info.fpr3valid? info.fpr3:NULL))
+                {
+                  if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
+                    print_card_key_info (fp, keyblock);
+                }
+            }
 
-            release_kbnode (keyblock);
-          }
-#endif /* GNUPG_MAJOR_VERSION == 1 */
+#else /* GNUPG_MAJOR_VERSION != 1 */
+          if (!get_keyblock_byfprint (&keyblock, thefpr, 20))
+            print_card_key_info (fp, keyblock);
+#endif /* GNUPG_MAJOR_VERSION != 1 */
+
+          release_kbnode (keyblock);
         }
       else
         tty_fprintf (fp, "[none]\n");
diff --git a/g10/keylist.c b/g10/keylist.c
index ba2a954..968aa95 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -180,50 +180,58 @@ print_pubkey_info (estream_t fp, PKT_public_key * pk)
 void
 print_card_key_info (estream_t fp, kbnode_t keyblock)
 {
-  /* KBNODE node; */
-  /* int i; */
-#warning Fixme: Needs to be adjusted to gpg-agent
-  /* for (node = keyblock; node; node = node->next) */
-  /*   { */
-  /*     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  ", */
-  /*       	       node->pkt->pkttype == PKT_SECRET_KEY ? "sec" : "ssb", */
-  /*       	       (sk->protect.s2k.mode == 1001) ? '#' : */
-  /*       	       (sk->protect.s2k.mode == 1002) ? '>' : ' ', */
-  /*       	       nbits_from_sk (sk), */
-  /*       	       pubkey_letter (sk->pubkey_algo), keystr_from_sk (sk)); */
-  /*         tty_fprintf (fp, _("created: %s"), datestr_from_sk (sk)); */
-  /*         tty_fprintf (fp, "  "); */
-  /*         tty_fprintf (fp, _("expires: %s"), expirestr_from_sk (sk)); */
-  /*         if (sk->is_protected && sk->protect.s2k.mode == 1002) */
-  /*           { */
-  /*             tty_fprintf (fp, "\n                      "); */
-  /*             tty_fprintf (fp, _("card-no: ")); */
-  /*             if (sk->protect.ivlen == 16 */
-  /*       	  && !memcmp (sk->protect.iv, "\xD2\x76\x00\x01\x24\x01", 6)) */
-  /*       	{ */
-  /*       	  /\* This is an OpenPGP card. *\/ */
-  /*       	  for (i = 8; i < 14; i++) */
-  /*       	    { */
-  /*       	      if (i == 10) */
-  /*       		tty_fprintf (fp, " "); */
-  /*       	      tty_fprintf (fp, "%02X", sk->protect.iv[i]); */
-  /*       	    } */
-  /*       	} */
-  /*             else */
-  /*       	{ */
-  /*                 /\* Something is wrong: Print all. *\/ */
-  /*       	  for (i = 0; i < sk->protect.ivlen; i++) */
-  /*       	    tty_fprintf (fp, "%02X", sk->protect.iv[i]); */
-  /*       	} */
-  /*           } */
-  /*         tty_fprintf (fp, "\n"); */
-  /*       } */
-  /*   } */
+  kbnode_t node;
+  char *hexgrip;
+  char *serialno;
+  int s2k_char;
+
+  for (node = keyblock; node; node = node->next)
+    {
+      if (node->pkt->pkttype == PKT_PUBLIC_KEY
+          || node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
+        {
+          int rc;
+          PKT_public_key *pk = node->pkt->pkt.public_key;
+
+          serialno = NULL;
+          rc = hexkeygrip_from_pk (pk, &hexgrip);
+          if (rc)
+            {
+              log_error ("error computing a keygrip: %s\n", gpg_strerror (rc));
+              s2k_char = '?';
+            }
+          else if (!agent_get_keyinfo (NULL, hexgrip, &serialno))
+            s2k_char = serialno? '>':' ';
+          else
+            s2k_char = '#';  /* Key not found.  */
+
+          tty_fprintf (fp, "%s%c  %4u%c/%s  ",
+                       node->pkt->pkttype == PKT_PUBLIC_KEY ? "sec" : "ssb",
+                       s2k_char, nbits_from_pk (pk),
+                       pubkey_letter (pk->pubkey_algo), keystr_from_pk (pk));
+          tty_fprintf (fp, _("created: %s"), datestr_from_pk (pk));
+          tty_fprintf (fp, "  ");
+          tty_fprintf (fp, _("expires: %s"), expirestr_from_pk (pk));
+          if (serialno)
+            {
+              tty_fprintf (fp, "\n                      ");
+              tty_fprintf (fp, _("card-no: "));
+              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*/
 

-----------------------------------------------------------------------

Summary of changes:
 g10/ChangeLog   |    4 ++
 g10/card-util.c |   48 ++++++++++++++-------------
 g10/keylist.c   |   96 +++++++++++++++++++++++++++++-------------------------
 3 files changed, 81 insertions(+), 67 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list