-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dkim: accept RSA keys in both raw and SPKI form
RFC 6376 is inconsistent about whether RSA public keys should be formatted as RSAPublicKey or SubjectPublicKeyInfo. Erratum 3017 (https://www.rfc-editor.org/errata/eid3017) proposes allowing both. This commit changes the verifier to accept both formats, and changes dkim-keygen to generate keys in SubjectPublicKeyInfo format for consistency with other implementations including opendkim, Gmail, and Fastmail. Closes: #43
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,52 @@ func TestVerifyWithOption(t *testing.T) { | |
} | ||
} | ||
|
||
const verifiedRawRSAMailString = `DKIM-Signature: a=rsa-sha256; bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=; | ||
c=simple/simple; d=example.com; | ||
h=Received:From:To:Subject:Date:Message-ID; [email protected]; | ||
s=newengland; t=1615825284; v=1; | ||
b=Xh4Ujb2wv5x54gXtulCiy4C0e+plRm6pZ4owF+kICpYzs/8WkTVIDBrzhJP0DAYCpnL62T0G | ||
k+0OH8pi/yqETVjKtKk+peMnNvKkut0GeWZMTze0bfq3/JUK3Ln3jTzzpXxrgVnvBxeY9EZIL4g | ||
s4wwFRRKz/1bksZGSjD8uuSU= | ||
Received: from client1.football.example.com [192.0.2.1] | ||
by submitserver.example.com with SUBMISSION; | ||
Fri, 11 Jul 2003 21:01:54 -0700 (PDT) | ||
From: Joe SixPack <[email protected]> | ||
To: Suzie Q <[email protected]> | ||
Subject: Is dinner ready? | ||
Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) | ||
Message-ID: <[email protected]> | ||
Hi. | ||
We lost the game. Are you hungry yet? | ||
Joe. | ||
` | ||
|
||
var testRawRSAVerification = &Verification{ | ||
Domain: "example.com", | ||
Identifier: "[email protected]", | ||
HeaderKeys: []string{"Received", "From", "To", "Subject", "Date", "Message-ID"}, | ||
Time: time.Unix(1615825284, 0), | ||
} | ||
|
||
func TestVerify_rawRSA(t *testing.T) { | ||
r := newMailStringReader(verifiedRawRSAMailString) | ||
|
||
verifications, err := Verify(r) | ||
if err != nil { | ||
t.Fatalf("Expected no error while verifying signature, got: %v", err) | ||
} else if len(verifications) != 1 { | ||
t.Fatalf("Expected exactly one verification, got %v", len(verifications)) | ||
} | ||
|
||
v := verifications[0] | ||
if !reflect.DeepEqual(testRawRSAVerification, v) { | ||
t.Errorf("Expected verification to be \n%+v\n but got \n%+v", testRawRSAVerification, v) | ||
} | ||
} | ||
|
||
const verifiedEd25519MailString = `DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; | ||
d=football.example.com; [email protected]; | ||
q=dns/txt; s=brisbane; t=1528637909; h=from : to : | ||
|