[git] GnuPG - branch, master, updated. gnupg-2.1.6-36-gfbb6c25

by Werner Koch cvs at cvs.gnupg.org
Thu Aug 6 18:02:46 CEST 2015


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  fbb6c25ab5dbb5f2b1f1eb342ca7caa3f955d8c9 (commit)
      from  969542c8c2f48a60c1d68b7bf70b0c00374bacba (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 fbb6c25ab5dbb5f2b1f1eb342ca7caa3f955d8c9
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 6 18:00:12 2015 +0200

    gpg: Add commands "fpr *" and "grip" to --edit-key.
    
    * g10/keyedit.c (cmdGRIP): New.
    (cmds): Add command "grip".
    (keyedit_menu) <cmdFPR>: Print subkeys with argument "*".
    (keyedit_menu) <cmdGRIP>: Print keygrip.
    (show_key_and_fingerprint): Add arg "with_subkeys".
    (show_key_and_grip): New.
    * g10/keylist.c (print_fingerprint): Add mode 4.
    --
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/keyedit.c b/g10/keyedit.c
index 6238b30..d8dba2d 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -56,7 +56,8 @@ static void show_key_with_all_names (ctrl_t ctrl, estream_t fp,
 				     int with_revoker, int with_fpr,
 				     int with_subkeys, int with_prefs,
                                      int nowarn);
-static void show_key_and_fingerprint (KBNODE keyblock);
+static void show_key_and_fingerprint (kbnode_t keyblock, int with_subkeys);
+static void show_key_and_grip (kbnode_t keyblock);
 static void subkey_expire_warning (kbnode_t keyblock);
 static int menu_adduid (KBNODE keyblock, int photo, const char *photo_name,
                         const char *uidstr);
@@ -1305,7 +1306,7 @@ enum cmdids
   cmdSHOWPREF,
   cmdSETPREF, cmdPREFKS, cmdNOTATION, cmdINVCMD, cmdSHOWPHOTO, cmdUPDTRUST,
   cmdCHKTRUST, cmdADDCARDKEY, cmdKEYTOCARD, cmdBKUPTOCARD, cmdCHECKBKUPKEY,
-  cmdCLEAN, cmdMINIMIZE, cmdNOP
+  cmdCLEAN, cmdMINIMIZE, cmdGRIP, cmdNOP
 };
 
 static struct
@@ -1322,6 +1323,7 @@ static struct
   { "help", cmdHELP, 0, N_("show this help")},
   { "?", cmdHELP, 0, NULL},
   { "fpr", cmdFPR, 0, N_("show key fingerprint")},
+  { "grip", cmdGRIP, 0, N_("show the keygrip")},
   { "list", cmdLIST, 0, N_("list key and user IDs")},
   { "l", cmdLIST, 0, NULL},
   { "uid", cmdSELUID, 0, N_("select user ID N")},
@@ -1644,7 +1646,13 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
 	  break;
 
 	case cmdFPR:
-	  show_key_and_fingerprint (keyblock);
+	  show_key_and_fingerprint
+            (keyblock, (*arg_string == '*'
+                        && (!arg_string[1] || spacep (arg_string + 1))));
+	  break;
+
+	case cmdGRIP:
+	  show_key_and_grip (keyblock);
 	  break;
 
 	case cmdSELUID:
@@ -3235,10 +3243,11 @@ show_basic_key_info (KBNODE keyblock)
     }
 }
 
+
 static void
-show_key_and_fingerprint (KBNODE keyblock)
+show_key_and_fingerprint (kbnode_t keyblock, int with_subkeys)
 {
-  KBNODE node;
+  kbnode_t node;
   PKT_public_key *pk = NULL;
   char pkstrbuf[PUBKEY_STRING_SIZE];
 
@@ -3262,6 +3271,56 @@ show_key_and_fingerprint (KBNODE keyblock)
   tty_printf ("\n");
   if (pk)
     print_fingerprint (NULL, pk, 2);
+  if (with_subkeys)
+    {
+      for (node = keyblock; node; node = node->next)
+        {
+          if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
+            {
+              pk = node->pkt->pkt.public_key;
+              tty_printf ("sub   %s/%s %s [%s]\n",
+                          pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
+                          keystr_from_pk(pk),
+                          datestr_from_pk (pk),
+                          usagestr_from_pk (pk, 0));
+
+              print_fingerprint (NULL, pk, 4);
+            }
+        }
+    }
+}
+
+
+/* Show a listing of the primary and its subkeys along with their
+   keygrips.  */
+static void
+show_key_and_grip (kbnode_t keyblock)
+{
+  kbnode_t node;
+  PKT_public_key *pk = NULL;
+  char pkstrbuf[PUBKEY_STRING_SIZE];
+  char *hexgrip;
+
+  for (node = keyblock; node; node = node->next)
+    {
+      if (node->pkt->pkttype == PKT_PUBLIC_KEY
+          || node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
+        {
+          pk = node->pkt->pkt.public_key;
+          tty_printf ("%s   %s/%s %s [%s]\n",
+                      node->pkt->pkttype == PKT_PUBLIC_KEY? "pub":"sub",
+                      pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
+                      keystr_from_pk(pk),
+                      datestr_from_pk (pk),
+                      usagestr_from_pk (pk, 0));
+
+          if (!hexkeygrip_from_pk (pk, &hexgrip))
+            {
+              tty_printf ("      Keygrip: %s\n", hexgrip);
+              xfree (hexgrip);
+            }
+        }
+    }
 }
 
 
diff --git a/g10/keylist.c b/g10/keylist.c
index 0f4c85a..4ea4bf5 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -1726,6 +1726,7 @@ print_icao_hexdigit (estream_t fp, int c)
  *      1: print using log_info ()
  *      2: direct use of tty
  *      3: direct use of tty but only primary key.
+ *      4: direct use of tty but only subkey.
  *     10: Same as 0 but with_colons etc is ignored.
  *
  * Modes 1 and 2 will try and print both subkey and primary key
@@ -1784,7 +1785,7 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
     {
       fp = override_fp; /* Use tty or given stream.  */
       if (primary)
-	/* TRANSLATORS: this should fit into 24 bytes to that the
+	/* TRANSLATORS: this should fit into 24 bytes so that the
 	 * fingerprint data is properly aligned with the user ID */
 	text = _(" Primary key fingerprint:");
       else
@@ -1795,6 +1796,11 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
       fp = override_fp; /* Use tty or given stream.  */
       text = _("      Key fingerprint =");
     }
+  else if (mode == 4)
+    {
+      fp = override_fp; /* Use tty or given stream.  */
+      text = _("      Subkey fingerprint:");
+    }
   else
     {
       fp = override_fp? override_fp : es_stdout;

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

Summary of changes:
 g10/keyedit.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 g10/keylist.c |  8 ++++++-
 2 files changed, 71 insertions(+), 6 deletions(-)


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




More information about the Gnupg-commits mailing list