diff options
Diffstat (limited to 'lang/qt/src')
-rw-r--r-- | lang/qt/src/decryptverifyarchivejob.cpp | 12 | ||||
-rw-r--r-- | lang/qt/src/decryptverifyarchivejob.h | 14 | ||||
-rw-r--r-- | lang/qt/src/decryptverifyarchivejob_p.h | 1 | ||||
-rw-r--r-- | lang/qt/src/decryptverifyjob.cpp | 12 | ||||
-rw-r--r-- | lang/qt/src/decryptverifyjob.h | 14 | ||||
-rw-r--r-- | lang/qt/src/decryptverifyjob_p.h | 1 | ||||
-rw-r--r-- | lang/qt/src/qgpgmedecryptverifyarchivejob.cpp | 11 | ||||
-rw-r--r-- | lang/qt/src/qgpgmedecryptverifyjob.cpp | 17 | ||||
-rw-r--r-- | lang/qt/src/qgpgmeverifydetachedjob.cpp | 17 | ||||
-rw-r--r-- | lang/qt/src/qgpgmeverifyopaquejob.cpp | 17 | ||||
-rw-r--r-- | lang/qt/src/verifydetachedjob.cpp | 12 | ||||
-rw-r--r-- | lang/qt/src/verifydetachedjob.h | 14 | ||||
-rw-r--r-- | lang/qt/src/verifydetachedjob_p.h | 1 | ||||
-rw-r--r-- | lang/qt/src/verifyopaquejob.cpp | 12 | ||||
-rw-r--r-- | lang/qt/src/verifyopaquejob.h | 14 | ||||
-rw-r--r-- | lang/qt/src/verifyopaquejob_p.h | 1 |
16 files changed, 162 insertions, 8 deletions
diff --git a/lang/qt/src/decryptverifyarchivejob.cpp b/lang/qt/src/decryptverifyarchivejob.cpp index b1699c3d..d427e1fd 100644 --- a/lang/qt/src/decryptverifyarchivejob.cpp +++ b/lang/qt/src/decryptverifyarchivejob.cpp @@ -56,6 +56,18 @@ bool DecryptVerifyArchiveJob::isSupported() return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); } +void DecryptVerifyArchiveJob::setProcessAllSignatures (bool processAll) +{ + auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); + d->m_processAllSignatures = processAll; +} + +bool DecryptVerifyArchiveJob::processAllSignatures() const +{ + auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); + return d->m_processAllSignatures; +} + void DecryptVerifyArchiveJob::setInputFile(const QString &path) { auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); diff --git a/lang/qt/src/decryptverifyarchivejob.h b/lang/qt/src/decryptverifyarchivejob.h index f80170c5..3139ae66 100644 --- a/lang/qt/src/decryptverifyarchivejob.h +++ b/lang/qt/src/decryptverifyarchivejob.h @@ -60,6 +60,20 @@ public: static bool isSupported(); /** + * Enables processing of all signatures if \a processAll is true. + * + * By default, gpg (in batch mode used by GpgME) stops the verification of + * data signatures when a bad signature is encountered. This can be changed + * by setting this flag. It's equivalent to setting the context flag + * "proc-all-sigs". + * + * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or + * 2.5.1. + */ + void setProcessAllSignatures(bool processAll); + bool processAllSignatures() const; + + /** * Sets the path of the file to read the archive from. * * Used if the job is started with startIt(). diff --git a/lang/qt/src/decryptverifyarchivejob_p.h b/lang/qt/src/decryptverifyarchivejob_p.h index e0823d23..bce093db 100644 --- a/lang/qt/src/decryptverifyarchivejob_p.h +++ b/lang/qt/src/decryptverifyarchivejob_p.h @@ -43,6 +43,7 @@ struct DecryptVerifyArchiveJobPrivate : public JobPrivate { QString m_inputFilePath; QString m_outputDirectory; + bool m_processAllSignatures = false; }; } diff --git a/lang/qt/src/decryptverifyjob.cpp b/lang/qt/src/decryptverifyjob.cpp index f369f1d5..f96305b9 100644 --- a/lang/qt/src/decryptverifyjob.cpp +++ b/lang/qt/src/decryptverifyjob.cpp @@ -47,6 +47,18 @@ DecryptVerifyJob::DecryptVerifyJob(QObject *parent) DecryptVerifyJob::~DecryptVerifyJob() = default; +void DecryptVerifyJob::setProcessAllSignatures (bool processAll) +{ + auto d = jobPrivate<DecryptVerifyJobPrivate>(this); + d->m_processAllSignatures = processAll; +} + +bool DecryptVerifyJob::processAllSignatures() const +{ + auto d = jobPrivate<DecryptVerifyJobPrivate>(this); + return d->m_processAllSignatures; +} + void DecryptVerifyJob::setInputFile(const QString &path) { auto d = jobPrivate<DecryptVerifyJobPrivate>(this); diff --git a/lang/qt/src/decryptverifyjob.h b/lang/qt/src/decryptverifyjob.h index 710fc80e..73dbea15 100644 --- a/lang/qt/src/decryptverifyjob.h +++ b/lang/qt/src/decryptverifyjob.h @@ -82,6 +82,20 @@ public: ~DecryptVerifyJob() override; /** + * Enables processing of all signatures if \a processAll is true. + * + * By default, gpg (in batch mode used by GpgME) stops the verification of + * data signatures when a bad signature is encountered. This can be changed + * by setting this flag. It's equivalent to setting the context flag + * "proc-all-sigs". + * + * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or + * 2.5.1. + */ + void setProcessAllSignatures(bool processAll); + bool processAllSignatures() const; + + /** * Sets the path of the file to decrypt (and verify). * * Used if the job is started with startIt(). diff --git a/lang/qt/src/decryptverifyjob_p.h b/lang/qt/src/decryptverifyjob_p.h index bbd30b59..10701da1 100644 --- a/lang/qt/src/decryptverifyjob_p.h +++ b/lang/qt/src/decryptverifyjob_p.h @@ -43,6 +43,7 @@ struct DecryptVerifyJobPrivate : public JobPrivate { QString m_inputFilePath; QString m_outputFilePath; + bool m_processAllSignatures = false; }; } diff --git a/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp b/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp index eda4bfd8..10f07e53 100644 --- a/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp +++ b/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp @@ -119,7 +119,8 @@ static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_io_device( static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_file_name(Context *ctx, const QString &inputFile, - const QString &outputDirectory) + const QString &outputDirectory, + bool processAllSignatures) { Data indata; #ifdef Q_OS_WIN @@ -128,6 +129,9 @@ static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_file_name( indata.setFileName(QFile::encodeName(inputFile).constData()); #endif + if (processAllSignatures) { + ctx->setFlag("proc-all-sigs", "1"); + } return decrypt_verify(ctx, indata, outputDirectory); } @@ -137,6 +141,9 @@ GpgME::Error QGpgMEDecryptVerifyArchiveJob::start(const std::shared_ptr<QIODevic return Error::fromCode(GPG_ERR_INV_VALUE); } + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } run(std::bind(&decrypt_verify_from_io_device, std::placeholders::_1, std::placeholders::_2, @@ -153,7 +160,7 @@ GpgME::Error QGpgMEDecryptVerifyArchiveJobPrivate::startIt() } q->run([=](Context *ctx) { - return decrypt_verify_from_file_name(ctx, m_inputFilePath, m_outputDirectory); + return decrypt_verify_from_file_name(ctx, m_inputFilePath, m_outputDirectory, m_processAllSignatures); }); return {}; diff --git a/lang/qt/src/qgpgmedecryptverifyjob.cpp b/lang/qt/src/qgpgmedecryptverifyjob.cpp index 24930693..e8d2ad4e 100644 --- a/lang/qt/src/qgpgmedecryptverifyjob.cpp +++ b/lang/qt/src/qgpgmedecryptverifyjob.cpp @@ -145,7 +145,8 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify_qba(Context *ctx, cons static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context *ctx, const QString &inputFilePath, - const QString &outputFilePath) + const QString &outputFilePath, + bool processAllSignatures) { Data indata; #ifdef Q_OS_WIN @@ -166,6 +167,9 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); #endif + if (processAllSignatures) { + ctx->setFlag("proc-all-sigs", "1"); + } const auto results = ctx->decryptAndVerify(indata, outdata); const auto &decryptionResult = results.first; const auto &verificationResult = results.second; @@ -182,18 +186,27 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context Error QGpgMEDecryptVerifyJob::start(const QByteArray &cipherText) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } run(std::bind(&decrypt_verify_qba, std::placeholders::_1, cipherText)); return Error(); } void QGpgMEDecryptVerifyJob::start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } run(std::bind(&decrypt_verify, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), cipherText, plainText); } std::pair<GpgME::DecryptionResult, GpgME::VerificationResult> QGpgME::QGpgMEDecryptVerifyJob::exec(const QByteArray &cipherText, QByteArray &plainText) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } const result_type r = decrypt_verify_qba(context(), cipherText); plainText = std::get<2>(r); return std::make_pair(std::get<0>(r), std::get<1>(r)); @@ -206,7 +219,7 @@ GpgME::Error QGpgMEDecryptVerifyJobPrivate::startIt() } q->run([=](Context *ctx) { - return decrypt_verify_from_filename(ctx, m_inputFilePath, m_outputFilePath); + return decrypt_verify_from_filename(ctx, m_inputFilePath, m_outputFilePath, m_processAllSignatures); }); return {}; diff --git a/lang/qt/src/qgpgmeverifydetachedjob.cpp b/lang/qt/src/qgpgmeverifydetachedjob.cpp index 1f6e47cd..91d89f96 100644 --- a/lang/qt/src/qgpgmeverifydetachedjob.cpp +++ b/lang/qt/src/qgpgmeverifydetachedjob.cpp @@ -131,7 +131,8 @@ static QGpgMEVerifyDetachedJob::result_type verify_detached_qba(Context *ctx, co static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx, const QString &signatureFilePath, - const QString &signedFilePath) + const QString &signedFilePath, + bool processAllSignatures) { Data signatureData; #ifdef Q_OS_WIN @@ -147,6 +148,9 @@ static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx, signedData.setFileName(QFile::encodeName(signedFilePath).constData()); #endif + if (processAllSignatures) { + ctx->setFlag("proc-all-sigs", "1"); + } const auto verificationResult = ctx->verifyDetachedSignature(signatureData, signedData); Error ae; @@ -156,18 +160,27 @@ static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx, Error QGpgMEVerifyDetachedJob::start(const QByteArray &signature, const QByteArray &signedData) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } run(std::bind(&verify_detached_qba, std::placeholders::_1, signature, signedData)); return Error(); } void QGpgMEVerifyDetachedJob::start(const std::shared_ptr<QIODevice> &signature, const std::shared_ptr<QIODevice> &signedData) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } run(std::bind(&verify_detached, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), signature, signedData); } GpgME::VerificationResult QGpgME::QGpgMEVerifyDetachedJob::exec(const QByteArray &signature, const QByteArray &signedData) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } const result_type r = verify_detached_qba(context(), signature, signedData); return std::get<0>(r); } @@ -179,7 +192,7 @@ GpgME::Error QGpgMEVerifyDetachedJobPrivate::startIt() } q->run([=](Context *ctx) { - return verify_from_filename(ctx, m_signatureFilePath, m_signedFilePath); + return verify_from_filename(ctx, m_signatureFilePath, m_signedFilePath, m_processAllSignatures); }); return {}; diff --git a/lang/qt/src/qgpgmeverifyopaquejob.cpp b/lang/qt/src/qgpgmeverifyopaquejob.cpp index 19e61e37..0cca9f72 100644 --- a/lang/qt/src/qgpgmeverifyopaquejob.cpp +++ b/lang/qt/src/qgpgmeverifyopaquejob.cpp @@ -136,7 +136,8 @@ static QGpgMEVerifyOpaqueJob::result_type verify_opaque_qba(Context *ctx, const static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx, const QString &inputFilePath, - const QString &outputFilePath) + const QString &outputFilePath, + bool processAllSignatures) { Data indata; #ifdef Q_OS_WIN @@ -157,6 +158,9 @@ static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx, outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); #endif + if (processAllSignatures) { + ctx->setFlag("proc-all-sigs", "1"); + } const auto verificationResult = ctx->verifyOpaqueSignature(indata, outdata); if (!verificationResult.error().code()) { @@ -171,17 +175,26 @@ static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx, Error QGpgMEVerifyOpaqueJob::start(const QByteArray &signedData) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } run(std::bind(&verify_opaque_qba, std::placeholders::_1, signedData)); return Error(); } void QGpgMEVerifyOpaqueJob::start(const std::shared_ptr<QIODevice> &signedData, const std::shared_ptr<QIODevice> &plainText) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } run(std::bind(&verify_opaque, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), signedData, plainText); } GpgME::VerificationResult QGpgME::QGpgMEVerifyOpaqueJob::exec(const QByteArray &signedData, QByteArray &plainText) { + if (processAllSignatures()) { + context()->setFlag("proc-all-sigs", "1"); + } const result_type r = verify_opaque_qba(context(), signedData); plainText = std::get<1>(r); return std::get<0>(r); @@ -194,7 +207,7 @@ GpgME::Error QGpgMEVerifyOpaqueJobPrivate::startIt() } q->run([=](Context *ctx) { - return verify_from_filename(ctx, m_inputFilePath, m_outputFilePath); + return verify_from_filename(ctx, m_inputFilePath, m_outputFilePath, m_processAllSignatures); }); return {}; diff --git a/lang/qt/src/verifydetachedjob.cpp b/lang/qt/src/verifydetachedjob.cpp index 11e630c1..68fe7f21 100644 --- a/lang/qt/src/verifydetachedjob.cpp +++ b/lang/qt/src/verifydetachedjob.cpp @@ -47,6 +47,18 @@ VerifyDetachedJob::VerifyDetachedJob(QObject *parent) VerifyDetachedJob::~VerifyDetachedJob() = default; +void VerifyDetachedJob::setProcessAllSignatures (bool processAll) +{ + auto d = jobPrivate<VerifyDetachedJobPrivate>(this); + d->m_processAllSignatures = processAll; +} + +bool VerifyDetachedJob::processAllSignatures() const +{ + auto d = jobPrivate<VerifyDetachedJobPrivate>(this); + return d->m_processAllSignatures; +} + void VerifyDetachedJob::setSignatureFile(const QString &path) { auto d = jobPrivate<VerifyDetachedJobPrivate>(this); diff --git a/lang/qt/src/verifydetachedjob.h b/lang/qt/src/verifydetachedjob.h index c8c516bf..b5b668e3 100644 --- a/lang/qt/src/verifydetachedjob.h +++ b/lang/qt/src/verifydetachedjob.h @@ -79,6 +79,20 @@ public: ~VerifyDetachedJob() override; /** + * Enables processing of all signatures if \a processAll is true. + * + * By default, gpg (in batch mode used by GpgME) stops the verification of + * data signatures when a bad signature is encountered. This can be changed + * by setting this flag. It's equivalent to setting the context flag + * "proc-all-sigs". + * + * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or + * 2.5.1. + */ + void setProcessAllSignatures(bool processAll); + bool processAllSignatures() const; + + /** * Sets the path of the file containing the signature to verify. * * Used if the job is started with startIt(). diff --git a/lang/qt/src/verifydetachedjob_p.h b/lang/qt/src/verifydetachedjob_p.h index 1fedc8fb..cc594210 100644 --- a/lang/qt/src/verifydetachedjob_p.h +++ b/lang/qt/src/verifydetachedjob_p.h @@ -43,6 +43,7 @@ struct VerifyDetachedJobPrivate : public JobPrivate { QString m_signatureFilePath; QString m_signedFilePath; + bool m_processAllSignatures = false; }; } diff --git a/lang/qt/src/verifyopaquejob.cpp b/lang/qt/src/verifyopaquejob.cpp index 1ae8e75b..dced4595 100644 --- a/lang/qt/src/verifyopaquejob.cpp +++ b/lang/qt/src/verifyopaquejob.cpp @@ -47,6 +47,18 @@ VerifyOpaqueJob::VerifyOpaqueJob(QObject *parent) VerifyOpaqueJob::~VerifyOpaqueJob() = default; +void VerifyOpaqueJob::setProcessAllSignatures (bool processAll) +{ + auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); + d->m_processAllSignatures = processAll; +} + +bool VerifyOpaqueJob::processAllSignatures() const +{ + auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); + return d->m_processAllSignatures; +} + void VerifyOpaqueJob::setInputFile(const QString &path) { auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); diff --git a/lang/qt/src/verifyopaquejob.h b/lang/qt/src/verifyopaquejob.h index 8dd73141..e006886b 100644 --- a/lang/qt/src/verifyopaquejob.h +++ b/lang/qt/src/verifyopaquejob.h @@ -81,6 +81,20 @@ public: ~VerifyOpaqueJob() override; /** + * Enables processing of all signatures if \a processAll is true. + * + * By default, gpg (in batch mode used by GpgME) stops the verification of + * data signatures when a bad signature is encountered. This can be changed + * by setting this flag. It's equivalent to setting the context flag + * "proc-all-sigs". + * + * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or + * 2.5.1. + */ + void setProcessAllSignatures(bool processAll); + bool processAllSignatures() const; + + /** * Sets the path of the file to verify. * * Used if the job is started with startIt(). diff --git a/lang/qt/src/verifyopaquejob_p.h b/lang/qt/src/verifyopaquejob_p.h index 3dce6dec..9686f01c 100644 --- a/lang/qt/src/verifyopaquejob_p.h +++ b/lang/qt/src/verifyopaquejob_p.h @@ -43,6 +43,7 @@ struct VerifyOpaqueJobPrivate : public JobPrivate { QString m_inputFilePath; QString m_outputFilePath; + bool m_processAllSignatures = false; }; } |