qt: Rely on the bad passphrase error reported by gpg
* lang/qt/src/qgpgmedecryptverifyjob.cpp (patch_decryption_result):
Removed.
(decrypt_verify): Remove usage of patch_decryption_result.
--
This reverts most of revision d8e5871dca
.
GnuPG-bug-id: 5939
This commit is contained in:
parent
e21c3b559d
commit
512f11b458
@ -49,7 +49,6 @@
|
|||||||
#include "qgpgme_debug.h"
|
#include "qgpgme_debug.h"
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@ -64,18 +63,6 @@ QGpgMEDecryptVerifyJob::QGpgMEDecryptVerifyJob(Context *context)
|
|||||||
|
|
||||||
QGpgMEDecryptVerifyJob::~QGpgMEDecryptVerifyJob() {}
|
QGpgMEDecryptVerifyJob::~QGpgMEDecryptVerifyJob() {}
|
||||||
|
|
||||||
static void patch_decryption_result(DecryptionResult &result, const QString &auditLog)
|
|
||||||
{
|
|
||||||
if (result.error().code() == GPG_ERR_DECRYPT_FAILED) {
|
|
||||||
// check for wrong symmetric password
|
|
||||||
if (auditLog.contains(QLatin1String{"gpg: decryption of the symmetrically encrypted session key failed: Checksum error"})
|
|
||||||
|| (auditLog.contains(QRegularExpression{QStringLiteral("gpg: encrypted with \\d+ passphrase")})
|
|
||||||
&& auditLog.contains(QLatin1String{"gpg: decryption failed: Bad session key"}))) {
|
|
||||||
result.setError(Error::fromCode(GPG_ERR_BAD_PASSPHRASE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread *thread,
|
static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread *thread,
|
||||||
const std::weak_ptr<QIODevice> &cipherText_,
|
const std::weak_ptr<QIODevice> &cipherText_,
|
||||||
const std::weak_ptr<QIODevice> &plainText_)
|
const std::weak_ptr<QIODevice> &plainText_)
|
||||||
@ -95,21 +82,19 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread
|
|||||||
QGpgME::QByteArrayDataProvider out;
|
QGpgME::QByteArrayDataProvider out;
|
||||||
Data outdata(&out);
|
Data outdata(&out);
|
||||||
|
|
||||||
std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
|
const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
|
||||||
Error ae;
|
Error ae;
|
||||||
const QString log = _detail::audit_log_as_html(ctx, ae);
|
const QString log = _detail::audit_log_as_html(ctx, ae);
|
||||||
qCDebug(QGPGME_LOG) << __func__ << "- End no plainText. Error:" << ae.asString();
|
qCDebug(QGPGME_LOG) << __func__ << "- End no plainText. Error:" << ae.asString();
|
||||||
patch_decryption_result(res.first, log);
|
|
||||||
return std::make_tuple(res.first, res.second, out.data(), log, ae);
|
return std::make_tuple(res.first, res.second, out.data(), log, ae);
|
||||||
} else {
|
} else {
|
||||||
QGpgME::QIODeviceDataProvider out(plainText);
|
QGpgME::QIODeviceDataProvider out(plainText);
|
||||||
Data outdata(&out);
|
Data outdata(&out);
|
||||||
|
|
||||||
std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
|
const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
|
||||||
Error ae;
|
Error ae;
|
||||||
const QString log = _detail::audit_log_as_html(ctx, ae);
|
const QString log = _detail::audit_log_as_html(ctx, ae);
|
||||||
qCDebug(QGPGME_LOG) << __func__ << "- End plainText. Error:" << ae.asString();
|
qCDebug(QGPGME_LOG) << __func__ << "- End plainText. Error:" << ae.asString();
|
||||||
patch_decryption_result(res.first, log);
|
|
||||||
return std::make_tuple(res.first, res.second, QByteArray(), log, ae);
|
return std::make_tuple(res.first, res.second, QByteArray(), log, ae);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user