diff --git a/dkim/tests/data/rfc6376.signed.no_t.msg b/dkim/tests/data/rfc6376.signed.no_t.msg new file mode 100644 index 0000000..f4a31db --- /dev/null +++ b/dkim/tests/data/rfc6376.signed.no_t.msg @@ -0,0 +1,20 @@ +DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; + d=football.example.com; i=@football.example.com; + q=dns/txt; s=test; h=from : to : subject : + date : message-id : from : subject : date; x=100000000000; + bh=4bLNXImK9drULnmePzZNEBleUanJCX5PIsDIFoH4KTQ=; + b=icKcLSEZYXJ95flvWE8FT6hl5iqd8MC/LEKYH0QjsqYy6MO/4pgVNCZH + l/RAXAuADxE/40Fg7uTlxwwD1hjN2Ple6J//cJfslBdDOq6zTVbne1dqtl + NOat7iamJ1AfRqyG+ja7a2AZsrpUuJ7VA6O+0zRYPqpwMEkEFIzI9i/Xk= +From: Joe SixPack +To: Suzie Q +Subject: Is dinner ready? +Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) +Message-ID: <20030712040037.46341.5F8J@football.example.com> + +Hi. + +We lost the game. Are you hungry yet? + +Joe. + diff --git a/dkim/tests/test_dkim.py b/dkim/tests/test_dkim.py index 142cc12..49675b4 100644 --- a/dkim/tests/test_dkim.py +++ b/dkim/tests/test_dkim.py @@ -62,6 +62,7 @@ class TestSignAndVerify(unittest.TestCase): self.message5 = read_test_data("rfc6376.signed.rsa.msg") self.message6 = read_test_data("test.message.baddomain") self.message7 = read_test_data("rfc6376.w1258.msg") + self.message8 = read_test_data("rfc6376.signed.no_t.msg") self.key = read_test_data("test.private") self.rfckey = read_test_data("rfc8032_7_1.key") @@ -250,6 +251,7 @@ b/mPfjC0QJTocVBq6Za/PlzfV+Py92VaCak19F4WrbVTK5Gg5tW220MCAwEAAQ==""" d = dkim.DKIM(self.message4) res = d.verify(dnsfunc=self.dnsfunc5) self.assertTrue(res) + def test_non_utf8(self): # A message with Windows-1258 encoding is signed and verifies. for header_algo in (b"simple", b"relaxed"): @@ -262,6 +264,13 @@ b/mPfjC0QJTocVBq6Za/PlzfV+Py92VaCak19F4WrbVTK5Gg5tW220MCAwEAAQ==""" # As of 1.1.0 this won't verify, but at least we don't crash. FIXME self.assertFalse(res) + def test_no_t(self): + # Signature Timestamp is optional, so don't crash if it's missing. + d = dkim.DKIM(self.message8) + res = d.verify(dnsfunc=self.dnsfunc5) + # Signature won't verify, but that's not what we are testing. + self.assertFalse(res) + def test_catch_bad_key(self): # Raise correct error for defective public key. d = dkim.DKIM(self.message5)