qt: Add support for new context flag "proc-all-sigs"

* lang/qt/src/decryptverifyarchivejob.cpp,
lang/qt/src/decryptverifyarchivejob.h (DecryptVerifyArchiveJob): Add
member functions setProcessAllSignatures, processAllSignatures.
* lang/qt/src/decryptverifyarchivejob_p.h
(DecryptVerifyArchiveJobPrivate): Add member m_processAllSignatures.
* lang/qt/src/decryptverifyjob.cpp, lang/qt/src/decryptverifyjob.h
(DecryptVerifyJob): Add member functions setProcessAllSignatures,
processAllSignatures.
* lang/qt/src/decryptverifyjob_p.h (DecryptVerifyJobPrivate): Add member
m_processAllSignatures.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(decrypt_verify_from_file_name): Add argument "processAllSignatures".
Set context flag "proc-all-sigs" if requested.
(QGpgMEDecryptVerifyArchiveJob::start): Set context flag "proc-all-sigs"
if requested.
(QGpgMEDecryptVerifyArchiveJobPrivate::startIt): Pass
m_processAllSignatures to decrypt_verify_from_file_name.
* lang/qt/src/qgpgmedecryptverifyjob.cpp
(decrypt_verify_from_filename): Add argument "processAllSignatures".
Set context flag "proc-all-sigs" if requested.
(QGpgMEDecryptVerifyJob::start, QGpgMEDecryptVerifyJob::exec): Set
context flag "proc-all-sigs" if requested.
(QGpgMEDecryptVerifyJobPrivate::startIt): Pass
m_processAllSignatures to decrypt_verify_from_filename.
* lang/qt/src/qgpgmeverifydetachedjob.cpp (verify_from_filename): Add
argument "processAllSignatures". Set context flag "proc-all-sigs" if
requested.
(QGpgMEVerifyDetachedJob::start, QGpgMEVerifyDetachedJob::exec): Set
context flag "proc-all-sigs" if requested.
(QGpgMEVerifyDetachedJobPrivate::startIt): Pass
m_processAllSignatures to decrypt_verify_from_filename.
* lang/qt/src/qgpgmeverifyopaquejob.cpp (verify_from_filename): Add
argument "processAllSignatures". Set context flag "proc-all-sigs" if
requested.
(QGpgMEVerifyOpaqueJob::start, QGpgMEVerifyOpaqueJob::exec): Set
context flag "proc-all-sigs" if requested.
(QGpgMEVerifyOpaqueJobPrivate::startIt): Pass
m_processAllSignatures to decrypt_verify_from_filename.
* lang/qt/src/verifydetachedjob.cpp, lang/qt/src/verifydetachedjob.h
(VerifyDetachedJob): Add member functions setProcessAllSignatures,
processAllSignatures.
* lang/qt/src/verifydetachedjob_p.h (VerifyDetachedJobPrivate): Add
member m_processAllSignatures.
* lang/qt/src/verifyopaquejob.cpp, lang/qt/src/verifyopaquejob.h
(VerifyOpaqueJob): Add member functions setProcessAllSignatures,
processAllSignatures.
* lang/qt/src/verifyopaquejob_p.h (VerifyOpaqueJobPrivate): Add
member m_processAllSignatures.

* lang/qt/tests/run-decryptverifyarchivejob.cpp,
lang/qt/tests/run-decryptverifyjob.cpp,
lang/qt/tests/run-verifydetachedjob.cpp,
lang/qt/tests/run-verifyopaquejob.cpp (struct CommandLineOptions): Add
member processAllSignatures.
(parseCommandLine): Add command line option --process-all-signatures.
(main): Pass new option to the job.
--

The new option processAllSignatures is added to all jobs that verify
data signatures. By enabling this option, one can tell gpg not to stop
checking signatures after the first bad signature.

GnuPG-bug-id: 6870
This commit is contained in:
Ingo Klöcker 2024-08-26 12:45:08 +02:00
parent 37aa9eee7c
commit 409e314582
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
21 changed files with 191 additions and 8 deletions

11
NEWS
View File

