bug 380744, Thunderbird reports "unable to decrypt" on truncated decryptable messages

r=rrelyea, sr=mscott, a=dveditz


git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@233357 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
kaie%kuix.de
2007-08-29 23:05:22 +00:00
parent f5c3cf6c9c
commit 70dcda57f5
4 changed files with 30 additions and 3 deletions

View File

@@ -125,8 +125,12 @@ var smimeHeaderSink =
gEncryptedURIService.rememberEncrypted(gMyLastEncryptedURI);
}
if (nsICMSMessageErrors.SUCCESS != aEncryptionStatus)
switch (aEncryptionStatus)
{
case nsICMSMessageErrors.SUCCESS:
case nsICMSMessageErrors.ENCRYPT_INCOMPLETE:
break;
default:
var brand = gBrandBundle.getString("brandShortName");
var title = gSMIMEBundle.getString("CantDecryptTitle").replace(/%brand%/g,brand);
var body = gSMIMEBundle.getString("CantDecryptBody").replace(/%brand%/g,brand);
@@ -142,7 +146,7 @@ var smimeHeaderSink =
title+"</font></center><br>\n"+
body+"\n"+
"</td></tr></table></center></body></html>", false);
break;
}
},

View File

@@ -184,6 +184,11 @@ function onLoad()
encInfo = "EIValid";
break;
case nsICMSMessageErrors.ENCRYPT_INCOMPLETE:
encInfoLabel = "EIInvalidLabel";
encInfo = "EIContentAltered";
break;
case nsICMSMessageErrors.GENERAL_ERROR:
encInfoLabel = "EIInvalidLabel";
encInfoHeader = "EIInvalidHeader";

View File

@@ -97,6 +97,7 @@ typedef struct MimeCMSdata
PRBool ci_is_encrypted;
char *sender_addr;
PRBool decoding_failed;
PRUint32 decoded_bytes;
MimeObject *self;
PRBool parent_is_encrypted_p;
PRBool parent_holds_stamp_p;
@@ -108,6 +109,7 @@ typedef struct MimeCMSdata
ci_is_encrypted(PR_FALSE),
sender_addr(nsnull),
decoding_failed(PR_FALSE),
decoded_bytes(0),
self(nsnull),
parent_is_encrypted_p(PR_FALSE),
parent_holds_stamp_p(PR_FALSE)
@@ -146,6 +148,8 @@ static void MimeCMS_content_callback (void *arg, const char *buf, unsigned long
data->output_fn = 0;
return;
}
data->decoded_bytes += length;
}
PRBool MimeEncryptedCMS_encrypted_p (MimeObject *obj)
@@ -630,7 +634,17 @@ MimeCMS_eof (void *crypto_closure, PRBool abort_p)
if (!data->content_info)
{
status = nsICMSMessageErrors::GENERAL_ERROR;
if (!data->decoded_bytes)
{
// We were unable to decode any data.
status = nsICMSMessageErrors::GENERAL_ERROR;
}
else
{
// Some content got decoded, but we failed to decode
// the final summary, probably we got truncated data.
status = nsICMSMessageErrors::ENCRYPT_INCOMPLETE;
}
// Although a CMS message could be either encrypted or opaquely signed,
// what we see is most likely encrypted, because if it were

View File

@@ -63,6 +63,7 @@ interface nsICMSMessageErrors : nsISupports
const long VERIFY_CERT_WITHOUT_ADDRESS = 1040;
const long ENCRYPT_NO_BULK_ALG = 1056;
const long ENCRYPT_INCOMPLETE = 1057;
};
%{ C++
@@ -118,4 +119,7 @@ interface nsICMSMessageErrors : nsISupports
#define NS_ERROR_CMS_ENCRYPT_NO_BULK_ALG \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SECURITY, \
nsICMSMessageErrors::ENCRYPT_NO_BULK_ALG)
#define NS_ERROR_CMS_ENCRYPT_INCOMPLETE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SECURITY, \
nsICMSMessageErrors::ENCRYPT_INCOMPLETE)
%}