[git] GPGME - branch, master, updated. gpgme-1.6.0-302-gd2e40fb

by Andre Heinecke cvs at cvs.gnupg.org
Wed Aug 24 14:01:56 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  d2e40fb7adf667f3e2d2457ee4c646ea4d4d88b3 (commit)
       via  7c5a4974b71c30e824cbfcb3a0a70064e5ed5adb (commit)
       via  40ea1c85773cbe324557c34b3a4282f609fcdaf6 (commit)
      from  799b168243e6499ac01bf59e0656547f353a2589 (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 d2e40fb7adf667f3e2d2457ee4c646ea4d4d88b3
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Aug 24 14:00:41 2016 +0200

    Qt: Adapt (disabled) tofuinfo test to new API
    
    * lang/qt/tests/t-tofuinfo.cpp: Switch to UID based API.
    
    --
    Test is still disabled as GnuPG still returns unexpected
    results.

diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index 2f2ed43..ab466ee 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -41,6 +41,7 @@
 #include "qgpgmesignjob.h"
 #include "key.h"
 #include "t-support.h"
+#include "engineinfo.h"
 #include <iostream>
 
 using namespace QGpgME;
@@ -57,14 +58,20 @@ static const char testMsg1[] =
 
 class TofuInfoTest: public QGpgMETest
 {
-#if 0
     Q_OBJECT
 
+    bool testSupported()
+    {
+        /* GnuPG currently returns different values for different uid's
+         * on the first verify. This breaks this test. so its disabled
+         * for now. See GnuPG-Bug 2405 */
+        return !(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "3.0.0");
+    }
+
     void testTofuCopy(TofuInfo other, const TofuInfo &orig)
     {
         Q_ASSERT(!orig.isNull());
         Q_ASSERT(!other.isNull());
-        Q_ASSERT(!strcmp(orig.fingerprint(), other.fingerprint()));
         Q_ASSERT(orig.lastSeen() == other.lastSeen());
         Q_ASSERT(orig.signCount() == other.signCount());
         Q_ASSERT(orig.validity() == other.validity());
@@ -84,6 +91,9 @@ class TofuInfoTest: public QGpgMETest
         QByteArray signedData;
         auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData);
 
+        auto info = keys[0].userID(0).tofuInfo();
+        Q_ASSERT(info.signCount() == expected - 1);
+
         Q_ASSERT(!sigResult.error());
 
         auto verifyJob = openpgp()->verifyOpaqueJob();
@@ -97,23 +107,23 @@ class TofuInfoTest: public QGpgMETest
         Q_ASSERT(result.numSignatures() == 1);
         auto sig = result.signatures()[0];
 
-        Q_FOREACH(const TofuInfo stats, sig.tofuInfo()) {
-            Q_ASSERT(!stats.isNull());
-            Q_ASSERT(!strcmp(stats.fingerprint(), sig.fingerprint()));
-            Q_ASSERT(stats.signCount() == expected);
-        }
+        auto key2 = sig.key();
+        Q_ASSERT(!key.isNull());
+        Q_ASSERT(!strcmp (key2.primaryFingerprint(), key.primaryFingerprint()));
+        Q_ASSERT(!strcmp (key.primaryFingerprint(), sig.fingerprint()));
+        auto stats = key2.userID(0).tofuInfo();
+        Q_ASSERT(!stats.isNull());
+        Q_ASSERT(stats.signCount() == expected);
     }
 
-private:
-    QTemporaryDir mDir;
-
-private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */:
+private Q_SLOTS:
     void testTofuNull()
     {
+        if (!testSupported()) {
+            return;
+        }
         TofuInfo tofu;
         Q_ASSERT(tofu.isNull());
-        Q_ASSERT(!tofu.fingerprint());
-        Q_ASSERT(!tofu.address());
         Q_ASSERT(!tofu.description());
         Q_ASSERT(!tofu.signCount());
         Q_ASSERT(!tofu.lastSeen());
@@ -124,6 +134,9 @@ private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */:
 
     void testTofuInfo()
     {
+        if (!testSupported()) {
+            return;
+        }
         auto *job = openpgp()->verifyOpaqueJob(true);
         const QByteArray data1(testMsg1);
         QByteArray plaintext;
@@ -139,20 +152,17 @@ private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */:
         /* TOFU is always marginal */
         Q_ASSERT(sig.validity() == Signature::Marginal);
 
-        Q_ASSERT(!sig.tofuInfo().empty());
-        Q_FOREACH(const TofuInfo stats, sig.tofuInfo()) {
-            Q_ASSERT(!stats.isNull());
-            Q_ASSERT(!strcmp(stats.fingerprint(), sig.fingerprint()));
-            Q_ASSERT(stats.firstSeen() == stats.lastSeen());
-            Q_ASSERT(!stats.signCount());
-            Q_ASSERT(stats.address());
-          /* See issue2405 Comment back in when resolved
-            Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto); */
-            Q_ASSERT(stats.validity() == TofuInfo::NoHistory);
-        }
+        auto stats = sig.key().userID(0).tofuInfo();
+        Q_ASSERT(!stats.isNull());
+        Q_ASSERT(sig.key().primaryFingerprint());
+        Q_ASSERT(sig.fingerprint());
+        Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
+        Q_ASSERT(stats.firstSeen() == stats.lastSeen());
+        Q_ASSERT(stats.signCount() == 1);
+        Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
+        Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
 
-        const TofuInfo first = sig.tofuInfo()[0];
-        testTofuCopy(first, first);
+        testTofuCopy(stats, stats);
 
         /* Another verify */
 
@@ -167,15 +177,13 @@ private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */:
         /* TOFU is always marginal */
         Q_ASSERT(sig.validity() == Signature::Marginal);
 
-        Q_ASSERT(!sig.tofuInfo().empty());
-        Q_FOREACH(const TofuInfo stats, sig.tofuInfo()) {
-            Q_ASSERT(!stats.isNull());
-            Q_ASSERT(!strcmp(stats.fingerprint(), sig.fingerprint()));
-            Q_ASSERT(stats.signCount() == 1);
-            Q_ASSERT(stats.address());
-            Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
-            Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
-        }
+        stats = sig.key().userID(0).tofuInfo();
+        Q_ASSERT(!stats.isNull());
+        Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
+        Q_ASSERT(stats.firstSeen() == stats.lastSeen());
+        Q_ASSERT(stats.signCount() == 1);
+        Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
+        Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
 
         /* Verify that another call yields the same result */
         job = openpgp()->verifyOpaqueJob(true);
@@ -189,19 +197,20 @@ private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */:
         /* TOFU is always marginal */
         Q_ASSERT(sig.validity() == Signature::Marginal);
 
-        Q_ASSERT(!sig.tofuInfo().empty());
-        Q_FOREACH(const TofuInfo stats, sig.tofuInfo()) {
-            Q_ASSERT(!stats.isNull());
-            Q_ASSERT(!strcmp(stats.fingerprint(), sig.fingerprint()));
-            Q_ASSERT(stats.signCount() == 1);
-            Q_ASSERT(stats.address());
-            Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
-            Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
-        }
+        stats = sig.key().userID(0).tofuInfo();
+        Q_ASSERT(!stats.isNull());
+        Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
+        Q_ASSERT(stats.firstSeen() == stats.lastSeen());
+        Q_ASSERT(stats.signCount() == 1);
+        Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
+        Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
     }
 
     void testTofuSignCount()
     {
+        if (!testSupported()) {
+            return;
+        }
         auto *job = openpgp()->keyListJob(false, false, false);
         std::vector<GpgME::Key> keys;
         GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu at example.net"),
@@ -210,10 +219,10 @@ private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */:
         Key key = keys[0];
         Q_ASSERT(!key.isNull());
 
-        signAndVerify(QStringLiteral("Hello"), key, 0);
-        signAndVerify(QStringLiteral("Hello2"), key, 1);
-        signAndVerify(QStringLiteral("Hello3"), key, 2);
-        signAndVerify(QStringLiteral("Hello4"), key, 3);
+        signAndVerify(QStringLiteral("Hello"), key, 1);
+        signAndVerify(QStringLiteral("Hello2"), key, 2);
+        signAndVerify(QStringLiteral("Hello3"), key, 3);
+        signAndVerify(QStringLiteral("Hello4"), key, 4);
     }
 
     void initTestCase()
@@ -236,7 +245,9 @@ private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */:
                  mDir.path() + QStringLiteral("/secring.gpg")));
 
     }
