[git] GnuPG - branch, master, updated. gnupg-2.1.8-81-gd7b8e76

by Werner Koch cvs at cvs.gnupg.org
Thu Oct 8 15:44:48 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  d7b8e76f9930750d669405dee3108c9bc8e87b91 (commit)
       via  a2600e42f91aa7187f3d6ac74cfb5e4c22ed4a58 (commit)
       via  b6d621583fc9cbda6f9376a24f2f4cf11499a4fd (commit)
       via  a400958323d93036dca9c63135b167012ea64f8b (commit)
      from  9ac31f91b10059474da1c9580fb99e94278d4c11 (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 d7b8e76f9930750d669405dee3108c9bc8e87b91
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Oct 8 15:04:45 2015 +0200

    gpg: Add option --print-dane-records.
    
    * g10/options.h (opt): Add field "print_dane_records".
    * g10/gpg.c (oPrintDANERecords): new.
    (opts): Add --print-dane-records.
    (main): Set that option.
    * g10/export.c (do_export): Remove EXPORT_DANE_FORMAT handling.
    (do_export_stream): Add EXPORT_DANE_FORMAT handling.
    * g10/keylist.c (list_keyblock_pka): Implement DANE record printing.
    
    * g10/gpgv.c (export_pubkey_buffer): New stub.
    * g10/test-stubs.c (export_pubkey_buffer): New stub.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/doc/gpg.texi b/doc/gpg.texi
index 980d326..35291a8 100644
--- a/doc/gpg.texi
+++ b/doc/gpg.texi
@@ -2039,6 +2039,13 @@ Modify the output of the list commands to print PKA records suitable
 to put into DNS zone files.  An ORIGIN line is printed before each
 record to allow diverting the records to the corresponding zone file.
 
+ at item --print-dane-records
+ at opindex print-dane-records
+Modify the output of the list commands to print OpenPGP DANE records
+suitable to put into DNS zone files.  An ORIGIN line is printed before
+each record to allow diverting the records to the corresponding zone
+file.
+
 @item --fixed-list-mode
 @opindex fixed-list-mode
 Do not merge primary user ID and primary key in @option{--with-colon}
diff --git a/g10/export.c b/g10/export.c
index 94a3256..2e9e61c 100644
--- a/g10/export.c
+++ b/g10/export.c
@@ -198,15 +198,11 @@ do_export (ctrl_t ctrl, strlist_t users, int secret, unsigned int options )
   if (rc)
     return rc;
 
-  /* We don't want an Armor for DANE format.  */
-  if (!(options & EXPORT_DANE_FORMAT))
+  if ( opt.armor )
     {
-      if ( opt.armor )
-        {
-          afx = new_armor_context ();
-          afx->what = secret? 5 : 1;
-          push_armor_filter (afx, out);
-        }
+      afx = new_armor_context ();
+      afx->what = secret? 5 : 1;
+      push_armor_filter (afx, out);
     }
 
   rc = do_export_stream (ctrl, out, users, secret, NULL, options, &any );
@@ -776,6 +772,11 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
   init_packet (&pkt);
   kdbhd = keydb_new ();
 
+  /* For the DANE format override the options.  */
+  if ((options & EXPORT_DANE_FORMAT))
+    options = (EXPORT_DANE_FORMAT | EXPORT_MINIMAL | EXPORT_CLEAN);
+
+
   if (!users)
     {
       ndesc = 1;
diff --git a/g10/gpg.c b/g10/gpg.c
index 557eeec..39cc2e5 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -384,6 +384,7 @@ enum cmd_and_opt_values
     oFakedSystemTime,
     oNoAutostart,
     oPrintPKARecords,
+    oPrintDANERecords,
 
     oNoop
   };
@@ -716,6 +717,7 @@ static ARGPARSE_OPTS opts[] = {
   ARGPARSE_s_n (oLegacyListMode, "legacy-list-mode", "@"),
   ARGPARSE_s_n (oListOnly, "list-only", "@"),
   ARGPARSE_s_n (oPrintPKARecords, "print-pka-records", "@"),
+  ARGPARSE_s_n (oPrintDANERecords, "print-dane-records", "@"),
   ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict", "@"),
   ARGPARSE_s_n (oIgnoreValidFrom,    "ignore-valid-from", "@"),
   ARGPARSE_s_n (oIgnoreCrcError, "ignore-crc-error", "@"),
@@ -2998,6 +3000,7 @@ main (int argc, char **argv)
 	  case oFixedListMode: /* Dummy */ break;
           case oLegacyListMode: opt.legacy_list_mode = 1; break;
 	  case oPrintPKARecords: opt.print_pka_records = 1; break;
+	  case oPrintDANERecords: opt.print_dane_records = 1; break;
 	  case oListOnly: opt.list_only=1; break;
 	  case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break;
 	  case oIgnoreValidFrom: opt.ignore_valid_from = 1; break;
diff --git a/g10/gpgv.c b/g10/gpgv.c
index 412f4be..8bb3fc4 100644
--- a/g10/gpgv.c
+++ b/g10/gpgv.c
@@ -592,3 +592,17 @@ gpg_dirmngr_get_pka (ctrl_t ctrl, const char *userid,
     *r_url = NULL;
   return gpg_error (GPG_ERR_NOT_FOUND);
 }
+
+gpg_error_t
+export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options,
+                      kbnode_t *r_keyblock, void **r_data, size_t *r_datalen)
+{
+  (void)ctrl;
+  (void)keyspec;
+  (void)options;
+
+  *r_keyblock = NULL;
+  *r_data = NULL;
+  *r_datalen = 0;
+  return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
+}
diff --git a/g10/keylist.c b/g10/keylist.c
index 192ced7..3814f1c 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -847,6 +847,9 @@ list_keyblock_pka (ctrl_t ctrl, kbnode_t keyblock)
   PKT_public_key *pk;
   char pkstrbuf[PUBKEY_STRING_SIZE];
   char *hexfpr;
+  char *hexkeyblock = NULL;
+  unsigned int hexkeyblocklen;
+  const char *s;
 
   /* Get the keyid from the keyblock.  */
   node = find_kbnode (keyblock, PKT_PUBLIC_KEY);
@@ -859,11 +862,55 @@ list_keyblock_pka (ctrl_t ctrl, kbnode_t keyblock)
 
   pk = node->pkt->pkt.public_key;
 
-  es_fprintf (es_stdout, ";; pub  %s/%s %s\n;; ",
+  /* First print an overview of the key with all userids.  */
+  es_fprintf (es_stdout, ";; pub  %s/%s %s\n;;",
               pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
               keystr_from_pk (pk), datestr_from_pk (pk));
   print_fingerprint (NULL, pk, 10);
+  for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
+    {
+      if (node->pkt->pkttype == PKT_USER_ID)
+	{
+	  PKT_user_id *uid = node->pkt->pkt.user_id;
+
+	  if (pk && (uid->is_expired || uid->is_revoked)
+	      && !(opt.list_options & LIST_SHOW_UNUSABLE_UIDS))
+            continue;
+
+          es_fputs (";; uid  ", es_stdout);
+          print_utf8_buffer (es_stdout, uid->name, uid->len);
+          es_putc ('\n', es_stdout);
+        }
+    }
+
+
   hexfpr = hexfingerprint (pk);
+  if (opt.print_dane_records)
+    {
+      kbnode_t dummy_keyblock;
+      void *data;
+      size_t datalen;
+      gpg_error_t err;
+
+      /* We do not have an export fucntion which allows to pass a
+         keyblock, thus we need to search the key again.  */
+      err = export_pubkey_buffer (ctrl, hexfpr,
+                                  EXPORT_DANE_FORMAT,
+                                  &dummy_keyblock, &data, &datalen);
+      release_kbnode (dummy_keyblock);
+      if (!err)
+        {
+          hexkeyblocklen = datalen;
+          hexkeyblock = bin2hex (data, datalen, NULL);
+          if (!hexkeyblock)
+            err = gpg_error_from_syserror ();
+          xfree (data);
+          ascii_strlwr (hexkeyblock);
+        }
+      if (err)
+        log_error (_("skipped \"%s\": %s\n"), hexfpr, gpg_strerror (err));
+
+    }
 
   for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
     {
@@ -877,27 +924,57 @@ list_keyblock_pka (ctrl_t ctrl, kbnode_t keyblock)
 	      && !(opt.list_options & LIST_SHOW_UNUSABLE_UIDS))
             continue;
 
-          es_fputs (";; uid  ", es_stdout);
-          print_utf8_buffer (es_stdout, uid->name, uid->len);
-	  es_putc ('\n', es_stdout);
           mbox = mailbox_from_userid (uid->name);
           if (mbox && (p = strchr (mbox, '@')))
             {
-              char hashbuf[20];
+              char hashbuf[32];
               char *hash;
               unsigned int len;
 
               *p++ = 0;
-              es_fprintf (es_stdout, "$ORIGIN _pka.%s.\n", p);
-              gcry_md_hash_buffer (GCRY_MD_SHA1, hashbuf, mbox, strlen (mbox));
-              hash = zb32_encode (hashbuf, 8*20);
-              if (hash)
+              if (opt.print_pka_records)
                 {
-                  len = strlen (hexfpr)/2;
-                  es_fprintf (es_stdout,
-                              "%s TYPE37 \\# %u 0006 0000 00 %02X %s\n",
-                              hash, 6 + len, len, hexfpr);
-                  xfree (hash);
+                  es_fprintf (es_stdout, "$ORIGIN _pka.%s.\n; %s\n; ",
+                              p, hexfpr);
+                  print_utf8_buffer (es_stdout, uid->name, uid->len);
+                  es_putc ('\n', es_stdout);
+                  gcry_md_hash_buffer (GCRY_MD_SHA1, hashbuf,
+                                       mbox, strlen (mbox));
+                  hash = zb32_encode (hashbuf, 8*20);
+                  if (hash)
+                    {
+                      len = strlen (hexfpr)/2;
+                      es_fprintf (es_stdout,
+                                  "%s TYPE37 \\# %u 0006 0000 00 %02X %s\n",
+                                  hash, 6 + len, len, hexfpr);
+                      xfree (hash);
+                    }
+                }
+              if (opt.print_dane_records && hexkeyblock)
+                {
+                  es_fprintf (es_stdout, "$ORIGIN _openpgpkey.%s.\n; %s\n; ",
+                              p, hexfpr);
+                  print_utf8_buffer (es_stdout, uid->name, uid->len);
+                  es_putc ('\n', es_stdout);
+                  gcry_md_hash_buffer (GCRY_MD_SHA256, hashbuf,
+                                       mbox, strlen (mbox));
+                  hash = bin2hex (hashbuf, 28, NULL);
+                  if (hash)
+                    {
+                      ascii_strlwr (hash);
+                      es_fprintf (es_stdout, "%s TYPE61 \\# %u (\n",
+                                  hash, hexkeyblocklen);
+                      xfree (hash);
+                      s = hexkeyblock;
+                      for (;;)
+                        {
+                          es_fprintf (es_stdout, "\t%.64s\n", s);
+                          if (strlen (s) < 64)
+                            break;
+                          s += 64;
+                        }
+                      es_fputs ("\t)\n", es_stdout);
+                    }
                 }
             }
           xfree (mbox);
@@ -906,6 +983,7 @@ list_keyblock_pka (ctrl_t ctrl, kbnode_t keyblock)
     }
   es_putc ('\n', es_stdout);
 
+  xfree (hexkeyblock);
   xfree (hexfpr);
 }
 
