[git] GPGME - branch, master, updated. gpgme-1.6.0-329-g120b147

by Werner Koch cvs at cvs.gnupg.org
Wed Sep 7 09:29:39 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  120b14783c0312d782dc08ce4949a6209d5ccc7b (commit)
      from  151da95470f174dc770b2111890ad650a1697276 (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 120b14783c0312d782dc08ce4949a6209d5ccc7b
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Sep 7 09:26:11 2016 +0200

    core,cpp: Extend the TOFU information.
    
    * src/gpgme.h.in (struct _gpeme_tofu_info): Rename FIRSTSEEN to
    SIGNFIRST and LASTSEEN to SIGNLAST.  Add ENCRFIST and ENCRLAST.
    * src/keylist.c (parse_tfs_record): Parse to ENCRFIRST and ENCRLAST.
    * src/verify.c (parse_tofu_stats): Ditto.
    * tests/run-keylist.c (main): Adjust and print encrypt stats.
    * tests/run-verify.c (print_result): Ditto.
    
    * lang/cpp/src/tofuinfo.h (TofuInfo): Rename firstSeen to signFirst
    and lastSeen to signLast.  Add encrCount, encrFirst and encrLast.
    * lang/cpp/src/tofuinfo.cpp (encrCount, encrFirst, encrLast): New.
    --
    
    The latest GnuPG commits have the needed changes but we also allow the
    use of currently released GnuPG version.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/lang/cpp/src/tofuinfo.cpp b/lang/cpp/src/tofuinfo.cpp
index ade262b..bb67fc8 100644
--- a/lang/cpp/src/tofuinfo.cpp
+++ b/lang/cpp/src/tofuinfo.cpp
@@ -123,14 +123,29 @@ unsigned short GpgME::TofuInfo::signCount() const
     return isNull() ? 0 : d->mInfo->signcount;
 }
 
-unsigned long GpgME::TofuInfo::firstSeen() const
+unsigned short GpgME::TofuInfo::encrCount() const
 {
-    return isNull() ? 0 : d->mInfo->firstseen;
+    return isNull() ? 0 : d->mInfo->encrcount;
 }
 
-unsigned long GpgME::TofuInfo::lastSeen() const
+unsigned long GpgME::TofuInfo::signFirst() const
 {
-    return isNull() ? 0 : d->mInfo->lastseen;
+    return isNull() ? 0 : d->mInfo->signfirst;
+}
+
+unsigned long GpgME::TofuInfo::signLast() const
+{
+    return isNull() ? 0 : d->mInfo->signlast;
+}
+
+unsigned long GpgME::TofuInfo::encrFirst() const
+{
+    return isNull() ? 0 : d->mInfo->encrfirst;
+}
+
+unsigned long GpgME::TofuInfo::encrLast() const
+{
+    return isNull() ? 0 : d->mInfo->encrlast;
 }
 
 std::ostream &GpgME::operator<<(std::ostream &os, const GpgME::TofuInfo &info)
@@ -141,8 +156,11 @@ std::ostream &GpgME::operator<<(std::ostream &os, const GpgME::TofuInfo &info)
            << "\n validity: " << info.validity()
            << "\n policy: "   << info.policy()
            << "\n signcount: "<< info.signCount()
-           << "\n firstseen: "<< info.firstSeen()
-           << "\n lastseen: " << info.lastSeen()
+           << "\n signfirst: "<< info.signFirst()
+           << "\n signlast: " << info.signLast()
+           << "\n encrcount: "<< info.encrCount()
+           << "\n encrfirst: "<< info.encrFirst()
+           << "\n encrlast: " << info.encrLast()
            << '\n';
     }
     return os << ")";
