[git] GPGME - branch, master, updated. gpgme-1.6.0-196-g329ab93
by Andre Heinecke
cvs at cvs.gnupg.org
Mon Jul 4 11:48:30 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 329ab93f7ed862d7f4c0501fca5355936a74ac52 (commit)
via 8fa9b5696ca9f8386971e6f36646536f9579ceaa (commit)
via efb5059b9b6e81db7b0c016aa9fb70abe98308ea (commit)
via 80498ab662238a31325e78c0037ea6752f680a37 (commit)
via d75c118aae18e20f08dbbb69c7998e1f3694ccd0 (commit)
from fbd6ac4655ebf56d91ebd9a4ff499c8319fcd087 (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 329ab93f7ed862d7f4c0501fca5355936a74ac52
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Jul 4 11:23:12 2016 +0200
Doc: Document pinentry mode
* doc/gpgme.texi (Passphrase Callback): Document as context
attribute.
(gpgme_set_passphrase_cb): Note that this requires LOOPBACK mode
with GnuPG 2.1.
diff --git a/doc/gpgme.texi b/doc/gpgme.texi
index 8d666c3..87322b0 100644
--- a/doc/gpgme.texi
+++ b/doc/gpgme.texi
@@ -2311,6 +2311,7 @@ started. In fact, these references are accessed through the
* ASCII Armor:: Requesting @acronym{ASCII} armored output.
* Text Mode:: Choosing canonical text mode.
* Offline Mode:: Choosing offline mode.
+* Pinentry Mode:: Choosing the pinentry mode.
* Included Certificates:: Including a number of certificates.
* Key Listing Mode:: Selecting key listing mode.
* Passphrase Callback:: Getting the passphrase from the user.
@@ -2471,6 +2472,57 @@ valid pointer.
@end deftypefun
+ at node Pinentry Mode
+ at subsection Pinentry Mode
+ at cindex context, pinentry mode
+ at cindex pinentry mode
+
+ at deftypefun gpgme_error_t gpgme_set_pinentry_mode (@w{gpgme_ctx_t @var{ctx}},
+ at w{gpgme_pinentry_mode_t @var{mode}})
+The function @code{gpgme_set_pinentry_mode} specifies the pinentry mode
+to be used.
+
+For GnuPG >= 2.1 this option is required to be set to
+ at code{GPGME_PINENTRY_MODE_LOOPBACK} to enable the passphrase callback
+mechanism in GPGME through @code{gpgme_set_passphrase_cb}.
+ at end deftypefun
+
+ at deftypefun gpgme_pinentry_mode_t gpgme_get_pinentry_mode (@w{gpgme_ctx_t @var{ctx}})
+The function @code{gpgme_get_pinenty_mode} returns the
+mode set for the context.
+ at end deftypefun
+
+ at deftp {Data type} {enum gpgme_pinentry_mode_t}
+ at tindex gpgme_pinentry_mode_t
+The @code{gpgme_minentry_mode_t} type specifies the set of possible pinentry
+modes that are supported by @acronym{GPGME} if GnuPG >= 2.1 is used.
+The following modes are supported:
+
+ at table @code
+ at item GPGME_PINENTRY_MODE_DEFAULT
+Use the default of the agent, which is ask.
+
+ at item GPGME_PINENTRY_MODE_ASK
+Force the use of the Pinentry.
+
+ at item GPGME_PINENTRY_MODE_CANCEL
+Emulate use of Pinentry's cancel button.
+
+ at item GPGME_PINENTRY_MODE_ERROR
+Return a Pinentry error @code{No Pinentry}.
+
+ at item GPGME_PINENTRY_MODE_LOOPBACK
+Redirect Pinentry queries to the caller.
+This enables the use of @code{gpgme_set_passphrase_cb} whis pinentry
+queries redirected to gpgme.
+
+Note: This mode requires @code{allow-loopback-pinentry} to be enabled
+in the @file{gpg-agent.conf} or an agent started with that option.
+
+ at end table
+ at end deftp
+
+
@node Included Certificates
@subsection Included Certificates
@cindex certificates, included
@@ -2639,6 +2691,10 @@ implement their own passphrase query. Some engines do not even
support an external passphrase callback at all, in this case the error
code @code{GPG_ERR_NOT_SUPPORTED} is returned.
+For GnuPG >= 2.1 the pinentry mode has to be set to
+ at code{GPGME_PINENTRY_MODE_LOOPBACK} to enable the passphrase callback.
+See @code{gpgme_set_pinentry_mode}.
+
The user can disable the use of a passphrase callback function by
calling @code{gpgme_set_passphrase_cb} with @var{passfunc} being
@code{NULL}.
commit 8fa9b5696ca9f8386971e6f36646536f9579ceaa
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Jul 4 11:42:30 2016 +0200
Qt: Add testTofuSignCount
* src/lang/qt/tests/t-tofuinfo.cpp(testTofuSignCount): New.
(initTestCase): Set gpg-agent loopback pinentry config.
(signAndVerify): Helper for tofuTestSignCount.
--
Also needs the wait code because of GnuPG-Bug-Id: 2405
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index 0257359..a27dd93 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -35,6 +35,12 @@
#include "tofuinfo.h"
#include "verifyopaquejob.h"
#include "verificationresult.h"
+#include "signingresult.h"
+#include "keylistjob.h"
+#include "keylistresult.h"
+#include "qgpgmesignjob.h"
+#include "key.h"
+#include "t-support.h"
#include <iostream>
using namespace QGpgME;
@@ -64,6 +70,40 @@ class TofuInfoTest: public QObject
Q_ASSERT(orig.policy() == other.policy());
}
+ void signAndVerify(const QString &what, const GpgME::Key &key, int expected)
+ {
+ Context *ctx = Context::createForProtocol(OpenPGP);
+ ctx->setPassphraseProvider(new TestPassphraseProvider);
+ ctx->setPinentryMode(Context::PinentryLoopback);
+ auto *job = new QGpgMESignJob(ctx);
+
+ std::vector<Key> keys;
+ keys.push_back(key);
+ QByteArray signedData;
+ auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData);
+
+ Q_ASSERT(!sigResult.error());
+
+ auto verifyJob = openpgp()->verifyOpaqueJob();
+ QByteArray verified;
+
+ auto result = verifyJob->exec(signedData, verified);
+
+ Q_ASSERT(!result.error());
+ Q_ASSERT(verified == what.toUtf8());
+
+ 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);
+ }
+ /* FIXME: GnuPG-Bug-Id 2405 makes the wait necessary. */
+ QTest::qWait(1000);
+ }
+
private:
QTemporaryDir mDir;
@@ -90,9 +130,9 @@ private Q_SLOTS:
auto result = job->exec(data1, plaintext);
- Q_ASSERT(!strcmp(plaintext.constData(), "Just GNU it!\n"));
Q_ASSERT(!result.isNull());
Q_ASSERT(!result.error());
+ Q_ASSERT(!strcmp(plaintext.constData(), "Just GNU it!\n"));
Q_ASSERT(result.numSignatures() == 1);
Signature sig = result.signatures()[0];
@@ -138,6 +178,44 @@ private Q_SLOTS:
Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
}
+
+ /* Verify that another call yields the same result */
+ job = openpgp()->verifyOpaqueJob(true);
+ result = job->exec(data1, plaintext);
+
+ Q_ASSERT(!result.isNull());
+ Q_ASSERT(!result.error());
+
+ Q_ASSERT(result.numSignatures() == 1);
+ sig = result.signatures()[0];
+ /* 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);
+ }
+ }
+
+ void testTofuSignCount()
+ {
+ auto *job = openpgp()->keyListJob(false, false, false);
+ std::vector<GpgME::Key> keys;
+ GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu at example.net"),
+ true, keys);
+ Q_ASSERT(!keys.empty());
+ 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);
}
void initTestCase()
@@ -150,6 +228,10 @@ private Q_SLOTS:
Q_ASSERT(conf.open(QIODevice::WriteOnly));
conf.write("trust-model tofu+pgp");
conf.close();
+ QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
+ Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
+ agentConf.write("allow-loopback-pinentry");
+ agentConf.close();
Q_ASSERT(QFile::copy(gpgHome + QStringLiteral("/pubring.gpg"),
mDir.path() + QStringLiteral("/pubring.gpg")));
Q_ASSERT(QFile::copy(gpgHome + QStringLiteral("/secring.gpg"),
commit efb5059b9b6e81db7b0c016aa9fb70abe98308ea
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Jul 4 11:40:03 2016 +0200
Qt: Add test passphrase provider
* lang/qt/tests/t-support.h (TestPassphraseProvider): New.
* lang/qt/tests/Makefile.am (t_tofuinfo_SOURCES): Add t-support.h
diff --git a/lang/qt/tests/Makefile.am b/lang/qt/tests/Makefile.am
index 204b5a7..c228000 100644
--- a/lang/qt/tests/Makefile.am
+++ b/lang/qt/tests/Makefile.am
@@ -49,7 +49,7 @@ initial.test : check-local
t_keylist_SOURCES = t-keylist.cpp
t_keylocate_SOURCES = t-keylocate.cpp
t_ownertrust_SOURCES = t-ownertrust.cpp
-t_tofuinfo_SOURCES = t-tofuinfo.cpp
+t_tofuinfo_SOURCES = t-tofuinfo.cpp t-support.h
nodist_t_keylist_SOURCES = $(moc_files)
diff --git a/lang/qt/tests/t-support.h b/lang/qt/tests/t-support.h
new file mode 100644
index 0000000..8755b99
--- /dev/null
+++ b/lang/qt/tests/t-support.h
@@ -0,0 +1,47 @@
+/* t-support.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2016 Intevation GmbH
+
+ QGpgME is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ QGpgME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#include "interfaces/passphraseprovider.h"
+#include <QtGlobal>
+
+namespace GpgME
+{
+class TestPassphraseProvider : public PassphraseProvider
+{
+public:
+ char *getPassphrase(const char *useridHint, const char *description,
+ bool previousWasBad, bool &canceled) Q_DECL_OVERRIDE
+ {
+ return strdup("abc");
+ }
+};
+
+} // namespace GpgME
commit 80498ab662238a31325e78c0037ea6752f680a37
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Jul 4 11:31:01 2016 +0200
Cpp: Add support for TOFU_CONFLICT sigsum
* lang/cpp/src/verificationresult.cpp (GpgME::Signature::Summary):
Handle TOFU_CONFLICT.
* lang/cpp/src/verificationresult.h (Summary): Add TofuConflict.
diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp
index 4bd1a7b..3eb8a85 100644
--- a/lang/cpp/src/verificationresult.cpp
+++ b/lang/cpp/src/verificationresult.cpp
@@ -224,6 +224,9 @@ GpgME::Signature::Summary GpgME::Signature::summary() const
if (sigsum & GPGME_SIGSUM_SYS_ERROR) {
result |= SysError;
}
+ if (sigsum & GPGME_SIGSUM_TOFU_CONFLICT) {
+ result |= TofuConflict;
+ }
return static_cast<Summary>(result);
}
@@ -520,6 +523,7 @@ std::ostream &GpgME::operator<<(std::ostream &os, Signature::Summary summary)
OUTPUT(CrlTooOld);
OUTPUT(BadPolicy);
OUTPUT(SysError);
+ OUTPUT(TofuConflict);
#undef OUTPUT
return os << ')';
}
diff --git a/lang/cpp/src/verificationresult.h b/lang/cpp/src/verificationresult.h
index 5a2927f..f5fbc2e 100644
--- a/lang/cpp/src/verificationresult.h
+++ b/lang/cpp/src/verificationresult.h
@@ -115,7 +115,8 @@ public:
CrlMissing = 0x080,
CrlTooOld = 0x100,
BadPolicy = 0x200,
- SysError = 0x400
+ SysError = 0x400,
+ TofuConflict= 0x800
};
Summary summary() const;
commit d75c118aae18e20f08dbbb69c7998e1f3694ccd0
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Jul 4 11:25:40 2016 +0200
Cpp: Add support for pinentry_mode
* lang/cpp/src/context.cpp (Context::pinentryMode): Return mode.
(Context::setPinentryMode): Set mode.
* lang/cpp/src/context.h (PinentryMode): Add enum.
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 085b835..9e31b6a 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -1255,6 +1255,46 @@ Error Context::lastError() const
return Error(d->lasterr);
}
+Context::PinentryMode Context::pinentryMode() const
+{
+ switch (gpgme_get_pinentry_mode (d->ctx)) {
+ case GPGME_PINENTRY_MODE_ASK:
+ return PinentryAsk;
+ case GPGME_PINENTRY_MODE_CANCEL:
+ return PinentryCancel;
+ case GPGME_PINENTRY_MODE_ERROR:
+ return PinentryError;
+ case GPGME_PINENTRY_MODE_LOOPBACK:
+ return PinentryLoopback;
+ case GPGME_PINENTRY_MODE_DEFAULT:
+ default:
+ return PinentryDefault;
+ }
+}
+
+Error Context::setPinentryMode(PinentryMode which)
+{
+ gpgme_pinentry_mode_t mode;
+ switch (which) {
+ case PinentryAsk:
+ mode = GPGME_PINENTRY_MODE_ASK;
+ break;
+ case PinentryCancel:
+ mode = GPGME_PINENTRY_MODE_CANCEL;
+ break;
+ case PinentryError:
+ mode = GPGME_PINENTRY_MODE_ERROR;
+ break;
+ case PinentryLoopback:
+ mode = GPGME_PINENTRY_MODE_LOOPBACK;
+ break;
+ case PinentryDefault:
+ default:
+ mode = GPGME_PINENTRY_MODE_DEFAULT;
+ }
+ return Error(d->lasterr = gpgme_set_pinentry_mode(d->ctx, mode));
+}
+
std::ostream &operator<<(std::ostream &os, Protocol proto)
{
os << "GpgME::Protocol(";
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index a8112d6..c9c2af7 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -117,6 +117,16 @@ public:
GpgME::Error setEngineFileName(const char *filename);
GpgME::Error setEngineHomeDirectory(const char *filename);
+ enum PinentryMode{
+ PinentryDefault = 0,
+ PinentryAsk = 1,
+ PinentryCancel = 2,
+ PinentryError = 3,
+ PinentryLoopback = 4
+ };
+ GpgME::Error setPinentryMode(PinentryMode which);
+ PinentryMode pinentryMode() const;
+
private:
friend class ::GpgME::EventLoopInteractor;
void installIOCallbacks(gpgme_io_cbs *iocbs);
-----------------------------------------------------------------------
Summary of changes:
doc/gpgme.texi | 56 +++++++++++++++
lang/cpp/src/context.cpp | 40 +++++++++++
lang/cpp/src/context.h | 10 +++
lang/cpp/src/verificationresult.cpp | 4 ++
lang/cpp/src/verificationresult.h | 3 +-
lang/qt/tests/Makefile.am | 2 +-
.../{src/abstractimportjob.h => tests/t-support.h} | 35 +++------
lang/qt/tests/t-tofuinfo.cpp | 84 +++++++++++++++++++++-
8 files changed, 206 insertions(+), 28 deletions(-)
copy lang/qt/{src/abstractimportjob.h => tests/t-support.h} (72%)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list