@@ -1679,7 +1757,7 @@ list_keyblock (ctrl_t ctrl,
                struct keylist_context *listctx)
 {
   reorder_keyblock (keyblock);
-  if (opt.print_pka_records)
+  if (opt.print_pka_records || opt.print_dane_records)
     list_keyblock_pka (ctrl, keyblock);
   else if (opt.with_colons)
     list_keyblock_colon (keyblock, secret, has_secret, fpr);
diff --git a/g10/options.h b/g10/options.h
index 694c29f..d57ab5d 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -74,6 +74,7 @@ struct
   int fingerprint; /* list fingerprints */
   int list_sigs;   /* list signatures */
   int print_pka_records;
+  int print_dane_records;
   int no_armor;
   int list_packets; /* list-packets mode: 1=normal, 2=invoked by command*/
   int def_cipher_algo;
diff --git a/g10/test-stubs.c b/g10/test-stubs.c
index c6f6d68..f3155fd 100644
--- a/g10/test-stubs.c
+++ b/g10/test-stubs.c
@@ -411,3 +411,17 @@ gpg_dirmngr_get_pka (ctrl_t ctrl, const char *userid,
     *r_url = NULL;
   return gpg_error (GPG_ERR_NOT_FOUND);
 }
+
+gpg_error_t
+export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options,
+                      kbnode_t *r_keyblock, void **r_data, size_t *r_datalen)
+{
+  (void)ctrl;
+  (void)keyspec;
+  (void)options;
+
+  *r_keyblock = NULL;
+  *r_data = NULL;
+  *r_datalen = 0;
+  return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
+}

