Test vectors for dkim2
  • Go 97.8%
  • Makefile 2.2%
Find a file
2026-06-25 14:40:23 +01:00
cmd Tidy up makefile, fix tags_whitespace. 2026-06-25 14:40:23 +01:00
keys Check in generated keys and tests. 2026-06-22 19:15:54 +01:00
tests Tidy up makefile, fix tags_whitespace. 2026-06-25 14:40:23 +01:00
.gitignore Add Makefile and README.md. 2026-06-22 19:15:30 +01:00
dns.go First round of non-recipie tests. 2026-06-22 17:36:00 +01:00
dns.json Check in generated keys and tests. 2026-06-22 19:15:54 +01:00
dns.txt Check in generated keys and tests. 2026-06-22 19:15:54 +01:00
go.mod Tidy up makefile, fix tags_whitespace. 2026-06-25 14:40:23 +01:00
go.sum Tidy up makefile, fix tags_whitespace. 2026-06-25 14:40:23 +01:00
ignore.go First round of non-recipie tests. 2026-06-22 17:36:00 +01:00
LICENSE Initial commit 2026-06-04 08:08:32 +00:00
Makefile Tidy up makefile, fix tags_whitespace. 2026-06-25 14:40:23 +01:00
README.md Tidy up makefile, fix tags_whitespace. 2026-06-25 14:40:23 +01:00
structure.go First round of non-recipie tests. 2026-06-22 17:36:00 +01:00

dkim2tests

Test vectors for dkim2

Tests

For each test there are three files in the tests directory. The primary one is a toml file containing all the details of the test. There are also two copies of the message, one before signing (.orig) and one after (.signed).

There are also two files containing all the relevant DNS records for the tests. dns.json contains the public keys, keyed by DKIM hostname (selector + _domainkey + domain). dns.txt contains the same as regular DNS zone file entries.

dns.json and dns.txt are redundant, as the public keys used are also included in each toml test file. dns.go provides helpers to use that dns info as a mock resolver.

chaos_test.go provides an example of how to run the tests in Go.

TOML Structure

There is one test in each toml file in the tests directory. The structure of the toml is included as Go struct in structure.go.

Name: the short name of the test

Description: a longer description

Comments: an explanation of what the test is testing

Spec: the version of the DKIM2 spec the test is written against

Section: relevant sections of the DKIM2 spec

OriginalMessage: a multiline field containing the message before signing - if this is empty, use OriginalFile

OriginalFile: file containing the original message

SignedMessage: a multiline field containing the signed message - if this is empty use SignedFile

SignedFile: file containing the signed message

MailFrom: the 5321.From of the message

RcptTo: a list of 5321.To addresses the message was sent to

ExpectedState: the expected validation state, e.g. permerror or pass

ExpectedError: a human readable error message

CanonicalDkim2Headers: a multiline field containing the Message-Instance and Dkim2-Signature headers that were signed

ExpectedFlags: The flags in the top Dkim2-Signature header

PrivateKeys: a section containing the private keys used to sign the message

DNS: a section containing the public keys in DNS format corresponding to the private keys

Regenerating tests

To regenerate the private keys, run make keys.

To generate public keys and dns data from the private keys, run make dns.

To generate tests, run make tests. (This will give a diagnostic about a mail from not being found in public keys which can be ignored.)