@ -42,6 +42,9 @@ Noteworthy changes in version 1.24.0 (unrelease)
* qt: Add support for enabling and disabling keys. [T7239] * qt: Add support for enabling and disabling keys. [T7239]
* qt: Add support for new context flag "proc-all-sigs" to the jobs that
verify data signatures.
* Interface changes relative to the 1.23.2 release: * Interface changes relative to the 1.23.2 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GPGME_ENCRYPT_FILE NEW. GPGME_ENCRYPT_FILE NEW.
@ -63,10 +66,14 @@ Noteworthy changes in version 1.24.0 (unrelease)
cpp: Key::revocationKeys NEW. cpp: Key::revocationKeys NEW.
cpp: Error::asStdString NEW. cpp: Error::asStdString NEW.
cpp: Error::asString DEPRECATED. cpp: Error::asString DEPRECATED.
qt: DecryptVerifyArchiveJob::setProcessAllSignatures NEW.
qt: DecryptVerifyArchiveJob::processAllSignatures NEW.
qt: DecryptVerifyJob::setInputFile NEW. qt: DecryptVerifyJob::setInputFile NEW.
qt: DecryptVerifyJob::inputFile NEW. qt: DecryptVerifyJob::inputFile NEW.
qt: DecryptVerifyJob::setOutputFile NEW. qt: DecryptVerifyJob::setOutputFile NEW.
qt: DecryptVerifyJob::outputFile NEW. qt: DecryptVerifyJob::outputFile NEW.
qt: DecryptVerifyJob::setProcessAllSignatures NEW.
qt: DecryptVerifyJob::processAllSignatures NEW.
qt: EncryptJob::setRecipients NEW. qt: EncryptJob::setRecipients NEW.
qt: EncryptJob::recipients NEW. qt: EncryptJob::recipients NEW.
qt: EncryptJob::setInputFile NEW. qt: EncryptJob::setInputFile NEW.
@ -99,10 +106,14 @@ Noteworthy changes in version 1.24.0 (unrelease)
qt: VerifyDetachedJob::signatureFile NEW. qt: VerifyDetachedJob::signatureFile NEW.
qt: VerifyDetachedJob::setSignedFile NEW. qt: VerifyDetachedJob::setSignedFile NEW.
qt: VerifyDetachedJob::signedFile NEW. qt: VerifyDetachedJob::signedFile NEW.
qt: VerifyDetachedJob::setProcessAllSignatures NEW.
qt: VerifyDetachedJob::processAllSignatures NEW.
qt: VerifyOpaqueJob::setInputFile NEW. qt: VerifyOpaqueJob::setInputFile NEW.
qt: VerifyOpaqueJob::inputFile NEW. qt: VerifyOpaqueJob::inputFile NEW.
qt: VerifyOpaqueJob::setOutputFile NEW. qt: VerifyOpaqueJob::setOutputFile NEW.
qt: VerifyOpaqueJob::outputFile NEW. qt: VerifyOpaqueJob::outputFile NEW.
qt: VerifyOpaqueJob::setProcessAllSignatures NEW.
qt: VerifyOpaqueJob::processAllSignatures NEW.
qt: ImportJob::setImportOptions NEW. qt: ImportJob::setImportOptions NEW.
qt: ImportJob::importOptions NEW. qt: ImportJob::importOptions NEW.
qt: QuickJob::startSetKeyEnabled NEW. qt: QuickJob::startSetKeyEnabled NEW.

View File

@ -56,6 +56,18 @@ bool DecryptVerifyArchiveJob::isSupported()
return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); 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) void DecryptVerifyArchiveJob::setInputFile(const QString &path)
{ {
auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this);

View File

@ -59,6 +59,20 @@ public:
static bool isSupported(); 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. * Sets the path of the file to read the archive from.
* *

View File

@ -43,6 +43,7 @@ struct DecryptVerifyArchiveJobPrivate : public JobPrivate
{ {
QString m_inputFilePath; QString m_inputFilePath;
QString m_outputDirectory; QString m_outputDirectory;
bool m_processAllSignatures = false;
}; };
} }

View File

