aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lang/qt/src/Makefile.am8
-rw-r--r--lang/qt/src/decryptverifyarchivejob.cpp71
-rw-r--r--lang/qt/src/decryptverifyarchivejob.h91
-rw-r--r--lang/qt/src/decryptverifyarchivejob_p.h49
-rw-r--r--lang/qt/src/protocol.h2
-rw-r--r--lang/qt/src/protocol_p.h12
-rw-r--r--lang/qt/src/qgpgmedecryptverifyarchivejob.cpp119
-rw-r--r--lang/qt/src/qgpgmedecryptverifyarchivejob.h68
8 files changed, 420 insertions, 0 deletions
diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
index 8775531e..3b3f1e80 100644
--- a/lang/qt/src/Makefile.am
+++ b/lang/qt/src/Makefile.am
@@ -34,12 +34,14 @@ EXTRA_DIST = QGpgmeConfig.cmake.in.in QGpgmeConfigVersion.cmake.in \
qgpgme_sources = \
dataprovider.cpp \
debug.cpp \
+ decryptverifyarchivejob.cpp \
encryptarchivejob.cpp \
filelistdataprovider.cpp \
job.cpp multideletejob.cpp qgpgmeadduseridjob.cpp \
qgpgmeaddexistingsubkeyjob.cpp \
qgpgmebackend.cpp qgpgmechangeexpiryjob.cpp qgpgmechangeownertrustjob.cpp \
qgpgmechangepasswdjob.cpp qgpgmedecryptjob.cpp \
+ qgpgmedecryptverifyarchivejob.cpp \
qgpgmedecryptverifyjob.cpp qgpgmedeletejob.cpp qgpgmedownloadjob.cpp \
qgpgmeencryptarchivejob.cpp \
qgpgmeencryptjob.cpp qgpgmeexportjob.cpp qgpgmeimportfromkeyserverjob.cpp \
@@ -75,6 +77,7 @@ qgpgme_headers= \
dataprovider.h \
debug.h \
decryptjob.h \
+ decryptverifyarchivejob.h \
decryptverifyjob.h \
downloadjob.h \
encryptarchivejob.h \
@@ -126,6 +129,7 @@ camelcase_headers= \
DataProvider \
Debug \
DecryptJob \
+ DecryptVerifyArchiveJob \
DecryptVerifyJob \
DN \
DownloadJob \
@@ -168,6 +172,7 @@ camelcase_headers= \
private_qgpgme_headers = \
changeexpiryjob_p.h \
+ decryptverifyarchivejob_p.h \
encryptarchivejob_p.h \
encryptjob_p.h \
importjob_p.h \
@@ -182,6 +187,7 @@ private_qgpgme_headers = \
qgpgmechangeownertrustjob.h \
qgpgmechangepasswdjob.h \
qgpgmedecryptjob.h \
+ qgpgmedecryptverifyarchivejob.h \
qgpgmedecryptverifyjob.h \
qgpgmedeletejob.h \
qgpgmedownloadjob.h \
@@ -224,6 +230,7 @@ qgpgme_moc_sources = \
changeownertrustjob.moc \
changepasswdjob.moc \
decryptjob.moc \
+ decryptverifyarchivejob.moc \
decryptverifyjob.moc \
deletejob.moc \
downloadjob.moc \
@@ -244,6 +251,7 @@ qgpgme_moc_sources = \
qgpgmechangeownertrustjob.moc \
qgpgmechangepasswdjob.moc \
qgpgmedecryptjob.moc \
+ qgpgmedecryptverifyarchivejob.moc \
qgpgmedecryptverifyjob.moc \
qgpgmedeletejob.moc \
qgpgmedownloadjob.moc \
diff --git a/lang/qt/src/decryptverifyarchivejob.cpp b/lang/qt/src/decryptverifyarchivejob.cpp
new file mode 100644
index 00000000..ebfd36ca
--- /dev/null
+++ b/lang/qt/src/decryptverifyarchivejob.cpp
@@ -0,0 +1,71 @@
+/*
+ decryptverifyarchivejob.cpp
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2023 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ 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.
+*/
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "decryptverifyarchivejob.h"
+#include "decryptverifyarchivejob_p.h"
+
+#include <engineinfo.h>
+
+using namespace QGpgME;
+
+DecryptVerifyArchiveJob::DecryptVerifyArchiveJob(QObject *parent)
+ : Job{parent}
+{
+}
+
+DecryptVerifyArchiveJob::~DecryptVerifyArchiveJob() = default;
+
+// static
+bool DecryptVerifyArchiveJob::isSupported()
+{
+ static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion();
+ return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0");
+}
+
+void DecryptVerifyArchiveJob::setOutputDirectory(const QString &outputDirectory)
+{
+ auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this);
+ d->m_outputDirectory = outputDirectory;
+}
+
+QString DecryptVerifyArchiveJob::outputDirectory() const
+{
+ auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this);
+ return d->m_outputDirectory;
+}
+
+#include "decryptverifyarchivejob.moc"
diff --git a/lang/qt/src/decryptverifyarchivejob.h b/lang/qt/src/decryptverifyarchivejob.h
new file mode 100644
index 00000000..ea922bc4
--- /dev/null
+++ b/lang/qt/src/decryptverifyarchivejob.h
@@ -0,0 +1,91 @@
+/*
+ decryptverifyarchivejob.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2023 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ 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.
+*/
+
+#ifndef __QGPGME_DECRYPTVERIFYARCHIVEJOB_H__
+#define __QGPGME_DECRYPTVERIFYARCHIVEJOB_H__
+
+#include "job.h"
+
+#ifdef BUILDING_QGPGME
+# include "context.h"
+#else
+# include <gpgme++/context.h>
+#endif
+
+namespace GpgME
+{
+class Key;
+}
+
+namespace QGpgME
+{
+
+/**
+ * Abstract base class for job for decrypting encrypted (signed) archives
+ */
+class QGPGME_EXPORT DecryptVerifyArchiveJob : public Job
+{
+ Q_OBJECT
+protected:
+ explicit DecryptVerifyArchiveJob(QObject *parent);
+public:
+ ~DecryptVerifyArchiveJob() override;
+
+ static bool isSupported();
+
+ void setOutputDirectory(const QString &outputDirectory);
+ QString outputDirectory() const;
+
+ /**
+ * Starts the decryption of an encrypted (and signed) archive.
+ *
+ * Decrypts and extracts the encrypted archive in \a cipherText. If the
+ * archive is signed, then the signature is verified.
+ * If a non-empty output directory was set, then the content of the archive
+ * is extracted into this directory. Otherwise, it is extracted into a
+ * directory named \c GPGARCH_n_ (where \c n is a number).
+ *
+ * Emits result() when the job has finished.
+ */
+ virtual GpgME::Error start(const std::shared_ptr<QIODevice> &cipherText) = 0;
+
+Q_SIGNALS:
+ void result(const GpgME::DecryptionResult &decryptionResult,
+ const GpgME::VerificationResult &verificationResult,
+ const QString &auditLogAsHtml = {},
+ const GpgME::Error &auditLogError = {});
+};
+
+}
+
+#endif // __QGPGME_DECRYPTVERIFYARCHIVEJOB_H__
diff --git a/lang/qt/src/decryptverifyarchivejob_p.h b/lang/qt/src/decryptverifyarchivejob_p.h
new file mode 100644
index 00000000..b4e66530
--- /dev/null
+++ b/lang/qt/src/decryptverifyarchivejob_p.h
@@ -0,0 +1,49 @@
+/*
+ decryptverifyarchivejob_p.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2023 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ 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.
+*/
+
+#ifndef __QGPGME_DECRYPTVERIFYARCHIVEJOB_P_H__
+#define __QGPGME_DECRYPTVERIFYARCHIVEJOB_P_H__
+
+#include "job_p.h"
+
+namespace QGpgME
+{
+
+struct DecryptVerifyArchiveJobPrivate : public JobPrivate
+{
+ QString m_outputDirectory;
+};
+
+}
+
+#endif // __QGPGME_DECRYPTVERIFYARCHIVEJOB_P_H__
diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h
index e689ba66..cbd93877 100644
--- a/lang/qt/src/protocol.h
+++ b/lang/qt/src/protocol.h
@@ -60,6 +60,7 @@ class SignKeyJob;
class VerifyDetachedJob;
class VerifyOpaqueJob;
class SignEncryptJob;
+class DecryptVerifyArchiveJob;
class DecryptVerifyJob;
class RefreshKeysJob;
class ChangeExpiryJob;
@@ -196,6 +197,7 @@ public:
virtual EncryptArchiveJob *encryptArchiveJob(bool armor = false) const = 0;
virtual SignArchiveJob *signArchiveJob(bool armor = false) const = 0;
virtual SignEncryptArchiveJob *signEncryptArchiveJob(bool armor = false) const = 0;
+ virtual DecryptVerifyArchiveJob *decryptVerifyArchiveJob() const = 0;
};
/** Obtain a reference to the OpenPGP Protocol.
diff --git a/lang/qt/src/protocol_p.h b/lang/qt/src/protocol_p.h
index a4a33acb..fcb2b30a 100644
--- a/lang/qt/src/protocol_p.h
+++ b/lang/qt/src/protocol_p.h
@@ -41,6 +41,7 @@
#include "qgpgmekeylistjob.h"
#include "qgpgmelistallkeysjob.h"
#include "qgpgmedecryptjob.h"
+#include "qgpgmedecryptverifyarchivejob.h"
#include "qgpgmedecryptverifyjob.h"
#include "qgpgmerefreshsmimekeysjob.h"
#include "qgpgmedeletejob.h"
@@ -545,6 +546,17 @@ public:
}
return nullptr;
}
+
+ QGpgME::DecryptVerifyArchiveJob *decryptVerifyArchiveJob() const override
+ {
+ if (mProtocol != GpgME::OpenPGP) {
+ return nullptr;
+ }
+ if (auto context = GpgME::Context::createForProtocol(mProtocol)) {
+ return new QGpgME::QGpgMEDecryptVerifyArchiveJob{context};
+ }
+ return nullptr;
+ }
};
}
diff --git a/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp b/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
new file mode 100644
index 00000000..2e8c89c1
--- /dev/null
+++ b/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
@@ -0,0 +1,119 @@
+/*
+ qgpgmedecryptverifyarchivejob.cpp
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
+ Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
+ Software engineering by Intevation GmbH
+ Copyright (c) 2023 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ 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.
+*/
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "qgpgmedecryptverifyarchivejob.h"
+
+#include "dataprovider.h"
+#include "decryptverifyarchivejob_p.h"
+
+#include <data.h>
+
+using namespace QGpgME;
+using namespace GpgME;
+
+namespace
+{
+
+class QGpgMEDecryptVerifyArchiveJobPrivate : public DecryptVerifyArchiveJobPrivate
+{
+ QGpgMEDecryptVerifyArchiveJob *q = nullptr;
+
+public:
+ QGpgMEDecryptVerifyArchiveJobPrivate(QGpgMEDecryptVerifyArchiveJob *qq)
+ : q{qq}
+ {
+ }
+
+ ~QGpgMEDecryptVerifyArchiveJobPrivate() override = default;
+
+private:
+ void start() override
+ {
+ q->run();
+ }
+};
+
+}
+
+QGpgMEDecryptVerifyArchiveJob::QGpgMEDecryptVerifyArchiveJob(Context *context)
+ : mixin_type{context}
+{
+ setJobPrivate(this, std::unique_ptr<QGpgMEDecryptVerifyArchiveJobPrivate>{new QGpgMEDecryptVerifyArchiveJobPrivate{this}});
+ lateInitialization();
+}
+
+static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify(Context *ctx,
+ QThread *thread,
+ const std::weak_ptr<QIODevice> &cipherText_,
+ const QString &outputDirectory)
+{
+ const std::shared_ptr<QIODevice> cipherText = cipherText_.lock();
+ const _detail::ToThreadMover ctMover(cipherText, thread);
+
+ QGpgME::QIODeviceDataProvider in{cipherText};
+ Data indata(&in);
+
+ Data outdata;
+ if (!outputDirectory.isEmpty()) {
+ outdata.setFileName(outputDirectory.toStdString());
+ }
+
+ const auto res = ctx->decryptAndVerify(indata, outdata, Context::DecryptArchive);
+ Error ae;
+ const QString log = _detail::audit_log_as_html(ctx, ae);
+ return std::make_tuple(res.first, res.second, log, ae);
+}
+
+GpgME::Error QGpgMEDecryptVerifyArchiveJob::start(const std::shared_ptr<QIODevice> &cipherText)
+{
+ if (!cipherText) {
+ return Error::fromCode(GPG_ERR_INV_VALUE);
+ }
+
+ run(std::bind(&decrypt_verify,
+ std::placeholders::_1,
+ std::placeholders::_2,
+ std::placeholders::_3,
+ outputDirectory()),
+ cipherText);
+ return {};
+}
+
+#include "qgpgmedecryptverifyarchivejob.moc"
diff --git a/lang/qt/src/qgpgmedecryptverifyarchivejob.h b/lang/qt/src/qgpgmedecryptverifyarchivejob.h
new file mode 100644
index 00000000..b43be070
--- /dev/null
+++ b/lang/qt/src/qgpgmedecryptverifyarchivejob.h
@@ -0,0 +1,68 @@
+/*
+ qgpgmedecryptverifyarchivejob.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2023 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ 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.
+*/
+
+#ifndef __QGPGME_QGPGMEDECRYPTVERIFYARCHIVEJOB_H__
+#define __QGPGME_QGPGMEDECRYPTVERIFYARCHIVEJOB_H__
+
+#include "decryptverifyarchivejob.h"
+
+#include "threadedjobmixin.h"
+
+#include <decryptionresult.h>
+#include <verificationresult.h>
+
+namespace QGpgME
+{
+
+class QGpgMEDecryptVerifyArchiveJob
+#ifdef Q_MOC_RUN
+ : public DecryptVerifyArchiveJob
+#else
+ : public _detail::ThreadedJobMixin<DecryptVerifyArchiveJob, std::tuple<GpgME::DecryptionResult, GpgME::VerificationResult, QString, GpgME::Error>>
+#endif
+{
+ Q_OBJECT
+#ifdef Q_MOC_RUN
+public Q_SLOTS:
+ void slotFinished();
+#endif
+public:
+ explicit QGpgMEDecryptVerifyArchiveJob(GpgME::Context *context);
+ ~QGpgMEDecryptVerifyArchiveJob() = default;
+
+ GpgME::Error start(const std::shared_ptr<QIODevice> &cipherText) override;
+};
+
+}
+
+#endif // __QGPGME_QGPGMEDECRYPTVERIFYARCHIVEJOB_H__