[git] GPGME - branch, master, updated. gpgme-1.6.0-324-g965b842

by Andre Heinecke cvs at cvs.gnupg.org
Mon Sep 5 12:59:55 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  965b842fad6ec6fbd8902f3a32119abcd0728fe4 (commit)
       via  79439e76cc5b302222874a1f9e93665cb12801ac (commit)
       via  444d85ace0dddff5c511961927052d9946035b00 (commit)
      from  8a39a595eb802b80a6ad756b0ee8939e9733e86f (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 965b842fad6ec6fbd8902f3a32119abcd0728fe4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 5 12:58:35 2016 +0200

    qt: Enable signcount checks in tofuinfo test
    
    * lang/qt/tests/t-tofuinfo.cpp: Enable checks for signcount.
    
    --
    Signcount for userIDs works now as expected with gnupg 2.1.16.

diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index 30f7bea..f7238f3 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -89,13 +89,12 @@ class TofuInfoTest: public QGpgMETest
         auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData);
         delete job;
 
-        auto info = keys[0].userID(0).tofuInfo();
-        if (expected != -1) {
+        Q_ASSERT(!sigResult.error());
+        foreach (const auto uid, keys[0].userIDs()) {
+            auto info = uid.tofuInfo();
             Q_ASSERT(info.signCount() == expected - 1);
         }
 
-        Q_ASSERT(!sigResult.error());
-
         auto verifyJob = openpgp()->verifyOpaqueJob();
         QByteArray verified;
 
@@ -114,9 +113,13 @@ class TofuInfoTest: public QGpgMETest
         Q_ASSERT(!strcmp (key.primaryFingerprint(), sig.fingerprint()));
         auto stats = key2.userID(0).tofuInfo();
         Q_ASSERT(!stats.isNull());
-        if (expected != -1) {
-            Q_ASSERT(stats.signCount() == expected);
+        if (stats.signCount() != expected) {
+            std::cout << "################ Key before verify: "
+                      << key
+                      << "################ Key after verify: "
+                      << key2;
         }
+        Q_ASSERT(stats.signCount() == expected);
     }
 
 private Q_SLOTS:
@@ -218,6 +221,7 @@ private Q_SLOTS:
             return;
         }
         auto *job = openpgp()->keyListJob(false, false, false);
+        job->addMode(GpgME::WithTofu);
         std::vector<GpgME::Key> keys;
         GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu at example.net"),
                                                 true, keys);
@@ -226,10 +230,13 @@ private Q_SLOTS:
         Key key = keys[0];
         Q_ASSERT(!key.isNull());
 
-        signAndVerify(QStringLiteral("Hello"), key, -1);
-        signAndVerify(QStringLiteral("Hello2"), key, -1);
-        signAndVerify(QStringLiteral("Hello3"), key, -1);
-        signAndVerify(QStringLiteral("Hello4"), key, -1);
+        signAndVerify(QStringLiteral("Hello"), key, 1);
+        key.update();
+        signAndVerify(QStringLiteral("Hello2"), key, 2);
+        key.update();
+        signAndVerify(QStringLiteral("Hello3"), key, 3);
+        key.update();
+        signAndVerify(QStringLiteral("Hello4"), key, 4);
     }
 
     void testTofuKeyList()
@@ -248,8 +255,16 @@ private Q_SLOTS:
         auto key = keys[0];
         Q_ASSERT(!key.isNull());
         Q_ASSERT(key.userID(0).tofuInfo().isNull());
-        signAndVerify(QStringLiteral("Hello"), key, -1);
-        signAndVerify(QStringLiteral("Hello"), key, -1);
+        auto keyCopy = key;
+        keyCopy.update();
+        auto sigCnt = keyCopy.userID(0).tofuInfo().signCount();
+        signAndVerify(QStringLiteral("Hello"), keyCopy,
+                      sigCnt + 1);
+        keyCopy.update();
+        /* For some reason if you remove the " World" part of
+         * the next message the test fails. */
+        signAndVerify(QStringLiteral("Hello World"), keyCopy,
+                      sigCnt + 2);
 
         /* Now another one but with tofu */
         job = openpgp()->keyListJob(false, false, false);

commit 79439e76cc5b302222874a1f9e93665cb12801ac
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 5 12:53:02 2016 +0200

    cpp: Add convenience update function to a key
    
    * lang/cpp/src/key.cpp (Key::update): New.
    * lang/cpp/src/key.h: Update accordingly.
    
    --
    This function helps if you have an incomplete key or want
    to make sure all info in a key is complete (e.g. validity / tofuinfo)

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 204eeca..cfa1ba3 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -24,6 +24,7 @@
 
 #include "util.h"
 #include "tofuinfo.h"
