[git] GPGME - branch, master, updated. gpgme-1.6.0-257-g6f3dc66

by Werner Koch cvs at cvs.gnupg.org
Thu Aug 4 16:20:13 CEST 2016


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 "GnuPG Made Easy".

The branch, master has been updated
       via  6f3dc66634e30d86aa6250c4ac22f9b8f7ec1be9 (commit)
      from  56e26b54da9f16961209275d7a61883d3ea898ca (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 6f3dc66634e30d86aa6250c4ac22f9b8f7ec1be9
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 4 16:17:01 2016 +0200

    core: Extend gpgme_subkey_t to carry the keygrip.
    
    * src/gpgme.h.in (struct _gpgme_subkey): Add file 'keygrip'.
    * src/key.c (gpgme_key_unref): Free KEYGRIP.
    * src/keylist.c (keylist_colon_handler): Parse GRP records.
    * src/engine-gpg.c (gpg_keylist_build_options): Do not use
    --with-fingerprint options for gpg versions >= 2.1.15.
    
    * tests/run-keylist.c (main): Print subkeys and keygrips.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/NEWS b/NEWS
index bb31a50..09d0a1c 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Noteworthy changes in version 1.7.0 (unreleased) [C25/A14/R_]
  GPGME_PK_EDDSA                 NEW.
  gpgme_set_ctx_flag             NEW.
  gpgme_signature_t              EXTENDED: New field tofu.
+ gpgme_subkey_t                 EXTENDED: New field keygrip.
  gpgme_tofu_policy_t            NEW.
  gpgme_tofu_info_t              NEW.
  GPGME_STATUS_KEY_CONSIDERED    NEW.
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index 16571a5..942711f 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -2283,12 +2283,19 @@ gpg_keylist_build_options (engine_gpg_t gpg, int secret_only,
   gpg_error_t err;
 
   err = add_arg (gpg, "--with-colons");
-  if (!err)
-    err = add_arg (gpg, "--fixed-list-mode");
-  if (!err)
-    err = add_arg (gpg, "--with-fingerprint");
-  if (!err)
-    err = add_arg (gpg, "--with-fingerprint");
+
+  /* Since gpg 2.1.15 fingerprints are always printed, thus there is
+   * no more need to explictly reqeust them.  */
+  if (!have_gpg_version (gpg, "2.1.15"))
+    {
+      if (!err)
+        err = add_arg (gpg, "--fixed-list-mode");
+      if (!err)
+        err = add_arg (gpg, "--with-fingerprint");
+      if (!err)
+        err = add_arg (gpg, "--with-fingerprint");
+    }
+
   if (!err && (mode & GPGME_KEYLIST_MODE_WITH_SECRET))
     err = add_arg (gpg, "--with-secret");
   if (!err
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 49d56c3..c05686d 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -691,6 +691,9 @@ struct _gpgme_subkey
 
   /* The name of the curve for ECC algorithms or NULL.  */
   char *curve;
+
+  /* The keygrip of the subkey in hex digit form or NULL if not availabale.  */
+  char *keygrip;
 };
 typedef struct _gpgme_subkey *gpgme_subkey_t;
 
diff --git a/src/key.c b/src/key.c
index 1a68966..de97102 100644
--- a/src/key.c
+++ b/src/key.c
@@ -333,6 +333,8 @@ gpgme_key_unref (gpgme_key_t key)
 	free (subkey->fpr);
       if (subkey->curve)
 	free (subkey->curve);
+      if (subkey->keygrip)
+	free (subkey->keygrip);
       if (subkey->card_number)
 	free (subkey->card_number);
       free (subkey);
diff --git a/src/keylist.c b/src/keylist.c
index fcf574f..5a346ea 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -426,7 +426,7 @@ keylist_colon_handler (void *priv, char *line)
   gpgme_ctx_t ctx = (gpgme_ctx_t) priv;
   enum
     {
-      RT_NONE, RT_SIG, RT_UID, RT_SUB, RT_PUB, RT_FPR,
+      RT_NONE, RT_SIG, RT_UID, RT_SUB, RT_PUB, RT_FPR, RT_GRP,
       RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK
     }
   rectype = RT_NONE;
@@ -479,6 +479,8 @@ keylist_colon_handler (void *priv, char *line)
     rectype = RT_CRS;
   else if (!strcmp (field[0], "fpr") && key)
     rectype = RT_FPR;
+  else if (!strcmp (field[0], "grp") && key)
+    rectype = RT_GRP;
   else if (!strcmp (field[0], "uid") && key)
     rectype = RT_UID;
   else if (!strcmp (field[0], "sub") && key)
@@ -717,6 +719,22 @@ keylist_colon_handler (void *priv, char *line)
 	}
       break;
 
+    case RT_GRP:
+      /* Field 10 has the keygrip.  */
+      if (fields >= 10 && field[9] && *field[9])
+	{
+          /* Need to apply it to the last subkey because all subkeys
+             have a keygrip. */
+          subkey = key->_last_subkey;
+          if (!subkey->keygrip)
+            {
+              subkey->keygrip = strdup (field[9]);
+              if (!subkey->keygrip)
+                return gpg_error_from_syserror ();
+            }
+	}
+      break;
+
     case RT_SIG:
     case RT_REV:
       if (!opd->tmp_uid)
diff --git a/tests/run-keylist.c b/tests/run-keylist.c
index 8abdf43..fc0f066 100644
--- a/tests/run-keylist.c
+++ b/tests/run-keylist.c
@@ -67,6 +67,7 @@ main (int argc, char **argv)
   gpgme_ctx_t ctx;
   gpgme_keylist_mode_t mode = 0;
   gpgme_key_t key;
+  gpgme_subkey_t subkey;
   gpgme_keylist_result_t result;
   int import = 0;
   gpgme_key_t keyarray[100];
@@ -173,22 +174,54 @@ main (int argc, char **argv)
     {
       gpgme_user_id_t uid;
       int nuids;
-
+      int nsub;
 
       printf ("keyid   : %s\n", key->subkeys?nonnull (key->subkeys->keyid):"?");
       printf ("fpr     : %s\n", key->subkeys?nonnull (key->subkeys->fpr):"?");
+      if (key->subkeys && key->subkeys->keygrip)
+        printf ("grip    : %s\n", key->subkeys->keygrip);
+      if (key->subkeys && key->subkeys->curve)
+            printf ("curve   : %s\n", key->subkeys->curve);
       printf ("caps    : %s%s%s%s\n",
               key->can_encrypt? "e":"",
               key->can_sign? "s":"",
               key->can_certify? "c":"",
               key->can_authenticate? "a":"");
-      printf ("flags   :%s%s%s%s%s%s\n",
+      printf ("flags   :%s%s%s%s%s%s%s\n",
               key->secret? " secret":"",
               key->revoked? " revoked":"",
               key->expired? " expired":"",
               key->disabled? " disabled":"",
               key->invalid? " invalid":"",
-              key->is_qualified? " qualifid":"");
+              key->is_qualified? " qualifid":"",
+              key->subkeys && key->subkeys->is_cardkey? " cardkey":"");
+
+      subkey = key->subkeys;
+      if (subkey)
+        subkey = subkey->next;
+      for (nsub=1; subkey; subkey = subkey->next, nsub++)
+        {
+          printf ("fpr   %2d: %s\n", nsub, nonnull (subkey->fpr));
+          if (subkey->keygrip)
+            printf ("grip  %2d: %s\n", nsub, subkey->keygrip);
+          if (subkey->curve)
+            printf ("curve %2d: %s\n", nsub, subkey->curve);
+          printf ("caps  %2d: %s%s%s%s\n",
+                  nsub,
+                  subkey->can_encrypt? "e":"",
+                  subkey->can_sign? "s":"",
+                  subkey->can_certify? "c":"",
+                  subkey->can_authenticate? "a":"");
+          printf ("flags %2d:%s%s%s%s%s%s%s\n",
+                  nsub,
+                  subkey->secret? " secret":"",
+                  subkey->revoked? " revoked":"",
+                  subkey->expired? " expired":"",
+                  subkey->disabled? " disabled":"",
+                  subkey->invalid? " invalid":"",
+                  subkey->is_qualified? " qualifid":"",
+                  subkey->is_cardkey? " cardkey":"");
+        }
       for (nuids=0, uid=key->uids; uid; uid = uid->next, nuids++)
         {
           printf ("userid %d: %s\n", nuids, nonnull(uid->uid));
@@ -201,6 +234,8 @@ main (int argc, char **argv)
                   uid->validity == GPGME_VALIDITY_ULTIMATE? "ultimate": "[?]");
         }
 
+
+
       putchar ('\n');
 
       if (import)

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

Summary of changes:
 NEWS                |  1 +
 src/engine-gpg.c    | 19 +++++++++++++------
 src/gpgme.h.in      |  3 +++
 src/key.c           |  2 ++
 src/keylist.c       | 20 +++++++++++++++++++-
 tests/run-keylist.c | 41 ++++++++++++++++++++++++++++++++++++++---
 6 files changed, 76 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list