@ -47,6 +47,18 @@ DecryptVerifyJob::DecryptVerifyJob(QObject *parent)
DecryptVerifyJob::~DecryptVerifyJob() = default; 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) void DecryptVerifyJob::setInputFile(const QString &path)
{ {
auto d = jobPrivate<DecryptVerifyJobPrivate>(this); auto d = jobPrivate<DecryptVerifyJobPrivate>(this);

View File

@ -81,6 +81,20 @@ protected:
public: public:
~DecryptVerifyJob() override; ~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). * Sets the path of the file to decrypt (and verify).
* *

View File

@ -43,6 +43,7 @@ struct DecryptVerifyJobPrivate : public JobPrivate
{ {
QString m_inputFilePath; QString m_inputFilePath;
QString m_outputFilePath; QString m_outputFilePath;
bool m_processAllSignatures = false;
}; };
} }

View File

@ -119,7 +119,8 @@ static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_io_device(
static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_file_name(Context *ctx, static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_file_name(Context *ctx,
const QString &inputFile, const QString &inputFile,
const QString &outputDirectory) const QString &outputDirectory,
bool processAllSignatures)
{ {
Data indata; Data indata;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -128,6 +129,9 @@ static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_file_name(
indata.setFileName(QFile::encodeName(inputFile).constData()); indata.setFileName(QFile::encodeName(inputFile).constData());
#endif #endif
if (processAllSignatures) {
ctx->setFlag("proc-all-sigs", "1");
}
return decrypt_verify(ctx, indata, outputDirectory); 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); return Error::fromCode(GPG_ERR_INV_VALUE);
} }
if (processAllSignatures()) {
context()->setFlag("proc-all-sigs", "1");
}
run(std::bind(&decrypt_verify_from_io_device, run(std::bind(&decrypt_verify_from_io_device,
std::placeholders::_1, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_2,
@ -153,7 +160,7 @@ GpgME::Error QGpgMEDecryptVerifyArchiveJobPrivate::startIt()
} }
q->run([=](Context *ctx) { 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 {}; return {};

View File

@ -145,7 +145,8 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify_qba(Context *ctx, cons
static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context *ctx, static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context *ctx,
const QString &inputFilePath, const QString &inputFilePath,
const QString &outputFilePath) const QString &outputFilePath,
bool processAllSignatures)
{ {
Data indata; Data indata;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -166,6 +167,9 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context
outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData());
#endif #endif
if (processAllSignatures) {
ctx->setFlag("proc-all-sigs", "1");
}
const auto results = ctx->decryptAndVerify(indata, outdata); const auto results = ctx->decryptAndVerify(indata, outdata);
const auto &decryptionResult = results.first; const auto &decryptionResult = results.first;
const auto &verificationResult = results.second; const auto &verificationResult = results.second;
@ -182,18 +186,27 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context
Error QGpgMEDecryptVerifyJob::start(const QByteArray &cipherText) Error QGpgMEDecryptVerifyJob::start(const QByteArray &cipherText)
{ {
if (processAllSignatures()) {
context()->setFlag("proc-all-sigs", "1");
}
run(std::bind(&decrypt_verify_qba, std::placeholders::_1, cipherText)); run(std::bind(&decrypt_verify_qba, std::placeholders::_1, cipherText));
return Error(); return Error();
} }
void QGpgMEDecryptVerifyJob::start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText) 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); 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> std::pair<GpgME::DecryptionResult, GpgME::VerificationResult>
QGpgME::QGpgMEDecryptVerifyJob::exec(const QByteArray &cipherText, QByteArray &plainText) 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); const result_type r = decrypt_verify_qba(context(), cipherText);
plainText = std::get<2>(r); plainText = std::get<2>(r);
return std::make_pair(std::get<0>(r), std::get<1>(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) { 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 {}; return {};

View File

@ -131,7 +131,8 @@ static QGpgMEVerifyDetachedJob::result_type verify_detached_qba(Context *ctx, co
static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx, static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx,
const QString &signatureFilePath, const QString &signatureFilePath,
const QString &signedFilePath) const QString &signedFilePath,
bool processAllSignatures)
{ {
Data signatureData; Data signatureData;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -147,6 +148,9 @@ static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx,
signedData.setFileName(QFile::encodeName(signedFilePath).constData()); signedData.setFileName(QFile::encodeName(signedFilePath).constData());
#endif #endif
if (processAllSignatures) {
ctx->setFlag("proc-all-sigs", "1");
}
const auto verificationResult = ctx->verifyDetachedSignature(signatureData, signedData); const auto verificationResult = ctx->verifyDetachedSignature(signatureData, signedData);
Error ae; Error ae;
@ -156,18 +160,27 @@ static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx,
Error QGpgMEVerifyDetachedJob::start(const QByteArray &signature, const QByteArray &signedData) 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)); run(std::bind(&verify_detached_qba, std::placeholders::_1, signature, signedData));
return Error(); return Error();
} }
void QGpgMEVerifyDetachedJob::start(const std::shared_ptr<QIODevice> &signature, const std::shared_ptr<QIODevice> &signedData) 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); 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, GpgME::VerificationResult QGpgME::QGpgMEVerifyDetachedJob::exec(const QByteArray &signature,
const QByteArray &signedData) const QByteArray &signedData)
{ {
if (processAllSignatures()) {
context()->setFlag("proc-all-sigs", "1");
}
const result_type r = verify_detached_qba(context(), signature, signedData); const result_type r = verify_detached_qba(context(), signature, signedData);
return std::get<0>(r); return std::get<0>(r);
} }
@ -179,7 +192,7 @@ GpgME::Error QGpgMEVerifyDetachedJobPrivate::startIt()
} }
q->run([=](Context *ctx) { 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 {}; return {};

View File

@ -136,7 +136,8 @@ static QGpgMEVerifyOpaqueJob::result_type verify_opaque_qba(Context *ctx, const
static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx, static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx,
const QString &inputFilePath, const QString &inputFilePath,
const QString &outputFilePath) const QString &outputFilePath,
bool processAllSignatures)
{ {
Data indata; Data indata;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -157,6 +158,9 @@ static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx,
outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData());
#endif #endif
if (processAllSignatures) {
ctx->setFlag("proc-all-sigs", "1");
}
const auto verificationResult = ctx->verifyOpaqueSignature(indata, outdata); const auto verificationResult = ctx->verifyOpaqueSignature(indata, outdata);
if (!verificationResult.error().code()) { if (!verificationResult.error().code()) {
@ -171,17 +175,26 @@ static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx,
Error QGpgMEVerifyOpaqueJob::start(const QByteArray &signedData) Error QGpgMEVerifyOpaqueJob::start(const QByteArray &signedData)
{ {
if (processAllSignatures()) {
context()->setFlag("proc-all-sigs", "1");
}
run(std::bind(&verify_opaque_qba, std::placeholders::_1, signedData)); run(std::bind(&verify_opaque_qba, std::placeholders::_1, signedData));
return Error(); return Error();
} }
void QGpgMEVerifyOpaqueJob::start(const std::shared_ptr<QIODevice> &signedData, const std::shared_ptr<QIODevice> &plainText) 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); 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) 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); const result_type r = verify_opaque_qba(context(), signedData);
plainText = std::get<1>(r); plainText = std::get<1>(r);
return std::get<0>(r); return std::get<0>(r);
@ -194,7 +207,7 @@ GpgME::Error QGpgMEVerifyOpaqueJobPrivate::startIt()
} }
q->run([=](Context *ctx) { 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 {}; return {};

View File

@ -47,6 +47,18 @@ VerifyDetachedJob::VerifyDetachedJob(QObject *parent)
VerifyDetachedJob::~VerifyDetachedJob() = default; 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) void VerifyDetachedJob::setSignatureFile(const QString &path)
{ {
auto d = jobPrivate<VerifyDetachedJobPrivate>(this); auto d = jobPrivate<VerifyDetachedJobPrivate>(this);

View File

@ -78,6 +78,20 @@ protected:
public: public:
~VerifyDetachedJob() override; ~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. * Sets the path of the file containing the signature to verify.
* *

View File

@ -43,6 +43,7 @@ struct VerifyDetachedJobPrivate : public JobPrivate
{ {
QString m_signatureFilePath; QString m_signatureFilePath;
QString m_signedFilePath; QString m_signedFilePath;
bool m_processAllSignatures = false;
}; };
} }

View File

@ -47,6 +47,18 @@ VerifyOpaqueJob::VerifyOpaqueJob(QObject *parent)
VerifyOpaqueJob::~VerifyOpaqueJob() = default; 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) void VerifyOpaqueJob::setInputFile(const QString &path)
{ {
auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); auto d = jobPrivate<VerifyOpaqueJobPrivate>(this);

View File

@ -80,6 +80,20 @@ protected:
public: public:
~VerifyOpaqueJob() override; ~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. * Sets the path of the file to verify.
* *

View File

@ -43,6 +43,7 @@ struct VerifyOpaqueJobPrivate : public JobPrivate
{ {
QString m_inputFilePath; QString m_inputFilePath;
QString m_outputFilePath; QString m_outputFilePath;
bool m_processAllSignatures = false;
}; };
} }