diff --git a/lang/cpp/src/tofuinfo.h b/lang/cpp/src/tofuinfo.h
index eb5dbcc..ec253e9 100644
--- a/lang/cpp/src/tofuinfo.h
+++ b/lang/cpp/src/tofuinfo.h
@@ -93,11 +93,20 @@ public:
     /* Number of signatures seen for this binding.  Capped at USHRT_MAX.  */
     unsigned short signCount() const;
 
+    /* Number of encryption done to this binding.  Capped at USHRT_MAX.  */
+    unsigned short encrCount() const;
+
     /** Number of seconds since epoch when the first message was verified */
-    unsigned long firstSeen() const;
+    unsigned long signFirst() const;
 
     /** Number of seconds since epoch when the last message was verified */
-    unsigned long lastSeen() const;
+    unsigned long signLast() const;
+
+    /** Number of seconds since epoch when the first message was encrypted */
+    unsigned long encrFirst() const;
+
+    /** Number of seconds since epoch when the last message was encrypted */
+    unsigned long encrLast() const;
 
     /* If non-NULL a human readable string summarizing the TOFU data. */
     const char *description() const;
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 57f3446..00a4bed 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -650,9 +650,11 @@ struct _gpgme_tofu_info
   unsigned short encrcount;
 
   /* Number of seconds since Epoch when the first and the most
-   * recently seen message were verified.  0 means unknown. */
-  unsigned long firstseen;
-  unsigned long lastseen;
+   * recently seen message were verified/decrypted.  0 means unknown. */
+  unsigned long signfirst;
+  unsigned long signlast;
+  unsigned long encrfirst;
+  unsigned long encrlast;
 
   /* If non-NULL a human readable string summarizing the TOFU data. */
   char *description;
diff --git a/src/keylist.c b/src/keylist.c
index 9f1e68d..f7912e6 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -466,11 +466,25 @@ parse_tfs_record (gpgme_user_id_t uid, char **field, int nfield)
   err = _gpgme_strtoul_field (field[6], &uval);
   if (err)
     goto inv_engine;
-  ti->firstseen = uval;
+  ti->signfirst = uval;
   err = _gpgme_strtoul_field (field[7], &uval);
   if (err)
     goto inv_engine;
-  ti->lastseen = uval;
+  ti->signlast = uval;
+
+  if (nfield > 9)
+    {
+      /* This condition is only to allow for gpg 2.1.15 - can
+       * eventually be removed.  */
+      err = _gpgme_strtoul_field (field[8], &uval);
+      if (err)
+        goto inv_engine;
+      ti->encrfirst = uval;
+      err = _gpgme_strtoul_field (field[9], &uval);
+      if (err)
+        goto inv_engine;
+      ti->encrlast = uval;
+    }
 
   /* Ready.  */
   uid->tofu = ti;
diff --git a/src/verify.c b/src/verify.c
index 92eb333..5ac937d 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -755,20 +755,21 @@ parse_tofu_user (gpgme_signature_t sig, char *args, gpgme_protocol_t protocol)
 
 /* Parse a TOFU_STATS line and store it in the last tofu info of SIG.
  *
- *   TOFU_STATS <validity> <sign-count> <encr-count> [<policy> [<tm1> <tm2>]]
+ *   TOFU_STATS <validity> <sign-count> <encr-count> \
+ *                         [<policy> [<tm1> <tm2> <tm3> <tm4>]]
  */
 static gpgme_error_t
 parse_tofu_stats (gpgme_signature_t sig, char *args)
 {
   gpgme_error_t err;
   gpgme_tofu_info_t ti;
-  char *field[6];
+  char *field[8];
   int nfields;
   unsigned long uval;
 
   if (!sig->key || !sig->key->_last_uid || !(ti = sig->key->_last_uid->tofu))
     return trace_gpg_error (GPG_ERR_INV_ENGINE); /* No TOFU_USER seen.  */
-  if (ti->firstseen || ti->signcount || ti->validity || ti->policy)
+  if (ti->signfirst || ti->signcount || ti->validity || ti->policy)
     return trace_gpg_error (GPG_ERR_INV_ENGINE); /* Already set.  */
 
   nfields = _gpgme_split_fields (args, field, DIM (field));
@@ -824,11 +825,24 @@ parse_tofu_stats (gpgme_signature_t sig, char *args)
   err = _gpgme_strtoul_field (field[4], &uval);
   if (err)
     return trace_gpg_error (GPG_ERR_INV_ENGINE);
-  ti->firstseen = uval;
+  ti->signfirst = uval;
   err = _gpgme_strtoul_field (field[5], &uval);
   if (err)
     return trace_gpg_error (GPG_ERR_INV_ENGINE);
-  ti->lastseen = uval;
+  ti->signlast = uval;
+  if (nfields > 7)
+    {
+      /* This condition is only to allow for gpg 2.1.15 - can
+       * eventually be removed.  */
+      err = _gpgme_strtoul_field (field[6], &uval);
+      if (err)
+        return trace_gpg_error (GPG_ERR_INV_ENGINE);
+      ti->encrfirst = uval;
+      err = _gpgme_strtoul_field (field[7], &uval);
+      if (err)
+        return trace_gpg_error (GPG_ERR_INV_ENGINE);
+      ti->encrlast = uval;
+    }
 
   return 0;
 }
diff --git a/tests/run-keylist.c b/tests/run-keylist.c
index 00f874d..647a9ed 100644
--- a/tests/run-keylist.c
+++ b/tests/run-keylist.c
@@ -291,9 +291,11 @@ main (int argc, char **argv)
                       ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
                       ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
               printf ("   nsigs: %hu\n", ti->signcount);
+              printf ("   first: %s\n", isotimestr (ti->signfirst));
+              printf ("    last: %s\n", isotimestr (ti->signlast));
               printf ("   nencr: %hu\n", ti->encrcount);
-              printf ("   first: %s\n", isotimestr (ti->firstseen));
-              printf ("    last: %s\n", isotimestr (ti->lastseen));
+              printf ("   first: %s\n", isotimestr (ti->encrfirst));
+              printf ("    last: %s\n", isotimestr (ti->encrlast));
             }
         }
 
diff --git a/tests/run-verify.c b/tests/run-verify.c
index 3c18d3b..ebc20d9 100644
--- a/tests/run-verify.c
+++ b/tests/run-verify.c
@@ -197,9 +197,12 @@ print_result (gpgme_verify_result_t result)
                       ti->policy == GPGME_TOFU_POLICY_UNKNOWN? "unknown" :
                       ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
                       ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
-              printf ("    sigcount : %hu\n", ti->signcount);
-              printf ("    firstseen: %s\n", isotimestr (ti->firstseen));
-              printf ("    lastseen : %s\n", isotimestr (ti->lastseen));
+              printf ("    signcount: %hu\n", ti->signcount);
+              printf ("      first..: %s\n", isotimestr (ti->signfirst));
+              printf ("      last ..: %s\n", isotimestr (ti->signlast));
+              printf ("    encrcount: %hu\n", ti->encrcount);
+              printf ("      first..: %s\n", isotimestr (ti->encrfirst));
+              printf ("      last ..: %s\n", isotimestr (ti->encrlast));
               printf ("    desc ....: ");
               print_description (nonnull (ti->description), 15);
             }

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

Summary of changes:
 lang/cpp/src/tofuinfo.cpp | 30 ++++++++++++++++++++++++------
 lang/cpp/src/tofuinfo.h   | 13 +++++++++++--
 src/gpgme.h.in            |  8 +++++---
 src/keylist.c             | 18 ++++++++++++++++--
 src/verify.c              | 24 +++++++++++++++++++-----
 tests/run-keylist.c       |  6 ++++--
 tests/run-verify.c        |  9 ++++++---
 7 files changed, 85 insertions(+), 23 deletions(-)


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




More information about the Gnupg-commits mailing list