Bookmarks

DKIM — DomainKeys Identified Mail

A way to sign a message with a domain’s private key so that the receiver can verify the signature with the public key from DNS.

Also: DKIM signature, email signature, DKIM key

checked 9 Nov

All terms

DKIM ties a message to the domain responsible for it: the server adds a digital signature to the headers, and the receiver checks it against the public key published in DNS. The signature confirms that the signed parts of the message were not altered in transit and that they were signed by whoever holds the domain’s private key.

How it works

  • The sending server computes a hash of the message body and of selected headers and signs it with the private key.
  • The result is added to the DKIM-Signature header: the signing domain (d=), the selector (s=), the body hash (bh=), the list of signed headers (h=) and the signature itself (b=).
  • The receiver requests the TXT record selector._domainkey.domain, takes the public key from the p= field and verifies the signature.
text
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=mail2026;  h=from:to:subject:date:message-id; bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=; b=AuUoFEfDxTDkHl... mail2026._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEF..."

The selector is an arbitrary name, so one domain can have several keys: for different servers and mailing services. To rotate a key, publish a new selector and only then switch signing over.

Algorithms and key length

ItemRequirement
Algorithmrsa-sha256; rsa-sha1 has been forbidden since RFC 8301 (2018)
RSA key lengthat least 1024 bits, 2048 or more recommended
Ed25519ed25519-sha256 was added in RFC 8463 (2018)

A 2048-bit key does not fit in a single TXT string, which is limited to 255 bytes, so the value is split into several strings within one record. The signature breaks if the signed parts of a message are changed along the way: for example, if a mailing list adds a tag to the subject or a footer to the body.

The main standard is RFC 6376 (September 2011, editors Dave Crocker, Tony Hansen and Murray Kucherawy).

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

In depth in the references

where the topic is covered in detail