-#endif
+private:
+    QTemporaryDir mDir;
+
 };
 
 QTEST_MAIN(TofuInfoTest)

commit 7c5a4974b71c30e824cbfcb3a0a70064e5ed5adb
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Aug 24 13:59:37 2016 +0200

    Cpp: Add Key to signature
    
    * lang/cpp/src/verificationresult.cpp,
    lang/cpp/src/verificationresult.h (Signature::key): New.

diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp
index c32c896..c62625d 100644
--- a/lang/cpp/src/verificationresult.cpp
+++ b/lang/cpp/src/verificationresult.cpp
@@ -24,6 +24,7 @@
 #include <notation.h>
 #include "result_p.h"
 #include "util.h"
+#include "key.h"
 
 #include <gpgme.h>
 
@@ -64,6 +65,10 @@ public:
 # endif
             scopy->next = 0;
             sigs.push_back(scopy);
+            // copy keys
+            if (scopy->key) {
+                keys.push_back(Key(scopy->key, true));
+            }
             // copy notations:
             nota.push_back(std::vector<Nota>());
             purls.push_back(0);
@@ -107,6 +112,7 @@ public:
 
     std::vector<gpgme_signature_t> sigs;
     std::vector< std::vector<Nota> > nota;
+    std::vector<GpgME::Key> keys;
     std::vector<char *> purls;
     std::string file_name;
 };
