NetDetectHubGet the app

Home / Learn

Module 3: Email authenticationLesson 9 of 135 min read

DKIM signatures explained: selectors, keys and what gets signed

SPF checks which server delivered a message. DKIM, DomainKeys Identified Mail, checks something different: that a domain signed the message and that the signed parts were not changed on the way. The signature travels inside the message itself, so unlike SPF it can survive forwarding. Reading one signature header is enough to understand how the whole system works.

The signature header

A signing server adds a header named DKIM-Signature. It is a list of tag=value pairs defined in RFC 6376. The ones you need to read are:

  • d= the signing domain, the domain that takes responsibility for the message.
  • s= the selector, which names the key to use.
  • a= the algorithm, normally rsa-sha256.
  • h= the list of header fields that were signed. RFC 6376 requires the From header to be among them.
  • bh= a hash of the message body, after canonicalization.
  • b= the signature itself, computed over the signed headers and the DKIM-Signature header, with b= treated as empty.
  • c= the canonicalization methods, for example relaxed/relaxed.

How the receiver finds the key

The public key lives in DNS. RFC 6376 stores all DKIM keys under a subdomain named _domainkey. Given d=example.com and s=foo.bar, the receiver queries the TXT record at foo.bar._domainkey.example.com.

Because the selector is part of the name, one domain can have many keys at once: one per email service, or an old and a new key during a rotation. It also means nobody can list a domain's DKIM keys from DNS alone. You need the selector, and the place to find it is the s= tag in a message the domain has sent.

One signature, one lookup

Header: DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=mail2026; c=relaxed/relaxed; h=from:to:subject:date; bh=…; b=… → the receiver asks for TXT at mail2026._domainkey.example.com and gets v=DKIM1; k=rsa; p=MIIBIjANBgkq… (the base64 public key). It recomputes the body hash, compares it with bh=, and verifies b= with the key.

Canonicalization: surviving small changes

Mail servers sometimes rewrap long header lines or change whitespace. A signature that demanded identical bytes would break. RFC 6376 therefore defines two canonicalization algorithms each for headers and body. Simple tolerates almost no modification. Relaxed tolerates common ones, such as replacing whitespace and rewrapping header lines, by normalising them before hashing.

Content changes still break the signature, by design. A mailing list that adds a footer to the body or a tag to the subject changes signed data, so the original signature no longer verifies.

Key sizes and algorithms

RFC 8301 updated DKIM's cryptography in 2018. Signers must use RSA keys of at least 1024 bits and should use at least 2048 bits. Verifiers must not accept signatures made with RSA keys shorter than 1024 bits, and rsa-sha1 must no longer be used for signing.

Mailbox providers set the same floor. Google requires a DKIM key of 1024 bits or longer for mail to personal Gmail accounts and recommends 2048 bits where the DNS provider supports it. Yahoo asks for DKIM on every message with at least a 1024-bit key.

Two key-record tags to watch

p= empty means the key has been revoked: signatures that point to it fail. t=y means the domain is testing DKIM, and RFC 6376 says verifiers must not treat its messages differently from unsigned mail, even if the signature verifies. Leaving t=y in place after testing quietly throws away DKIM's value.

What DKIM does and doesn't prove

A valid signature proves that the domain in d= signed the message and that the signed headers and body are unchanged. It doesn't say the message is wanted or safe, and on its own it doesn't connect d= to the From address the reader sees: a message from [email protected] can carry a valid signature from d=mailer.example.net. Requiring the two to match is the role of DMARC alignment.

Rotating keys is simple with selectors. Publish the new key under a new selector, switch the signing server to it, and keep the old key in DNS until messages signed with it are no longer being checked, then empty its p= tag.

Find a domain's DKIM keys. The checker tries selectors that common providers use and lists them under Selectors tried; for any key it finds, read Key type and Key size. If nothing is found, copy the s= value from a received email's DKIM-Signature header into Selector (optional) and check again.

DKIM checker

Quick check

Three questions. Pick an answer to see why.

  1. A message has DKIM-Signature with d=example.org and s=k7. Which DNS record does the receiver fetch?

    Show the answer

    Answer: TXT at k7._domainkey.example.org RFC 6376 builds the query as selector._domainkey.domain.

  2. A mailing list adds a footer to every message body. What happens to the original DKIM signature?

    Show the answer

    Answer: It fails, because the body hash no longer matches bh= Relaxed canonicalization forgives whitespace, not added content, so the recomputed body hash differs.

  3. Why can't a DKIM checker simply list all of a domain's keys?

    Show the answer

    Answer: Because each key sits under a selector name, and DNS can't be asked for every name under _domainkey You have to know the selector, which appears as s= in signed messages; checkers can only try common ones.

Standards, not guesses

These guides explain how the internet's plumbing works, using the published standards (RFCs) and official documentation. Each guide shows the date it was last checked.

Sources

Last checked October 28, 2026

Results come from public DNS, registry and certificate data and from checks run from Cloudflare's network at the moment you ask. They can differ from what another network sees. How our tools work · Terms of use.