diff --git a/CHANGELOG.md b/CHANGELOG.md index f04d1bcd..280becaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. ### Fixes +- Fixed signature verification if a signed header contains a non ASCII character. - Fixed support for Thunderbird Conversations add-on in Thunderbird 115 and later (#395). ### Other diff --git a/modules/dkim/crypto.mjs.js b/modules/dkim/crypto.mjs.js index bb12babd..f9673dfb 100644 --- a/modules/dkim/crypto.mjs.js +++ b/modules/dkim/crypto.mjs.js @@ -229,7 +229,7 @@ class DkimCryptoWeb extends DkimCryptoBase { "RSASSA-PKCS1-v1_5", cryptoKey, this._decodeBase64(signature), - new TextEncoder().encode(data) + strToArrayBuffer(data) ); return [valid, rsaKeyParams.modulusLength]; } diff --git a/test/data/dkim/header_with_non_ascii_char.eml b/test/data/dkim/header_with_non_ascii_char.eml new file mode 100644 index 00000000..5e74775f --- /dev/null +++ b/test/data/dkim/header_with_non_ascii_char.eml @@ -0,0 +1,18 @@ +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=example.com; i=@example.com; + q=dns/txt; s=brisbane; t=1698597711; h=from : to : subject : date : + message-id : from : subject : date; + bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=; + b=CE3Oslfk2qB38RAmRCRhIIbMvP5u/kuP1KEswe4Gx2qSScrl/cZm2WCstkEbcapJxH6qu0 + Xw/AE7TWypWitV46qscm2GrDVselmWoSmxFl9Sji1p/5ouWc2UQJGNSDUYCpMJN0T3UMVHYv + +Bx0myqvZbYbKXp6jZsPami5g1Xcg= +From: Joe SixPack +To: Suzie ß +Subject: DKIM test - To header with non ASCII char +Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) +Message-ID: <20030712040037.46341.5F8J+test_0001@example.com> + +Hi. + +We lost the game. Are you hungry yet? + +Joe. diff --git a/test/unittest/verifierSpec.mjs.js b/test/unittest/verifierSpec.mjs.js index 93ebfd56..d95a9720 100644 --- a/test/unittest/verifierSpec.mjs.js +++ b/test/unittest/verifierSpec.mjs.js @@ -75,6 +75,12 @@ describe("DKIM Verifier [unittest]", function () { expect(res.signatures[1]?.auid).to.be.equal("@football.example.com"); expect(res.signatures[1]?.selector).to.be.equal("brisbane"); }); + it("Signed header with non ASCII char", async function () { + const res = await verifyEmlFile("dkim/header_with_non_ascii_char.eml"); + expect(res.signatures.length).to.be.equal(1); + expect(res.signatures[0]?.result).to.be.equal("SUCCESS"); + expect(res.signatures[0]?.warnings).to.be.empty; + }); it("DKIM key with empty notes tag", async function () { const res = await verifyEmlFile("rfc6376-A.2.eml", new Map([ ["brisbane._domainkey.example.com",