Skip to content

Commit

Permalink
Fix verification if a signed header contains a non ASCII character
Browse files Browse the repository at this point in the history
  • Loading branch information
lieser committed Oct 29, 2023
1 parent 8ce2309 commit ccfe711
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/dkim/crypto.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
18 changes: 18 additions & 0 deletions test/data/dkim/header_with_non_ascii_char.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=example.com; [email protected];
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 <[email protected]>
To: Suzie ß <[email protected]>
Subject: DKIM test - To header with non ASCII char
Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT)
Message-ID: <[email protected]>

Hi.

We lost the game. Are you hungry yet?

Joe.
6 changes: 6 additions & 0 deletions test/unittest/verifierSpec.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ccfe711

Please sign in to comment.