View File

@ -56,6 +56,7 @@ std::ostream &operator<<(std::ostream &os, const QString &s)
} }
struct CommandLineOptions { struct CommandLineOptions {
bool processAllSignatures = false;
QString outputDirectory; QString outputDirectory;
QString archiveName; QString archiveName;
}; };
@ -69,6 +70,7 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
parser.addHelpOption(); parser.addHelpOption();
parser.addOptions({ parser.addOptions({
{{"C", "directory"}, "Extract the files into the directory DIRECTORY.", "DIRECTORY"}, {{"C", "directory"}, "Extract the files into the directory DIRECTORY.", "DIRECTORY"},
{"process-all-signatures", "Don't stop signature checking after bad signature."},
}); });
parser.addPositionalArgument("archive", "The archive to decrypt and extract"); parser.addPositionalArgument("archive", "The archive to decrypt and extract");
@ -79,6 +81,7 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
parser.showHelp(1); parser.showHelp(1);
} }
options.processAllSignatures = parser.isSet("process-all-signatures");
options.outputDirectory = parser.value("directory"); options.outputDirectory = parser.value("directory");
options.archiveName = args.first(); options.archiveName = args.first();
@ -104,6 +107,7 @@ int main(int argc, char **argv)
std::cerr << "Error: Could not create job" << std::endl; std::cerr << "Error: Could not create job" << std::endl;
return 1; return 1;
} }
job->setProcessAllSignatures(options.processAllSignatures);
job->setInputFile(options.archiveName); job->setInputFile(options.archiveName);
job->setOutputDirectory(options.outputDirectory); job->setOutputDirectory(options.outputDirectory);
QObject::connect(job, &QGpgME::DecryptVerifyArchiveJob::result, &app, [](const GpgME::DecryptionResult &decryptionResult, const GpgME::VerificationResult &verificationResult, const QString &auditLog, const GpgME::Error &) { QObject::connect(job, &QGpgME::DecryptVerifyArchiveJob::result, &app, [](const GpgME::DecryptionResult &decryptionResult, const GpgME::VerificationResult &verificationResult, const QString &auditLog, const GpgME::Error &) {

View File

@ -58,6 +58,7 @@ std::ostream &operator<<(std::ostream &os, const QString &s)
} }
struct CommandLineOptions { struct CommandLineOptions {
bool processAllSignatures = false;
QString inputFile; QString inputFile;
QString outputFile; QString outputFile;
std::chrono::seconds cancelTimeout{0}; std::chrono::seconds cancelTimeout{0};
@ -73,6 +74,7 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
parser.addOptions({ parser.addOptions({
{{"o", "output"}, "Write output to FILE.", "FILE"}, {{"o", "output"}, "Write output to FILE.", "FILE"},
{"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"},
{"process-all-signatures", "Don't stop signature checking after bad signature."},
}); });
parser.addPositionalArgument("file", "File to decrypt", "FILE"); parser.addPositionalArgument("file", "File to decrypt", "FILE");
@ -83,6 +85,7 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
parser.showHelp(1); parser.showHelp(1);
} }
options.processAllSignatures = parser.isSet("process-all-signatures");
options.inputFile = args.front(); options.inputFile = args.front();
options.outputFile = parser.value("output"); options.outputFile = parser.value("output");
if (parser.isSet("cancel-after")) { if (parser.isSet("cancel-after")) {
@ -146,6 +149,7 @@ int main(int argc, char **argv)
std::shared_ptr<QFile> input; std::shared_ptr<QFile> input;
GpgME::Error err; GpgME::Error err;
job->setProcessAllSignatures(options.processAllSignatures);
if (output) { if (output) {
input.reset(new QFile{options.inputFile}); input.reset(new QFile{options.inputFile});
input->open(QIODevice::ReadOnly); input->open(QIODevice::ReadOnly);

View File

@ -56,6 +56,7 @@ std::ostream &operator<<(std::ostream &os, const QString &s)
} }
struct CommandLineOptions { struct CommandLineOptions {
bool processAllSignatures = false;
QString signatureFile; QString signatureFile;
QString signedFile; QString signedFile;
}; };
@ -67,6 +68,9 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
QCommandLineParser parser; QCommandLineParser parser;
parser.setApplicationDescription("Test program for VerifyDetachedJob"); parser.setApplicationDescription("Test program for VerifyDetachedJob");
parser.addHelpOption(); parser.addHelpOption();
parser.addOptions({
{"process-all-signatures", "Don't stop signature checking after bad signature."},
});
parser.addPositionalArgument("signature", "Detached SIGNATURE to verify", "SIGNATURE"); parser.addPositionalArgument("signature", "Detached SIGNATURE to verify", "SIGNATURE");
parser.addPositionalArgument("signed file", "FILE containing the signed data", "FILE"); parser.addPositionalArgument("signed file", "FILE containing the signed data", "FILE");
@ -77,6 +81,7 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
parser.showHelp(1); parser.showHelp(1);
} }
options.processAllSignatures = parser.isSet("process-all-signatures");
options.signatureFile = args[0]; options.signatureFile = args[0];
options.signedFile = args[1]; options.signedFile = args[1];
@ -110,6 +115,7 @@ int main(int argc, char **argv)
std::shared_ptr<QFile> input; std::shared_ptr<QFile> input;
GpgME::Error err; GpgME::Error err;
job->setProcessAllSignatures(options.processAllSignatures);
job->setSignatureFile(options.signatureFile); job->setSignatureFile(options.signatureFile);
job->setSignedFile(options.signedFile); job->setSignedFile(options.signedFile);
err = job->startIt(); err = job->startIt();

View File

@ -57,6 +57,7 @@ std::ostream &operator<<(std::ostream &os, const QString &s)
} }
struct CommandLineOptions { struct CommandLineOptions {
bool processAllSignatures = false;
QString inputFile; QString inputFile;
QString outputFile; QString outputFile;
std::chrono::seconds cancelTimeout{0}; std::chrono::seconds cancelTimeout{0};
@ -72,6 +73,7 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
parser.addOptions({ parser.addOptions({
{{"o", "output"}, "Write output to FILE.", "FILE"}, {{"o", "output"}, "Write output to FILE.", "FILE"},
{"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"},
{"process-all-signatures", "Don't stop signature checking after bad signature."},
}); });
parser.addPositionalArgument("file", "File to verify", "FILE"); parser.addPositionalArgument("file", "File to verify", "FILE");
@ -82,6 +84,7 @@ CommandLineOptions parseCommandLine(const QStringList &arguments)
parser.showHelp(1); parser.showHelp(1);
} }
options.processAllSignatures = parser.isSet("process-all-signatures");
options.inputFile = args.front(); options.inputFile = args.front();
options.outputFile = parser.value("output"); options.outputFile = parser.value("output");
if (parser.isSet("cancel-after")) { if (parser.isSet("cancel-after")) {
@ -143,6 +146,7 @@ int main(int argc, char **argv)
std::shared_ptr<QFile> input; std::shared_ptr<QFile> input;
GpgME::Error err; GpgME::Error err;
job->setProcessAllSignatures(options.processAllSignatures);
if (output) { if (output) {
input.reset(new QFile{options.inputFile}); input.reset(new QFile{options.inputFile});
input->open(QIODevice::ReadOnly); input->open(QIODevice::ReadOnly);