[git] GnuPG - branch, master, updated. gnupg-2.1.6-33-ga6e4053

by NIIBE Yutaka cvs at cvs.gnupg.org
Thu Aug 6 09:51: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  a6e40530898622fbc5d76557a7da5e69368ecaa4 (commit)
      from  d088d2c81690a89051349ddc8a82fe222625f4e0 (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 a6e40530898622fbc5d76557a7da5e69368ecaa4
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Thu Aug 6 16:44:03 2015 +0900

    common: extend API of openpgp_oid_to_curve for canonical name.
    
    * common/openpgp-oid.c (openpgp_oid_to_curve): Add CANON argument.
    * common/util.h: Update.
    * g10/import.c (transfer_secret_keys): Follow the change.
    * g10/keyid.c (pubkey_string): Likewise.
    * g10/keylist.c (list_keyblock_print, list_keyblock_colon): Likewise.
    * parse-packet.c (parse_key): Likewise.
    * scd/app-openpgp.c (send_key_attr, get_public_key): Likewise.
    
    --
    
    Change the function so that caller can select canonical name of curve
    or name for printing.  Suggested by wk.

diff --git a/common/openpgp-oid.c b/common/openpgp-oid.c
index 676079c..af91bb1 100644
--- a/common/openpgp-oid.c
+++ b/common/openpgp-oid.c
@@ -333,10 +333,10 @@ openpgp_curve_to_oid (const char *name, unsigned int *r_nbits)
 
 
 /* Map an OpenPGP OID to the Libgcrypt curve NAME.  Returns NULL for
-   unknown curve names.  We prefer an alias name here which is more
-   suitable for printing.  */
+   unknown curve names.  Unless CANON is set we prefer an alias name
+   here which is more suitable for printing.  */
 const char *
-openpgp_oid_to_curve (const char *oidstr)
+openpgp_oid_to_curve (const char *oidstr, int canon)
 {
   int i;
 
@@ -345,7 +345,7 @@ openpgp_oid_to_curve (const char *oidstr)
 
   for (i=0; oidtable[i].name; i++)
     if (!strcmp (oidtable[i].oidstr, oidstr))
-      return oidtable[i].alias? oidtable[i].alias : oidtable[i].name;
+      return !canon && oidtable[i].alias? oidtable[i].alias : oidtable[i].name;
 
   return NULL;
 }
diff --git a/common/util.h b/common/util.h
index 90acefa..df0f392 100644
--- a/common/util.h
+++ b/common/util.h
@@ -323,7 +323,7 @@ gpg_error_t openpgp_oid_from_str (const char *string, gcry_mpi_t *r_mpi);
 char *openpgp_oid_to_str (gcry_mpi_t a);
 int openpgp_oid_is_ed25519 (gcry_mpi_t a);
 const char *openpgp_curve_to_oid (const char *name, unsigned int *r_nbits);
-const char *openpgp_oid_to_curve (const char *oid);
+const char *openpgp_oid_to_curve (const char *oid, int canon);
 const char *openpgp_enum_curves (int *idxp);
 
 
diff --git a/g10/import.c b/g10/import.c
index 0a2ebcd..e92769d 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -1414,7 +1414,7 @@ transfer_secret_keys (ctrl_t ctrl, struct stats_s *stats, kbnode_t sec_keyblock,
             err = gpg_error_from_syserror ();
           else
             {
-              const char *curvename = openpgp_oid_to_curve (curvestr);
+              const char *curvename = openpgp_oid_to_curve (curvestr, 1);
               err = gcry_sexp_build (&curve, NULL, "(curve %s)",
                                      curvename?curvename:curvestr);
               xfree (curvestr);
diff --git a/g10/keyid.c b/g10/keyid.c
index 6b6f670..68990c8 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -119,7 +119,7 @@ pubkey_string (PKT_public_key *pk, char *buffer, size_t bufsize)
   else if (prefix)
     {
       char *curve = openpgp_oid_to_str (pk->pkey[0]);
-      const char *name = openpgp_oid_to_curve (curve);
+      const char *name = openpgp_oid_to_curve (curve, 0);
 
       if (name)
         snprintf (buffer, bufsize, "%s", name);
diff --git a/g10/keylist.c b/g10/keylist.c
index d81e7dd..b43165f 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -1091,7 +1091,7 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr,
               || pk2->pubkey_algo == PUBKEY_ALGO_ECDH)
             {
               char *curve = openpgp_oid_to_str (pk2->pkey[0]);
-              const char *name = openpgp_oid_to_curve (curve);
+              const char *name = openpgp_oid_to_curve (curve, 0);
               if (!name)
                 name = curve;
               es_fprintf (es_stdout, " %s", name);
@@ -1358,7 +1358,7 @@ list_keyblock_colon (KBNODE keyblock, int secret, int has_secret, int fpr)
       || pk->pubkey_algo == PUBKEY_ALGO_ECDH)
     {
       char *curve = openpgp_oid_to_str (pk->pkey[0]);
-      const char *name = openpgp_oid_to_curve (curve);
+      const char *name = openpgp_oid_to_curve (curve, 0);
       if (!name)
         name = curve;
       es_fputs (name, es_stdout);
@@ -1487,7 +1487,7 @@ list_keyblock_colon (KBNODE keyblock, int secret, int has_secret, int fpr)
               || pk->pubkey_algo == PUBKEY_ALGO_ECDH)
             {
               char *curve = openpgp_oid_to_str (pk->pkey[0]);
-              const char *name = openpgp_oid_to_curve (curve);
+              const char *name = openpgp_oid_to_curve (curve, 0);
               if (!name)
                 name = curve;
               es_fputs (name, es_stdout);
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 6131d32..478612a 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -2086,7 +2086,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
                    || algorithm == PUBKEY_ALGO_ECDH) && i==0)
                 {
                   char *curve = openpgp_oid_to_str (pk->pkey[0]);
-                  const char *name = openpgp_oid_to_curve (curve);
+                  const char *name = openpgp_oid_to_curve (curve, 0);
                   es_fprintf (listfp, " %s (%s)", name?name:"", curve);
                   xfree (curve);
                 }
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index cc95773..637f6b1 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -911,7 +911,7 @@ send_key_attr (ctrl_t ctrl, app_t app, const char *keyword, int keyno)
                 keyno+1,
                 app->app_local->keyattr[keyno].ecc.flags? PUBKEY_ALGO_EDDSA:
                 (keyno==1? PUBKEY_ALGO_ECDH: PUBKEY_ALGO_ECDSA),
-                openpgp_oid_to_curve (app->app_local->keyattr[keyno].ecc.oid));
+                openpgp_oid_to_curve (app->app_local->keyattr[keyno].ecc.oid, 0));
     }
   else
     snprintf (buffer, sizeof buffer, "%d 0 0 UNKNOWN", keyno+1);
@@ -1442,7 +1442,7 @@ get_public_key (app_t app, int keyno)
         format = "(public-key(ecc(curve%s)(flags eddsa)(q%b)))";
 
       err = gcry_sexp_build (&s_pkey, NULL, format,
-                 openpgp_oid_to_curve (app->app_local->keyattr[keyno].ecc.oid),
+                openpgp_oid_to_curve (app->app_local->keyattr[keyno].ecc.oid, 1),
                              (int)mlen, mbuf);
       if (err)
         goto leave;

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

Summary of changes:
 common/openpgp-oid.c | 8 ++++----
 common/util.h        | 2 +-
 g10/import.c         | 2 +-
 g10/keyid.c          | 2 +-
 g10/keylist.c        | 6 +++---
 g10/parse-packet.c   | 2 +-
 scd/app-openpgp.c    | 4 ++--
 7 files changed, 13 insertions(+), 13 deletions(-)


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




More information about the Gnupg-commits mailing list