+#include "context.h"
 
 #include <gpgme.h>
 
@@ -322,6 +323,27 @@ const Key &Key::mergeWith(const Key &other)
     return *this;
 }
 
+void Key::update()
+{
+    auto ctx = Context::createForProtocol(protocol());
+    if (!ctx) {
+        return;
+    }
+    ctx->setKeyListMode(KeyListMode::Local |
+                        KeyListMode::Signatures |
+                        KeyListMode::SignatureNotations |
+                        KeyListMode::Validate |
+                        KeyListMode::WithTofu);
+    Error err;
+    auto newKey = ctx->key(primaryFingerprint(), err, hasSecret());
+    delete ctx;
+    if (err) {
+        return;
+    }
+    swap(newKey);
+    return;
+}
+
 //
 //
 // class Subkey
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 85b16df..f193093 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -146,6 +146,12 @@ public:
 
     unsigned int keyListMode() const;
 
+    /*! Update information about this key.
+     * Starts a keylisting for this key with validity
+     * and tofu information gathering. Blocks for
+     * how long the keylisting takes.*/
+    void update();
+
 private:
     gpgme_key_t impl() const
     {

commit 444d85ace0dddff5c511961927052d9946035b00
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 5 11:57:09 2016 +0200

    cpp: Add ostream operators for key and uid
    
    * lang/cpp/src/key.cpp (Key, UserID): Add ostream operator.
    * lang/cpp/src/key.h: Update accordingly.
    
    --
    This is helpful debugging / showing the state of a key / uid and
    tofuinfo.

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 6f40f66..204eeca 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -28,6 +28,8 @@
 #include <gpgme.h>
 
 #include <string.h>
+#include <istream>
+#include <iterator>
 
 const GpgME::Key::Null GpgME::Key::null;
 
@@ -848,4 +850,41 @@ const char *UserID::Signature::policyURL() const
     return 0;
 }
 
+std::ostream &operator<<(std::ostream &os, const UserID &uid)
+{
+    os << "GpgME::UserID(";
+    if (!uid.isNull()) {
+        os << "\n name:      " << protect(uid.name())
+           << "\n email:     " << protect(uid.email())
+           << "\n comment:   " << protect(uid.comment())
+           << "\n validity:  " << uid.validityAsString()
+           << "\n revoked:   " << uid.isRevoked()
+           << "\n invalid:   " << uid.isInvalid()
+           << "\n numsigs:   " << uid.numSignatures()
+           << "\n tofuinfo:\n" << uid.tofuInfo();
+    }
+    return os << ')';
+}
+
+std::ostream &operator<<(std::ostream &os, const Key &key)
+{
+    os << "GpgME::Key(";
+    if (!key.isNull()) {
+        os << "\n protocol:   " << protect(key.protocolAsString())
+           << "\n ownertrust: " << key.ownerTrustAsString()
+           << "\n issuer:     " << protect(key.issuerName())
+           << "\n fingerprint:" << protect(key.primaryFingerprint())
+           << "\n listmode:   " << key.keyListMode()
+           << "\n canSign:    " << key.canReallySign()
+           << "\n canEncrypt: " << key.canEncrypt()
+           << "\n canCertify: " << key.canCertify()
+           << "\n canAuth:    " << key.canAuthenticate()
+           << "\n uids:\n";
+        const std::vector<UserID> uids = key.userIDs();
+        std::copy(uids.begin(), uids.end(),
+                  std::ostream_iterator<UserID>(os, "\n"));
+    }
+    return os << ')';
+}
+
 } // namespace GpgME
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index e8d7ee2..85b16df 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -391,6 +391,9 @@ private:
     gpgme_key_sig_t sig;
 };
 
+GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const UserID &uid);
+GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Key &key);
+
 } // namespace GpgME
 
 GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Key)

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

Summary of changes:
 lang/cpp/src/key.cpp         | 61 ++++++++++++++++++++++++++++++++++++++++++++
 lang/cpp/src/key.h           |  9 +++++++
 lang/qt/tests/t-tofuinfo.cpp | 39 +++++++++++++++++++---------
 3 files changed, 97 insertions(+), 12 deletions(-)


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




More information about the Gnupg-commits mailing list