[git] GnuPG - branch, master, updated. gnupg-2.1.21-122-g165cdd8

by Werner Koch cvs at cvs.gnupg.org
Thu Jul 20 18:20:24 CEST 2017


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  165cdd8121bbf80bfe2da071539d3578630f198f (commit)
       via  bddc2e04f1ddc18be20efc0f0508be401b345f42 (commit)
       via  33ecb541fcc2e8030989384b5e8c55aeccd21128 (commit)
       via  3ee314dde16d1d69ddf840cdb8b5aa186c592262 (commit)
      from  9998b162b47931fb8a8ed961d53418d505358888 (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 165cdd8121bbf80bfe2da071539d3578630f198f
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jul 20 17:27:48 2017 +0200

    gpg: New option --with-key-origin.
    
    * g10/getkey.c (parse_key_origin): Factor list out as ...
    (key_origin_list): new struct.
    (key_origin_string): New.
    * g10/gpg.c (oWithKeyOrigin): New const.
    (opts): New option --with-key-origin.
    (main): Implement option.
    * g10/options.h (struct opt): New flag with_key_origin.
    * g10/keylist.c (list_keyblock_print): Print key origin info.
    (list_keyblock_colon): Ditto.

diff --git a/doc/DETAILS b/doc/DETAILS
index 28fb55a..0be55f4 100644
--- a/doc/DETAILS
+++ b/doc/DETAILS
@@ -241,8 +241,7 @@ described here.
 
     The origin of the key or the user ID.  This is an integer
     optionally followed by a space and an URL.  This goes along with
-    the previous field.  The values are not yet defined.
-
+    the previous field.  The URL is quoted in C style.
 
 ** Special fields
 
diff --git a/doc/gpg.texi b/doc/gpg.texi
index 64dd502..cae351b 100644
--- a/doc/gpg.texi
+++ b/doc/gpg.texi
@@ -2531,6 +2531,13 @@ Print the ICAO spelling of the fingerprint in addition to the hex digits.
 Include the keygrip in the key listings.  In @code{--with-colons} mode
 this is implicitly enable for secret keys.
 
+ at item --with-key-origin
+ at opindex with-key-origin
+Include the locally held information on the origin and last update of
+a key in a key listing.  In @code{--with-colons} mode this is always
+printed.  This data is currently experimental and shall not be
+considered part of the stable API.
+
 @item --with-wkd-hash
 @opindex with-wkd-hash
 Print a Web Key Directory identifier along with each user ID in key
diff --git a/g10/getkey.c b/g10/getkey.c
index 2bec984..484063e 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -4300,11 +4300,13 @@ parse_auto_key_locate (char *options)
 }
 
 
-/* Parse the argument for --key-origin.  Return false on error. */
-int
-parse_key_origin (char *string)
-{
-  struct { const char *name; int origin; } list[] = {
+

+/* The list of key origins. */
+static struct {
+  const char *name;
+  int origin;
+} key_origin_list[] =
+  {
     { "self",    KEYORG_SELF    },
     { "file",    KEYORG_FILE    },
     { "url",     KEYORG_URL     },
@@ -4314,27 +4316,45 @@ parse_key_origin (char *string)
     { "ks",      KEYORG_KS      },
     { "unknown", KEYORG_UNKNOWN }
   };
+
+/* Parse the argument for --key-origin.  Return false on error. */
+int
+parse_key_origin (char *string)
+{
   int i;
 
   if (!ascii_strcasecmp (string, "help"))
     {
       log_info (_("valid values for option '%s':\n"), "--key-origin");
-      for (i=0; i < DIM (list); i++)
-        log_info ("  %s\n", list[i].name);
+      for (i=0; i < DIM (key_origin_list); i++)
+        log_info ("  %s\n", key_origin_list[i].name);
       g10_exit (1);
     }
 
-  for (i=0; i < DIM (list); i++)
-    if (!ascii_strcasecmp (string, list[i].name))
+  for (i=0; i < DIM (key_origin_list); i++)
+    if (!ascii_strcasecmp (string, key_origin_list[i].name))
       {
-        opt.key_origin = list[i].origin;
+        opt.key_origin = key_origin_list[i].origin;
         return 1;
       }
 
   return 0;
 }
 
+/* Return a string or "?" for the key ORIGIN.  */
+const char *
+key_origin_string (int origin)
+{
+  int i;
 
+  for (i=0; i < DIM (key_origin_list); i++)
+    if (key_origin_list[i].origin == origin)
+      return key_origin_list[i].name;
+  return "?";
+}
+
+
+

 /* Returns true if a secret key is available for the public key with
    key id KEYID; returns false if not.  This function ignores legacy
    keys.  Note: this is just a fast check and does not tell us whether
diff --git a/g10/gpg.c b/g10/gpg.c
index 5c60e1d..70b8011 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -201,6 +201,7 @@ enum cmd_and_opt_values
     oWithWKDHash,
     oWithColons,
     oWithKeyData,
+    oWithKeyOrigin,
     oWithTofuInfo,
     oWithSigList,
     oWithSigCheck,
@@ -785,6 +786,7 @@ static ARGPARSE_OPTS opts[] = {
   ARGPARSE_s_n (oWithKeygrip,     "with-keygrip", "@"),
   ARGPARSE_s_n (oWithSecret,      "with-secret", "@"),
   ARGPARSE_s_n (oWithWKDHash,     "with-wkd-hash", "@"),
+  ARGPARSE_s_n (oWithKeyOrigin,   "with-key-origin", "@"),
   ARGPARSE_s_s (oDisableCipherAlgo,  "disable-cipher-algo", "@"),
   ARGPARSE_s_s (oDisablePubkeyAlgo,  "disable-pubkey-algo", "@"),
   ARGPARSE_s_n (oAllowNonSelfsignedUID,      "allow-non-selfsigned-uid", "@"),
@@ -2733,6 +2735,10 @@ main (int argc, char **argv)
             opt.with_wkd_hash = 1;
             break;
 
+	  case oWithKeyOrigin:
+            opt.with_key_origin = 1;
+            break;
+
 	  case oSecretKeyring:
             /* Ignore this old option.  */
             break;
diff --git a/g10/keydb.h b/g10/keydb.h
index 6416e63..15345bb 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -398,6 +398,7 @@ char *get_user_id_byfpr_native (ctrl_t ctrl, const byte *fpr);
 void release_akl(void);
 int parse_auto_key_locate(char *options);
 int parse_key_origin (char *string);
+const char *key_origin_string (int origin);
 
 /*-- keyid.c --*/
 int pubkey_letter( int algo );
diff --git a/g10/keylist.c b/g10/keylist.c
index e4d5d06..37a26dc 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -922,6 +922,21 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr,
   if (opt.with_key_data)
     print_key_data (pk);
 
+  if (opt.with_key_origin
+      && (pk->keyorg || pk->keyupdate || pk->updateurl))
+    {
+      char updatestr[MK_DATESTR_SIZE];
+
+      es_fprintf (es_stdout, "      origin=%s last=%s %s",
+                  key_origin_string (pk->keyorg),
+                  mk_datestr (updatestr, sizeof updatestr, pk->keyupdate),
+                  pk->updateurl? "url=":"");
+      if (pk->updateurl)
+        print_utf8_string (es_stdout, pk->updateurl);
+      es_putc ('\n', es_stdout);
+    }
+
+
   for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
     {
       if (node->pkt->pkttype == PKT_USER_ID)
@@ -987,6 +1002,22 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr,
               xfree (mbox);
             }
 
+          if (opt.with_key_origin
+              && (uid->keyorg || uid->keyupdate || uid->updateurl))
+            {
+              char updatestr[MK_DATESTR_SIZE];
+
+              es_fprintf (es_stdout, "   %*sorigin=%s last=%s %s",
+                          indent, "",
+                          key_origin_string (uid->keyorg),
+                          mk_datestr (updatestr, sizeof updatestr,
+                                      uid->keyupdate),
+                          pk->updateurl? "url=":"");
+              if (pk->updateurl)
+                print_utf8_string (es_stdout, pk->updateurl);
+              es_putc ('\n', es_stdout);
+            }
+
 	  if ((opt.list_options & LIST_SHOW_PHOTOS) && uid->attribs != NULL)
 	    show_photos (ctrl, uid->attribs, uid->numattribs, pk, uid);
 	}
@@ -1315,7 +1346,13 @@ list_keyblock_colon (ctrl_t ctrl, kbnode_t keyblock,
   es_putc (':', es_stdout);		/* End of field 17. */
   print_compliance_flags (pk, keylength, curvename);
   es_putc (':', es_stdout);		/* End of field 18 (compliance). */
+  if (pk->keyupdate)
+    es_fputs (colon_strtime (pk->keyupdate), es_stdout);
   es_putc (':', es_stdout);		/* End of field 19 (last_update). */
+  es_fprintf (es_stdout, "%d%s", pk->keyorg, pk->updateurl? " ":"");
+  if (pk->updateurl)
+    es_write_sanitized (es_stdout, pk->updateurl, strlen (pk->updateurl),
+                        ":", NULL);
   es_putc (':', es_stdout);		/* End of field 20 (origin). */
   es_putc ('\n', es_stdout);
 
@@ -1367,7 +1404,14 @@ list_keyblock_colon (ctrl_t ctrl, kbnode_t keyblock,
 	  else
 	    es_write_sanitized (es_stdout, uid->name, uid->len, ":", NULL);
 	  es_fputs (":::::::::", es_stdout);
+          if (uid->keyupdate)
+            es_fputs (colon_strtime (uid->keyupdate), es_stdout);
           es_putc (':', es_stdout);	/* End of field 19 (last_update). */
+          es_fprintf (es_stdout, "%d%s", uid->keyorg, uid->updateurl? " ":"");
+          if (uid->updateurl)
+            es_write_sanitized (es_stdout,
+                                uid->updateurl, strlen (uid->updateurl),
+                                ":", NULL);
           es_putc (':', es_stdout);	/* End of field 20 (origin). */
 	  es_putc ('\n', es_stdout);
 #ifdef USE_TOFU
diff --git a/g10/options.h b/g10/options.h
index 5bb506e..21249e9 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -85,6 +85,7 @@ struct
   int with_tofu_info;   /* Option --with-tofu_info active.  */
   int with_secret;      /* Option --with-secret active.  */
   int with_wkd_hash;    /* Option --with-wkd-hash.  */
+  int with_key_origin;  /* Option --with-key-origin.  */
   int fingerprint; /* list fingerprints */
   int list_sigs;   /* list signatures */
   int no_armor;

commit bddc2e04f1ddc18be20efc0f0508be401b345f42
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jul 20 17:20:17 2017 +0200

    common: New function print_utf9_string.
    
    * common/miscellaneous.c (print_utf8_string): New.
    --
    
    This is a simple convenience function.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/miscellaneous.c b/common/miscellaneous.c
index c9c603d..caeb66f 100644
--- a/common/miscellaneous.c
+++ b/common/miscellaneous.c
@@ -228,6 +228,16 @@ print_utf8_buffer (estream_t stream, const void *p, size_t n)
   do_print_utf8_buffer (stream, p, n, NULL, NULL);
 }
 
+
+void
+print_utf8_string (estream_t stream, const char *p)
+{
+  if (!p)
+    p = "";
+  do_print_utf8_buffer (stream, p, strlen (p), NULL, NULL);
+}
+
+
 /* Write LENGTH bytes of BUFFER to FP as a hex encoded string.
    RESERVED must be 0. */
 void
diff --git a/common/util.h b/common/util.h
index c0aa57a..5b712d3 100644
--- a/common/util.h
+++ b/common/util.h
@@ -302,6 +302,7 @@ void print_utf8_buffer3 (estream_t fp, const void *p, size_t n,
                          const char *delim);
 void print_utf8_buffer2 (estream_t fp, const void *p, size_t n, int delim);
 void print_utf8_buffer (estream_t fp, const void *p, size_t n);
+void print_utf8_string (estream_t stream, const char *p);
 void print_hexstring (FILE *fp, const void *buffer, size_t length,
                       int reserved);
 char *try_make_printable_string (const void *p, size_t n, int delim);

commit 33ecb541fcc2e8030989384b5e8c55aeccd21128
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jul 20 14:49:07 2017 +0200

    doc: Comment fixes and one trailing comma fix.
    
    --

diff --git a/doc/DETAILS b/doc/DETAILS
index cbeead7..28fb55a 100644
--- a/doc/DETAILS
+++ b/doc/DETAILS
@@ -1348,7 +1348,7 @@ CREATE TABLE signatures (
   - 1 octet :: Key Source; i.e. the origin of the key:
                - 0 :: Unknown source.
                - 1 :: Public keyserver.
-               - 2 :: Preferred keysrver.
+               - 2 :: Preferred keyserver.
                - 3 :: OpenPGP DANE.
                - 4 :: Web Key Directory.
                - 5 :: Import from a trusted URL.
@@ -1538,5 +1538,5 @@ Description of some debug flags:
    If one of the "foo/*" names are used a "keygen.flags" prompt needs
    to be answered as well.  Instead of toggling the predefined flags,
    it is also possible to set them direct: Use a "=" character
-   directly followed by a comination of "a" (for authentication), "s"
+   directly followed by a combination of "a" (for authentication), "s"
    (for signing), or "c" (for certification).
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 6d00fc5..d4a1d6a 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -182,8 +182,8 @@ build_packet (IOBUF out, PACKET *pkt)
 
 
 /* Build a packet and write it to the stream OUT.  This variant also
- * writes the meta data using ring tyrust packets.  Returns: 0 on
- * success or on aerror code.  */
+ * writes the meta data using ring trust packets.  Returns: 0 on
+ * success or on error code.  */
 gpg_error_t
 build_packet_and_meta (iobuf_t out, PACKET *pkt)
 {
diff --git a/g10/keydb.h b/g10/keydb.h
index 803987b..6416e63 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -126,7 +126,7 @@ enum
     KEYORG_WKD     = 4, /* Web Key Directory.   */
     KEYORG_URL     = 5, /* Trusted URL.         */
     KEYORG_FILE    = 6, /* Trusted file.        */
-    KEYORG_SELF    = 7, /* We generated it.     */
+    KEYORG_SELF    = 7  /* We generated it.     */
   };
 
 
diff --git a/g10/packet.h b/g10/packet.h
index 56ac503..8dca88b 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -485,8 +485,8 @@ typedef struct {
 
 /* Subtypes for the ring trust packet.  */
 #define RING_TRUST_SIG 0  /* The classical signature cache.  */
-#define RING_TRUST_KEY 1  /* A KEYSRC on a primary key.      */
-#define RING_TRUST_UID 2  /* A KEYSRC on a user id.          */
+#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
+#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
 
 /* The local only ring trust packet which OpenPGP declares as
  * implementation defined.  GnuPG uses this to cache signature
@@ -498,7 +498,7 @@ typedef struct {
   unsigned int trustval;
   unsigned int sigcache;
   unsigned char subtype; /* The subtype of this ring trust packet.   */
-  unsigned char keyorg;  /* The origin of the key (KEYSRC_*).        */
+  unsigned char keyorg;  /* The origin of the key (KEYORG_*).        */
   u32 keyupdate;         /* The wall time the key was last updated.  */
   char *url;             /* NULL or the URL of the source.           */
 } PKT_ring_trust;

commit 3ee314dde16d1d69ddf840cdb8b5aa186c592262
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jul 20 13:36:44 2017 +0200

    gpg: Make function mk_datestr public.
    
    * g10/keydb.h (MK_DATESTR_SIZE): New.
    * g10/keyid.c (mk_datestr): Make public.  Add arg bufsize and use
    snprintf.  Change arg atime to u32.
    (datestr_from_pk): Simplify.
    (datestr_from_sig): Ditto.
    (expirestr_from_pk): Ditto.
    (expirestr_from_sig): Ditto.
    (revokestr_from_pk): Ditto.
    --
    
    Note that this also reduces the size of the static buffers from 16 to
    11 which is sufficient for the string.  In the past we added the 5
    extra bytes to cope for bugs in gmtime which is now handles by
    snprintf.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/keydb.h b/g10/keydb.h
index bad3149..803987b 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -458,6 +458,13 @@ u32 keyid_from_fingerprint (ctrl_t ctrl, const byte *fprint, size_t fprint_len,
                             u32 *keyid);
 byte *namehash_from_uid(PKT_user_id *uid);
 unsigned nbits_from_pk( PKT_public_key *pk );
+
+/* Convert an UTC TIMESTAMP into an UTC yyyy-mm-dd string.  Return
+ * that string.  The caller should pass a buffer with at least a size
+ * of MK_DATESTR_SIZE.  */
+char *mk_datestr (char *buffer, size_t bufsize, u32 timestamp);
+#define MK_DATESTR_SIZE 11
+
 const char *datestr_from_pk( PKT_public_key *pk );
 const char *datestr_from_sig( PKT_signature *sig );
 const char *expirestr_from_pk( PKT_public_key *pk );
diff --git a/g10/keyid.c b/g10/keyid.c
index 24a5643..d733156 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -613,9 +613,13 @@ nbits_from_pk (PKT_public_key *pk)
 }
 
 
-static const char *
-mk_datestr (char *buffer, time_t atime)
+/* Convert an UTC TIMESTAMP into an UTC yyyy-mm-dd string.  Return
+ * that string.  The caller should pass a buffer with at least a size
+ * of MK_DATESTR_SIZE.  */
+char *
+mk_datestr (char *buffer, size_t bufsize, u32 timestamp)
 {
+  time_t atime = timestamp;
   struct tm *tp;
 
   if (IS_INVALID_TIME_T (atime))
@@ -623,8 +627,8 @@ mk_datestr (char *buffer, time_t atime)
   else
     {
       tp = gmtime (&atime);
-      sprintf (buffer,"%04d-%02d-%02d",
-               1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday );
+      snprintf (buffer, bufsize, "%04d-%02d-%02d",
+                1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday );
     }
   return buffer;
 }
@@ -638,59 +642,51 @@ mk_datestr (char *buffer, time_t atime)
 const char *
 datestr_from_pk (PKT_public_key *pk)
 {
-  static char buffer[11+5];
-  time_t atime = pk->timestamp;
+  static char buffer[MK_DATESTR_SIZE];
 
-  return mk_datestr (buffer, atime);
+  return mk_datestr (buffer, sizeof buffer, pk->timestamp);
 }
 
 
 const char *
 datestr_from_sig (PKT_signature *sig )
 {
-  static char buffer[11+5];
-  time_t atime = sig->timestamp;
+  static char buffer[MK_DATESTR_SIZE];
 
-  return mk_datestr (buffer, atime);
+  return mk_datestr (buffer, sizeof buffer, sig->timestamp);
 }
 
 
 const char *
 expirestr_from_pk (PKT_public_key *pk)
 {
-  static char buffer[11+5];
-  time_t atime;
+  static char buffer[MK_DATESTR_SIZE];
 
   if (!pk->expiredate)
     return _("never     ");
-  atime = pk->expiredate;
-  return mk_datestr (buffer, atime);
+  return mk_datestr (buffer, sizeof buffer, pk->expiredate);
 }
 
 
 const char *
 expirestr_from_sig (PKT_signature *sig)
 {
-  static char buffer[11+5];
-  time_t atime;
+  static char buffer[MK_DATESTR_SIZE];
 
   if (!sig->expiredate)
     return _("never     ");
-  atime=sig->expiredate;
-  return mk_datestr (buffer, atime);
+  return mk_datestr (buffer, sizeof buffer, sig->expiredate);
 }
 
 
 const char *
 revokestr_from_pk( PKT_public_key *pk )
 {
-  static char buffer[11+5];
-  time_t atime;
+  static char buffer[MK_DATESTR_SIZE];
 
   if(!pk->revoked.date)
     return _("never     ");
-  atime=pk->revoked.date;
-  return mk_datestr (buffer, atime);
+  return mk_datestr (buffer, sizeof buffer, pk->revoked.date);
 }
 
 

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

Summary of changes:
 common/miscellaneous.c | 10 ++++++++++
 common/util.h          |  1 +
 doc/DETAILS            |  7 +++----
 doc/gpg.texi           |  7 +++++++
 g10/build-packet.c     |  4 ++--
 g10/getkey.c           | 40 ++++++++++++++++++++++++++++++----------
 g10/gpg.c              |  6 ++++++
 g10/keydb.h            | 10 +++++++++-
 g10/keyid.c            | 40 ++++++++++++++++++----------------------
 g10/keylist.c          | 44 ++++++++++++++++++++++++++++++++++++++++++++
 g10/options.h          |  1 +
 g10/packet.h           |  6 +++---
 12 files changed, 134 insertions(+), 42 deletions(-)


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




More information about the Gnupg-commits mailing list