commit a2600e42f91aa7187f3d6ac74cfb5e4c22ed4a58
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Oct 8 14:58:26 2015 +0200

    Fix two unused/possible-uninitialized var warnings.
    
    --

diff --git a/common/mkdir_p.c b/common/mkdir_p.c
index 6a54600..53c3f0f 100644
--- a/common/mkdir_p.c
+++ b/common/mkdir_p.c
@@ -36,7 +36,7 @@ amkdir_p (char **directory_components)
   int count;
   char **dirs;
   int i;
-  int rc;
+  int rc = 0;
 
   for (count = 0; directory_components[count]; count ++)
     ;
diff --git a/g10/keyedit.c b/g10/keyedit.c
index 143c748..4803f9e 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -293,7 +293,6 @@ print_and_check_one_sig (KBNODE keyblock, KBNODE node,
         {
           PKT_public_key *pk = keyblock->pkt->pkt.public_key;
           const unsigned char *s;
-          u32 expire;
 
           s = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PRIMARY_UID, NULL);
           if (s && *s)

commit b6d621583fc9cbda6f9376a24f2f4cf11499a4fd
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Oct 8 14:55:07 2015 +0200

    gpg: Pass CTRL parameter to all key listing functions.
    
    * g10/keylist.c (public_key_list): Add arg CTRL.
    (secret_key_list): Ditto.
    (list_all, list_one): Ditto.
    (locate_one): Ditto.
    (list_keyblock_pka): Ditto.
    (list_keyblock): Ditto.
    (list_keyblock_direct): Ditto.
    * g10/keygen.c (proc_parameter_file): Add arg CTRL.
    (read_parameter_file): Ditto.
    (quick_generate_keypair): Ditto.
    (do_generate_keypair): Ditto.
    (generate_keypair): Pass arg CTRL.
    * g10/gpg.c (main): Pass arg CTRL to quick_generate_keypair.
    --
    
    This will help use to implement the --server mode.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/gpg.c b/g10/gpg.c
index 9454b53..557eeec 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -3949,7 +3949,7 @@ main (int argc, char **argv)
         if (argc != 1 )
           wrong_args("--gen-key user-id");
         username = make_username (fname);
-        quick_generate_keypair (username);
+        quick_generate_keypair (ctrl, username);
         xfree (username);
         break;
 
diff --git a/g10/keygen.c b/g10/keygen.c
index dd37559..85bbe13 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -135,7 +135,7 @@ static byte zip_prefs[MAX_PREFS];
 static int nzip_prefs;
 static int mdc_available,ks_modify;
 
-static void do_generate_keypair( struct para_data_s *para,
+static void do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
 				 struct output_control_s *outctrl, int card );
 static int write_keyblock (iobuf_t out, kbnode_t node);
 static gpg_error_t gen_card_key (int algo, int keyno, int is_primary,
@@ -3036,7 +3036,7 @@ get_parameter_revkey( struct para_data_s *para, enum para_name key )
 }
 
 static int
-proc_parameter_file( struct para_data_s *para, const char *fname,
+proc_parameter_file (ctrl_t ctrl, struct para_data_s *para, const char *fname,
                      struct output_control_s *outctrl, int card )
 {
   struct para_data_s *r;
@@ -3222,7 +3222,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
       append_to_parameter (para, r);
     }
 
-  do_generate_keypair( para, outctrl, card );
+  do_generate_keypair (ctrl, para, outctrl, card );
   return 0;
 }
 
@@ -3233,7 +3233,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
  * Note, that string parameters are expected to be in UTF-8
  */
 static void
-read_parameter_file( const char *fname )
+read_parameter_file (ctrl_t ctrl, const char *fname )
 {
     static struct { const char *name;
 		    enum para_name key;
@@ -3328,7 +3328,7 @@ read_parameter_file( const char *fname )
                 outctrl.keygen_flags |= KEYGEN_FLAG_TRANSIENT_KEY;
 	    else if( !ascii_strcasecmp( keyword, "%commit" ) ) {
 		outctrl.lnr = lnr;
-		if (proc_parameter_file( para, fname, &outctrl, 0 ))
+		if (proc_parameter_file (ctrl, para, fname, &outctrl, 0 ))
                   print_status_key_not_created
                     (get_parameter_value (para, pHANDLE));
 		release_parameter_list( para );
@@ -3384,7 +3384,7 @@ read_parameter_file( const char *fname )
 
 	if( keywords[i].key == pKEYTYPE && para ) {
 	    outctrl.lnr = lnr;
-	    if (proc_parameter_file( para, fname, &outctrl, 0 ))
+	    if (proc_parameter_file (ctrl, para, fname, &outctrl, 0 ))
               print_status_key_not_created
                 (get_parameter_value (para, pHANDLE));
 	    release_parameter_list( para );
@@ -3414,7 +3414,7 @@ read_parameter_file( const char *fname )
     }
     else if( para ) {
 	outctrl.lnr = lnr;
-	if (proc_parameter_file( para, fname, &outctrl, 0 ))
+	if (proc_parameter_file (ctrl, para, fname, &outctrl, 0 ))
           print_status_key_not_created (get_parameter_value (para, pHANDLE));
     }
 
@@ -3479,7 +3479,7 @@ quickgen_set_para (struct para_data_s *para, int for_subkey,
  * Unattended generation of a standard key.
  */
 void
-quick_generate_keypair (const char *uid)
+quick_generate_keypair (ctrl_t ctrl, const char *uid)
 {
   gpg_error_t err;
   struct para_data_s *para = NULL;
@@ -3569,7 +3569,7 @@ quick_generate_keypair (const char *uid)
       para = r;
     }
 
-  proc_parameter_file (para, "[internal]", &outctrl, 0);
+  proc_parameter_file (ctrl, para, "[internal]", &outctrl, 0);
  leave:
   release_parameter_list (para);
 }
@@ -3613,7 +3613,7 @@ generate_keypair (ctrl_t ctrl, int full, const char *fname,
 
   if (opt.batch)
     {
-      read_parameter_file( fname );
+      read_parameter_file (ctrl, fname);
       return;
     }
 
@@ -3841,7 +3841,7 @@ generate_keypair (ctrl_t ctrl, int full, const char *fname,
   r->next = para;
   para = r;
 
-  proc_parameter_file (para, "[internal]", &outctrl, !!card_serialno);
+  proc_parameter_file (ctrl, para, "[internal]", &outctrl, !!card_serialno);
   release_parameter_list (para);
 }
 
@@ -3958,7 +3958,7 @@ start_tree(KBNODE *tree)
 
 
 static void
-do_generate_keypair (struct para_data_s *para,
+do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
 		     struct output_control_s *outctrl, int card)
 {
   gpg_error_t err;
@@ -4192,7 +4192,7 @@ do_generate_keypair (struct para_data_s *para,
             {
               tty_printf (_("public and secret key created and signed.\n") );
               tty_printf ("\n");
-              list_keyblock_direct (pub_root, 0, 1, 1);
+              list_keyblock_direct (ctrl, pub_root, 0, 1, 1);
             }
 
 
diff --git a/g10/keylist.c b/g10/keylist.c
index bfc6d49..192ced7 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -45,8 +45,9 @@
 #include "mbox-util.h"
 
 
-static void list_all (int, int);
-static void list_one (strlist_t names, int secret, int mark_secret);
+static void list_all (ctrl_t, int, int);
+static void list_one (ctrl_t ctrl,
+                      strlist_t names, int secret, int mark_secret);
 static void locate_one (ctrl_t ctrl, strlist_t names);
 static void print_card_serialno (const char *serialno);
 
@@ -60,7 +61,8 @@ struct keylist_context
 };
 
 
-static void list_keyblock (kbnode_t keyblock, int secret, int has_secret,
+static void list_keyblock (ctrl_t ctrl,
+                           kbnode_t keyblock, int secret, int has_secret,
                            int fpr, struct keylist_context *listctx);
 
 
@@ -131,9 +133,9 @@ public_key_list (ctrl_t ctrl, strlist_t list, int locate_mode)
   if (locate_mode)
     locate_one (ctrl, list);
   else if (!list)
-    list_all (0, opt.with_secret);
+    list_all (ctrl, 0, opt.with_secret);
   else
-    list_one (list, 0, opt.with_secret);
+    list_one (ctrl, list, 0, opt.with_secret);
 }
 
 
@@ -145,9 +147,9 @@ secret_key_list (ctrl_t ctrl, strlist_t list)
   check_trustdb_stale ();
 
   if (!list)
-    list_all (1, 0);
+    list_all (ctrl, 1, 0);
   else				/* List by user id */
-    list_one (list, 1, 0);
+    list_one (ctrl, list, 1, 0);
 }
 
 void
@@ -466,7 +468,7 @@ print_signature_stats (struct keylist_context *s)
    MARK_SECRET is true secret keys are indicated in a public key
    listing.  */
 static void
-list_all (int secret, int mark_secret)
+list_all (ctrl_t ctrl, int secret, int mark_secret)
 {
   KEYDB_HANDLE hd;
   KBNODE keyblock = NULL;
@@ -527,7 +529,7 @@ list_all (int secret, int mark_secret)
                 }
             }
           merge_keys_and_selfsig (keyblock);
-          list_keyblock (keyblock, secret, any_secret, opt.fingerprint,
+          list_keyblock (ctrl, keyblock, secret, any_secret, opt.fingerprint,
                          &listctx);
         }
       release_kbnode (keyblock);
@@ -552,7 +554,7 @@ list_all (int secret, int mark_secret)
 
 
 static void
-list_one (strlist_t names, int secret, int mark_secret)
+list_one (ctrl_t ctrl, strlist_t names, int secret, int mark_secret)
 {
   int rc = 0;
   KBNODE keyblock = NULL;
@@ -593,7 +595,8 @@ list_one (strlist_t names, int secret, int mark_secret)
             es_putc ('-', es_stdout);
           es_putc ('\n', es_stdout);
         }
-      list_keyblock (keyblock, secret, mark_secret, opt.fingerprint, &listctx);
+      list_keyblock (ctrl,
+                     keyblock, secret, mark_secret, opt.fingerprint, &listctx);
       release_kbnode (keyblock);
     }
   while (!getkey_next (ctx, NULL, &keyblock));
@@ -634,7 +637,7 @@ locate_one (ctrl_t ctrl, strlist_t names)
 	{
 	  do
 	    {
-	      list_keyblock (keyblock, 0, 0, opt.fingerprint, &listctx);
+	      list_keyblock (ctrl, keyblock, 0, 0, opt.fingerprint, &listctx);
 	      release_kbnode (keyblock);
 	    }
 	  while (ctx && !getkey_next (ctx, NULL, &keyblock));
@@ -837,7 +840,7 @@ dump_attribs (const PKT_user_id *uid, PKT_public_key *pk)
 
 /* Print IPGP cert records instead of a standard key listing.  */
 static void
-list_keyblock_pka (kbnode_t keyblock)
+list_keyblock_pka (ctrl_t ctrl, kbnode_t keyblock)
 {
   kbnode_t kbctx;
   kbnode_t node;
@@ -1671,12 +1674,13 @@ reorder_keyblock (KBNODE keyblock)
 }
 
 static void
-list_keyblock (KBNODE keyblock, int secret, int has_secret, int fpr,
+list_keyblock (ctrl_t ctrl,
+               KBNODE keyblock, int secret, int has_secret, int fpr,
                struct keylist_context *listctx)
 {
   reorder_keyblock (keyblock);
   if (opt.print_pka_records)
-    list_keyblock_pka (keyblock);
+    list_keyblock_pka (ctrl, keyblock);
   else if (opt.with_colons)
     list_keyblock_colon (keyblock, secret, has_secret, fpr);
   else
@@ -1688,12 +1692,13 @@ list_keyblock (KBNODE keyblock, int secret, int has_secret, int fpr,
 
 /* Public function used by keygen to list a keyblock.  */
 void
-list_keyblock_direct (kbnode_t keyblock, int secret, int has_secret, int fpr)
+list_keyblock_direct (ctrl_t ctrl,
+                      kbnode_t keyblock, int secret, int has_secret, int fpr)
 {
   struct keylist_context listctx;
 
   memset (&listctx, 0, sizeof (listctx));
-  list_keyblock (keyblock, secret, has_secret, fpr, &listctx);
+  list_keyblock (ctrl, keyblock, secret, has_secret, fpr, &listctx);
   keylist_context_release (&listctx);
 }
 
diff --git a/g10/main.h b/g10/main.h
index 42d5ce1..0bace61 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -256,7 +256,7 @@ void show_basic_key_info (KBNODE keyblock);
 u32 parse_expire_string(const char *string);
 u32 ask_expire_interval(int object,const char *def_expire);
 u32 ask_expiredate(void);
-void quick_generate_keypair (const char *uid);
+void quick_generate_keypair (ctrl_t ctrl, const char *uid);
 void generate_keypair (ctrl_t ctrl, int full, const char *fname,
                        const char *card_serialno, int card_backup_key);
 int keygen_set_std_prefs (const char *string,int personal);
@@ -347,8 +347,8 @@ void public_key_list (ctrl_t ctrl, strlist_t list, int locate_mode );
 void secret_key_list (ctrl_t ctrl, strlist_t list );
 void print_subpackets_colon(PKT_signature *sig);
 void reorder_keyblock (KBNODE keyblock);
-void list_keyblock_direct (kbnode_t keyblock, int secret, int has_secret,
-                           int fpr);
+void list_keyblock_direct (ctrl_t ctrl, kbnode_t keyblock, int secret,
+                           int has_secret, int fpr);
 void print_fingerprint (estream_t fp, PKT_public_key *pk, int mode);
 void print_revokers (estream_t fp, PKT_public_key *pk);
 void show_policy_url(PKT_signature *sig,int indent,int mode);

commit a400958323d93036dca9c63135b167012ea64f8b
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Oct 7 16:55:15 2015 +0200

    gpg: Remove unfinished experimental code to export as S-expressions.
    
    * g10/options.h (EXPORT_SEXP_FORMAT): Remove.
    (EXPORT_DANE_FORMAT): New.
    * g10/export.c (parse_export_options): Remove "export-sexp-format".
    (export_seckeys): Adjust for removed option.
    (export_secsubkeys): Ditto.
    (do_export): Prepare for DANE format.
    (build_sexp, build_sexp_seckey): Remove.
    (do_export_stream): Remove use of removed functions.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/export.c b/g10/export.c
index 62802d3..94a3256 100644
--- a/g10/export.c
+++ b/g10/export.c
@@ -1,7 +1,7 @@
 /* export.c - Export keys in the OpenPGP defined format.
  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
  *               2005, 2010 Free Software Foundation, Inc.
- * Copyright (C) 2014  Werner Koch
+ * Copyright (C) 1998-2015  Werner Koch
  *
  * This file is part of GnuPG.
  *
@@ -52,7 +52,6 @@ static int do_export_stream (ctrl_t ctrl, iobuf_t out,
                              strlist_t users, int secret,
                              kbnode_t *keyblock_out, unsigned int options,
 			     int *any);
-static int build_sexp (iobuf_t out, PACKET *pkt, int *indent);
 
 
 int
@@ -70,8 +69,6 @@ parse_export_options(char *str,unsigned int *options,int noisy)
        N_("remove unusable parts from key during export")},
       {"export-minimal",EXPORT_MINIMAL|EXPORT_CLEAN,NULL,
        N_("remove as much as possible from key during export")},
-      {"export-sexp-format",EXPORT_SEXP_FORMAT, NULL,
-       N_("export keys in an S-expression based format")},
       /* Aliases for backward compatibility */
       {"include-local-sigs",EXPORT_LOCAL_SIGS,NULL,NULL},
       {"include-attributes",EXPORT_ATTRIBUTES,NULL,NULL},
@@ -172,17 +169,13 @@ export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options,
 int
 export_seckeys (ctrl_t ctrl, strlist_t users )
 {
-  /* Use only relevant options for the secret key. */
-  unsigned int options = (opt.export_options & EXPORT_SEXP_FORMAT);
-  return do_export (ctrl, users, 1, options);
+  return do_export (ctrl, users, 1, 0);
 }
 
 int
 export_secsubkeys (ctrl_t ctrl, strlist_t users )
 {
-  /* Use only relevant options for the secret key. */
-  unsigned int options = (opt.export_options & EXPORT_SEXP_FORMAT);
-  return do_export (ctrl, users, 2, options);
+  return do_export (ctrl, users, 2, 0);
 }
 
 
@@ -205,7 +198,8 @@ do_export (ctrl_t ctrl, strlist_t users, int secret, unsigned int options )
   if (rc)
     return rc;
 
-  if (!(options & EXPORT_SEXP_FORMAT))
+  /* We don't want an Armor for DANE format.  */
+  if (!(options & EXPORT_DANE_FORMAT))
     {
       if ( opt.armor )
         {
@@ -760,7 +754,7 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk)
    export options to apply.  If KEYBLOCK_OUT is not NULL, AND the exit
    code is zero, a pointer to the first keyblock found and exported
    will be stored at this address; no other keyblocks are exported in
-   this case.  The caller must free it the returned keyblock.  If any
+   this case.  The caller must free the returned keyblock.  If any
    key has been exported true is stored at ANY. */
 static int
 do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
@@ -775,7 +769,6 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
   subkey_list_t subkey_list = NULL;  /* Track already processed subkeys. */
   KEYDB_HANDLE kdbhd;
   strlist_t sl;
-  int indent = 0;
   gcry_cipher_hd_t cipherhd = NULL;
   char *cache_nonce = NULL;
 
@@ -1114,10 +1107,7 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
                         ski->iv[ski->ivlen] = xtoi_2 (s);
                     }
 
-                  if ((options&EXPORT_SEXP_FORMAT))
-                    err = build_sexp (out, node->pkt, &indent);
-                  else
-                    err = build_packet (out, node->pkt);
+                  err = build_packet (out, node->pkt);
                 }
               else if (!err)
                 {
@@ -1172,10 +1162,7 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
                   if (err)
                     goto unwraperror;
 
-                  if ((options&EXPORT_SEXP_FORMAT))
-                    err = build_sexp (out, node->pkt, &indent);
-                  else
-                    err = build_packet (out, node->pkt);
+                  err = build_packet (out, node->pkt);
                   goto unwraperror_leave;
 
                 unwraperror:
@@ -1212,10 +1199,7 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
             }
           else
             {
-              if ((options&EXPORT_SEXP_FORMAT))
-                err = build_sexp (out, node->pkt, &indent);
-              else
-                err = build_packet (out, node->pkt);
+              err = build_packet (out, node->pkt);
             }
 
           if (err)
@@ -1229,25 +1213,12 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
             *any = 1;
 	}
 
-      if ((options&EXPORT_SEXP_FORMAT) && indent)
-        {
-          for (; indent; indent--)
-            iobuf_put (out, ')');
-          iobuf_put (out, '\n');
-        }
-
       if (keyblock_out)
         {
           *keyblock_out = keyblock;
           break;
         }
     }
-  if ((options&EXPORT_SEXP_FORMAT) && indent)
-    {
-      for (; indent; indent--)
-        iobuf_put (out, ')');
-      iobuf_put (out, '\n');
-    }
   if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
     err = 0;
 
@@ -1263,139 +1234,3 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
     log_info(_("WARNING: nothing exported\n"));
   return err;
 }
-
-
-
-/* static int */
-/* write_sexp_line (iobuf_t out, int *indent, const char *text) */
-/* { */
-/*   int i; */
-
-/*   for (i=0; i < *indent; i++) */
-/*     iobuf_put (out, ' '); */
-/*   iobuf_writestr (out, text); */
-/*   return 0; */
-/* } */
-
-/* static int */
-/* write_sexp_keyparm (iobuf_t out, int *indent, const char *name, gcry_mpi_t a) */
-/* { */
-/*   int rc; */
-/*   unsigned char *buffer; */
-
-/*   write_sexp_line (out, indent, "("); */
-/*   iobuf_writestr (out, name); */
-/*   iobuf_writestr (out, " #"); */
-
-/*   rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, &buffer, NULL, a); */
-/*   assert (!rc); */
-/*   iobuf_writestr (out, buffer); */
-/*   iobuf_writestr (out, "#)"); */
-/*   gcry_free (buffer); */
-/*   return 0; */
-/* } */
-
-static int
-build_sexp_seckey (iobuf_t out, PACKET *pkt, int *indent)
-{
-  (void)out;
-  (void)pkt;
-  (void)indent;
-
-  /* FIXME: Not yet implemented.  */
-  return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
-  /* PKT_secret_key *sk = pkt->pkt.secret_key; */
-  /* char tmpbuf[100]; */
-
-  /* if (pkt->pkttype == PKT_SECRET_KEY) */
-  /*   { */
-  /*     iobuf_writestr (out, "(openpgp-key\n"); */
-  /*     (*indent)++; */
-  /*   } */
-  /* else */
-  /*   { */
-  /*     iobuf_writestr (out, " (subkey\n"); */
-  /*     (*indent)++; */
-  /*   } */
-  /* (*indent)++; */
-  /* write_sexp_line (out, indent, "(private-key\n"); */
-  /* (*indent)++; */
-  /* if (is_RSA (sk->pubkey_algo) && !sk->is_protected) */
-  /*   { */
-  /*     write_sexp_line (out, indent, "(rsa\n"); */
-  /*     (*indent)++; */
-  /*     write_sexp_keyparm (out, indent, "n", sk->skey[0]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "e", sk->skey[1]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "d", sk->skey[2]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "p", sk->skey[3]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "q", sk->skey[4]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "u", sk->skey[5]);  */
-  /*     iobuf_put (out,')'); iobuf_put (out,'\n'); */
-  /*     (*indent)--; */
-  /*   } */
-  /* else if (sk->pubkey_algo == PUBKEY_ALGO_DSA && !sk->is_protected) */
-  /*   { */
-  /*     write_sexp_line (out, indent, "(dsa\n"); */
-  /*     (*indent)++; */
-  /*     write_sexp_keyparm (out, indent, "p", sk->skey[0]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "q", sk->skey[1]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "g", sk->skey[2]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "y", sk->skey[3]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "x", sk->skey[4]); */
-  /*     iobuf_put (out,')'); iobuf_put (out,'\n'); */
-  /*     (*indent)--; */
-  /*   } */
-  /* else if (sk->pubkey_algo == PUBKEY_ALGO_ECDSA && !sk->is_protected) */
-  /*   { */
-  /*     write_sexp_line (out, indent, "(ecdsa\n"); */
-  /*     (*indent)++;  */
-  /*     write_sexp_keyparm (out, indent, "c", sk->skey[0]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "q", sk->skey[6]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "d", sk->skey[7]); */
-  /*     iobuf_put (out,')'); iobuf_put (out,'\n'); */
-  /*     (*indent)--; */
-  /*   } */
-  /* else if (is_ELGAMAL (sk->pubkey_algo) && !sk->is_protected) */
-  /*   { */
-  /*     write_sexp_line (out, indent, "(elg\n"); */
-  /*     (*indent)++; */
-  /*     write_sexp_keyparm (out, indent, "p", sk->skey[0]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "g", sk->skey[2]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "y", sk->skey[3]); iobuf_put (out,'\n'); */
-  /*     write_sexp_keyparm (out, indent, "x", sk->skey[4]); */
-  /*     iobuf_put (out,')'); iobuf_put (out,'\n'); */
-  /*     (*indent)--; */
-  /*   } */
-  /* write_sexp_line (out, indent,  "(attrib\n"); (*indent)++; */
-  /* sprintf (tmpbuf, "(created \"%lu\"", (unsigned long)sk->timestamp); */
-  /* write_sexp_line (out, indent, tmpbuf); */
-  /* iobuf_put (out,')'); (*indent)--; /\* close created *\/ */
-  /* iobuf_put (out,')'); (*indent)--; /\* close attrib *\/ */
-  /* iobuf_put (out,')'); (*indent)--; /\* close private-key *\/ */
-  /* if (pkt->pkttype != PKT_SECRET_KEY) */
-  /*   iobuf_put (out,')'), (*indent)--; /\* close subkey *\/ */
-  /* iobuf_put (out,'\n'); */
-
-  /* return 0; */
-}
-
-
-/* For some packet types we write them in a S-expression format.  This
-   is still EXPERIMENTAL and subject to change.  */
-static int
-build_sexp (iobuf_t out, PACKET *pkt, int *indent)
-{
-  int rc;
-
-  switch (pkt->pkttype)
-    {
-    case PKT_SECRET_KEY:
-    case PKT_SECRET_SUBKEY:
-      rc = build_sexp_seckey (out, pkt, indent);
-      break;
-    default:
-      rc = 0;
-      break;
-    }
-  return rc;
-}
diff --git a/g10/options.h b/g10/options.h
index f5b23dd..694c29f 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -334,7 +334,7 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
 #define EXPORT_RESET_SUBKEY_PASSWD       (1<<3)
 #define EXPORT_MINIMAL                   (1<<4)
 #define EXPORT_CLEAN                     (1<<5)
-#define EXPORT_SEXP_FORMAT               (1<<6)
+#define EXPORT_DANE_FORMAT               (1<<6)
 
 #define LIST_SHOW_PHOTOS                 (1<<0)
 #define LIST_SHOW_POLICY_URLS            (1<<1)

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

Summary of changes:
 common/mkdir_p.c |   2 +-
 doc/gpg.texi     |   7 ++
 g10/export.c     | 196 +++++--------------------------------------------------
 g10/gpg.c        |   5 +-
 g10/gpgv.c       |  14 ++++
 g10/keyedit.c    |   1 -
 g10/keygen.c     |  26 ++++----
 g10/keylist.c    | 147 ++++++++++++++++++++++++++++++++---------
 g10/main.h       |   6 +-
 g10/options.h    |   3 +-
 g10/test-stubs.c |  14 ++++
 11 files changed, 189 insertions(+), 232 deletions(-)


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




More information about the Gnupg-commits mailing list