@@ -366,6 +372,14 @@ std::vector<GpgME::Notation> GpgME::Signature::notations() const
     return result;
 }
 
+GpgME::Key GpgME::Signature::key() const
+{
+    if (isNull()) {
+        return Key();
+    }
+    return d->keys[idx];
+}
+
 class GpgME::Notation::Private
 {
 public:
diff --git a/lang/cpp/src/verificationresult.h b/lang/cpp/src/verificationresult.h
index 3394a47..93288af 100644
--- a/lang/cpp/src/verificationresult.h
+++ b/lang/cpp/src/verificationresult.h
@@ -40,6 +40,7 @@ namespace GpgME
 class Error;
 class Signature;
 class Notation;
+class Key;
 
 class GPGMEPP_EXPORT VerificationResult : public Result
 {
@@ -157,6 +158,11 @@ public:
     GpgME::Notation notation(unsigned int index) const;
     std::vector<GpgME::Notation> notations() const;
 
+    /** Returns the key object associated with this signature.
+     * May be incomplete but will have at least the fingerprint
+     * set or the associated TOFU Information if applicable. */
+    GpgME::Key key() const;
+
 private:
     std::shared_ptr<VerificationResult::Private> d;
     unsigned int idx;

commit 40ea1c85773cbe324557c34b3a4282f609fcdaf6
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Aug 24 13:57:49 2016 +0200

    Cpp: Use fpr field for primaryFingerprint
    
    * lang/cpp/src/key.cpp (Key::primaryFingerprint): Return
    fpr value if available.
    
    --
    Should not be necessary but we might have an incomplete
    key without subkeys but the fingerprint already set in
    gpgme's data type.

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 68d7685..6f40f66 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -259,11 +259,16 @@ const char *Key::shortKeyID() const
 
 const char *Key::primaryFingerprint() const
 {
-    const char *fpr = key && key->subkeys ? key->subkeys->fpr : 0 ;
-    if (fpr) {
-        return fpr;
-    } else {
-        return keyID();
+    if (!key) {
+        return nullptr;
+    }
+    if (key->fpr) {
+        /* Return what gpgme thinks is the primary fingerprint */
+        return key->fpr;
+    }
+    if (key->subkeys) {
+        /* Return the first subkeys fingerprint */
+        return key->subkeys->fpr;
     }
 }
 

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

Summary of changes:
 lang/cpp/src/key.cpp                |  15 +++--
 lang/cpp/src/verificationresult.cpp |  14 +++++
 lang/cpp/src/verificationresult.h   |   6 ++
 lang/qt/tests/t-tofuinfo.cpp        | 109 ++++++++++++++++++++----------------
 4 files changed, 90 insertions(+), 54 deletions(-)


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




More information about the Gnupg-commits mailing list