Commit 0e19a836 authored by Sandro Knauß's avatar Sandro Knauß

No Secret key = no decryption.

Show the user that we are missing a secrect key to decrypt instead of
a general error message.

Differential Revision: https://phabricator.kde.org/D1252
parent 730e4ae3
From test@kolab.org Wed, 25 May 2011 23:49:40 +0100
From: OpenPGP Test <test@kolab.org>
To: test@kolab.org
Subject: inlinepgpencrypted - no seckey
Date: Wed, 25 May 2011 23:49:40 +0100
Message-ID: <1786696.yKXrOjjflF@herrwackelpudding.localhost>
X-KMail-Transport: GMX
X-KMail-Fcc: 28
X-KMail-Drafts: 7
X-KMail-Templates: 9
User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19)
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2
hQIMA1U9QmLaS63yAQ/8C8o5D7wQ9LoPHrNCNelku19bwQogTIqxRJSTYzO0b0tr
Pb7Oyxkm1XabYxhg9bxFcNvvAbxcbzmnFJqkVPzCird43N5BDMtwGumiUjNNYVgy
4tD6hs+h8GsmmQ5/J5cmuUwA+Ee20ubrTMH2qkU75WcyuRAG+IFsA80eEKG5qR8y
i2WXjBiImcmjrEVtSA3L+mUHmhuWxz/46EnCelSAJMfhSG8zuTJnK6OFBSDQNkqE
NRJl0PO4DYDeJiSYeXWEB2GTvc9JXtcHm7wIwzHXHSrBlXvQWEj5B8z9GSOJwO0o
JuV29TVU4iDU8d3flfhMGZEJXUkIIwt66/0CtuJNDmIAnqc4wQO9LtXFXOI/YK7x
twidnLY04kmh1bZfQsUBhwdYqLUzr0AXqE2kRTozod4XgVBmphVt6Ytu11L1UFdb
1wKBaQG/qmhOmeMJb7eJX6I66p8LzKiqkfNlTnPQURELMbCmiRwoDCC5wnrDj8g/
K0zvfNRFbGimbTHeQ01OncoVcRIlXK7njM6dTTqnglzwZagHn1Ph0krkdbnzLJkc
j8v1QLWuM1tt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2w7KnI7sxXvZljOvuSI
FE9NvGs2uHjRFjO0Vncjuv/fAbdvVvkTCSyLWZLUyOegJa/0KZOU48HtwwBzVxl1
D9joee2bmQnmxuGomRwelUVbux1GKRhfCtnNuKQNXU7NP3AnNUDAQjrQSD5C1f3e
9tPOi3wRuXnlYfBcmemKUrdYNVpWBpHh+KnJ1rW/NqwNvUtq0ucYIT5//dKaPiIf
HqizKm0MntFbIv4f29TNfw5Wp1GcTXc6Dmt/KSCjLH+IxPtdAgI5ZlrdOfVxlY1B
abIFKjN0csPfkfX7l8g6ekOYgP/NRHQQs7Zyds59Zj7Roi7+uabV8svXRREm0V34
595ro3cEzABOAnErxErC7Lm/VUI348kdOP/3IAckmwv1qts3P2eDA6CcLYE2V+sz
7mb9UGrUzu8hBxPjbuqIYfi2XOSxGRCvSH0Rmw7XzKfSRwHpusUQjpCbRXyntVqY
Db8+PufLBENx22ipLLEDltP1P9zRuy2KpANd0sggM/HtUC3Bjta7IR9Q3qbVcPDx
3Qu241eOBdb6
=J3lb
-----END PGP MESSAGE-----
<?xml version="1.0" encoding="UTF8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div style="position: relative; word-wrap: break-word">
<a name="att"/>
<div id="attachmentDiv">
<table cellspacing="1" cellpadding="1" class="encr">
<tr class="encrH">
<td dir="ltr">Encrypted message (decryption not possible)<br/>Reason: Crypto plug-in "OpenPGP" could not decrypt the data.<br/>Error: Decryption failed</td>
</tr>
<tr class="encrB">
<td>
<div style="font-size:x-large; text-align:center; padding:20pt;">No secret key found to encrypt the message. It is encrypted for following keys:<br/><a href="kmail:showCertificate#gpg ### OpenPGP ### 553D4262DA4BADF2">0x553D4262DA4BADF2</a><br/><a href="kmail:showCertificate#gpg ### OpenPGP ### F6E6A3D126C630E0">0xF6E6A3D126C630E0</a></div>
</td>
</tr>
<tr class="encrH">
<td dir="ltr">End of encrypted message</td>
</tr>
</table>
</div>
</div>
</body>
</html>
......@@ -671,8 +671,7 @@ bool ObjectTreeParser::okDecryptMIME(KMime::Content &data,
bDecryptionOk = true;
decryptedData = plainText;
} else {
passphraseError = decryptResult.error().isCanceled()
|| decryptResult.error().code() == GPG_ERR_NO_SECKEY;
passphraseError = decryptResult.error().isCanceled() || decryptResult.error().code() == GPG_ERR_NO_SECKEY;
actuallyEncrypted = decryptResult.error().code() != GPG_ERR_NO_DATA;
partMetaData.errorText = QString::fromLocal8Bit(decryptResult.error().asString());
partMetaData.isEncrypted = actuallyEncrypted;
......@@ -684,9 +683,31 @@ bool ObjectTreeParser::okDecryptMIME(KMime::Content &data,
if (bDecryptionOk) {
decryptedData = plainText;
} else if (htmlWriter() && showWarning) {
decryptedData = "<div style=\"font-size:x-large; text-align:center; padding:20pt;\">"
+ errorMsg.toUtf8()
+ "</div>";
bool noSecKey = true;
const QString sNoSecKeyHeader = i18n("No secret key found to encrypt the message. It is encrypted for following keys:");
QString secKeyList;
foreach (const GpgME::DecryptionResult::Recipient &recipient, decryptResult.recipients()) {
noSecKey &= (recipient.status().code() == GPG_ERR_NO_SECKEY);
if (!secKeyList.isEmpty()) {
secKeyList += QStringLiteral("<br />");
}
secKeyList += QStringLiteral("<a href=\"kmail:showCertificate#%1 ### %2 ### %3\">%4</a>")
.arg(cryptProto->displayName(),
cryptProto->name(),
QString::fromLatin1(recipient.keyID()),
QString::fromLatin1(QByteArray("0x") + recipient.keyID())
);
}
decryptedData = "<div style=\"font-size:x-large; text-align:center; padding:20pt;\">";
if (noSecKey) {
decryptedData += QString(sNoSecKeyHeader + QStringLiteral("<br />") + secKeyList).toUtf8();
} else {
decryptedData += errorMsg.toUtf8();
}
decryptedData += "</div>";
if (!passphraseError) {
partMetaData.errorText = i18n("Crypto plug-in \"%1\" could not decrypt the data.", cryptPlugLibName)
+ QLatin1String("<br />")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment