Email security

RFC 6376 DKIM Explained: Signatures, Selectors and Keys

RFC 6376 is the standard behind every DKIM signature in your inbox. Here is how it works, tag by tag, and how to use it correctly.

Cysoro Security TeamPublished · 7 min read
DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=selector1; c=relaxed/relaxed; h=from:to:subject:date; bh=2jUSOH9NhtVGCQWNr9BrIAP... b=F45dVWDfMbQDGHJFlXUNB2HK... dkim=pass EMAIL SECURITY RFC 6376DKIM The signature standard, explained.
Quick answer

RFC 6376, published in September 2011, is the Internet standard that defines DomainKeys Identified Mail (DKIM). It specifies how a sending domain adds a cryptographic signature to each email and how receivers verify it against a public key published in DNS. DKIM proves a message was authorized by the signing domain and was not altered in transit.

Key takeaways

  • RFC 6376 defines DKIM: the sender signs selected headers and the body, and the receiver verifies the signature with a public key from DNS.
  • The DKIM-Signature header carries the signing domain, selector, signed headers, body hash and signature — the From header must always be signed.
  • Use 2048-bit RSA keys or Ed25519, publish the key at selector._domainkey, and pair DKIM with DMARC for real spoofing protection.

Every signed email you receive carries a small piece of internet history in its headers: a DKIM-Signature field defined by RFC 6376. That standard, published in 2011, is still the foundation of email authentication today.

What is RFC 6376?

RFC 6376 is the Internet standard that defines DomainKeys Identified Mail (DKIM). Published in September 2011, it specifies how a domain signs outgoing email and how receivers verify those signatures. You can read the full text of RFC 6376 on the RFC Editor site.

The RFC obsoletes RFC 4871 and RFC 5672, the earlier DKIM specifications. It is a Standards Track document from the Internet Engineering Task Force, which means it went through full IETF review and approval. The abstract states its purpose plainly: DKIM lets a person, role or organization that owns a domain claim responsibility for a message by associating the domain with it.

DKIM is one of three pillars of email authentication, alongside SPF and DMARC. Our guide to what DKIM is explains the concept in plain language; this article covers the standard itself.

How does DKIM signing and verification work?

DKIM works like a wax seal on a letter. The sender signs the message with a private key, and anyone can check the seal using a public key the sender publishes in DNS.

How DKIM signing and verification workSigning (sender)1. Canonicalize headers and body2. Hash the body, store in bh=3. Sign the hash with private key4. Add DKIM-Signature headerVerification (receiver)1. Read d= and s= from signature2. Fetch public key from DNS3. Recompute hashes, check b=4. Record dkim=pass or failThe private key never leaves the sender; the public key lives in DNS.
DKIM signing and verification, as specified in RFC 6376. Illustration by Cysoro.

Signing happens in four steps. First the sender canonicalizes the body and headers, normalizing whitespace and line endings so harmless transport changes do not break the signature. Then it hashes the canonicalized body with SHA-256 and stores that hash in the bh= tag. Next it hashes the selected headers plus the DKIM-Signature header itself with an empty b= value, and signs that hash with the private key. The result goes into b=.

Verification reverses the process. The receiver reads the d= (signing domain) and s= (selector) tags, queries the DNS TXT record at selector._domainkey.domain, recomputes the body hash and checks it against bh=, then verifies the signature in b= with the public key. A match produces dkim=pass in the Authentication-Results header; anything else is a failure, a temporary error or a permanent error.

One design choice matters more than the rest: DKIM needs no certificate authority. Unlike S/MIME, the public key is distributed through DNS, which the sender already controls. That is why DKIM deployed so widely while older signing schemes stalled.

What does the DKIM-Signature header contain?

The DKIM-Signature header is a list of tag=value pairs. RFC 6376 defines the tags, and the worked example in its Appendix A shows a real signature. Here are the tags you will actually see.

TagMeaningRequired?
v=Version, always 1Yes
a=Signing algorithm, rsa-sha256 or ed25519-sha256Yes
d=Signing domain identifier (SDID)Yes
s=Selector, naming which key record to fetchYes
c=Canonicalization for header/body, simple or relaxedNo
h=Signed header fields, in order; From must be includedYes
bh=Base64 SHA-256 hash of the canonicalized bodyYes
b=The signature itselfYes
t=Signing time, in Unix secondsNo
x=Signature expiry timeNo
l=Body length counted in the hash (use with care)No
i=Identity of the user or agent on whose behalf the message is signedNo

Here is a real example from RFC 6376, shortened for readability:

DKIM-Signature: v=1; a=rsa-sha256; d=example.net; s=brisbane; c=relaxed/simple; q=dns/txt; t=1117574938; h=from:to:subject:date; bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=; b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZVoG4ZHRNiYzR

Two rules in the RFC deserve attention. First, Section 5.4 requires the From header field to be signed — a signature that does not cover From is invalid. Second, use c=relaxed/relaxed unless you have a specific reason not to; simple canonicalization breaks on small whitespace changes that many mail relays make.

What is a DKIM record, and where does it live?

The DKIM record is the DNS TXT record that publishes the public half of a signing key. It sits at selector._domainkey.domain — for example, google._domainkey.example.com.

The record itself is another tag=value list, defined in Section 3.6.1 of RFC 6376. Only the p= tag, holding the base64 public key, is required. In practice most records carry v=DKIM1; k=rsa; p=.... The k= tag names the key type, and an empty p= value means the key is revoked.

Selectors are the key-management trick that makes DKIM practical. One domain can publish several keys at once under different selectors, so you can rotate keys, run parallel senders and revoke a compromised key without touching the others. Google Workspace, Microsoft 365 and SendGrid each use their own selectors, which is why a busy domain often has three or four DKIM records live at once. You can check your own records with our free DKIM checker.

How have RFC 8301 and RFC 8463 updated DKIM?

RFC 6376 is still the base standard, but two updates changed its cryptography rules. Knowing them matters, because the original RFC allowed practices that are now unsafe.

RFC 8301, published in 2018, updated the signing algorithms and key sizes. It states that rsa-sha1 must no longer be used, that signers must use RSA keys of at least 1024 bits and should use at least 2048 bits, and that verifiers must not treat signatures from keys under 1024 bits as valid. If your DKIM key is still 1024 bits, it works — but 2048 bits is the current recommendation.

RFC 8463, also from 2018, added Ed25519 as a signing algorithm. Ed25519 keys are far shorter than RSA keys for equivalent security, which keeps DNS records small and avoids the TXT record size problems that 2048-bit RSA keys can cause. The DKIM article on Wikipedia lists the full update history of the standard.

RFC 6376 also has a companion set of documents worth knowing: RFC 5585 gives the DKIM architecture overview, and RFC 5863 covers deployment and operations. If you are implementing DKIM rather than just using it, read those two as well.

Why does DKIM fail?

A failed DKIM check does not always mean forgery. The most common causes are ordinary operational mistakes, and the Authentication-Results header usually tells you which one.

Why DKIM fails — and the fixNo key record in DNSPublish the TXT record, check the selectorMessage modified after signingFooter or subject change broke the hashKey too short (under 1024 bits)Generate a 2048-bit RSA or Ed25519 keyWrong selector in the signatureMatch s= to the DNS record nameDNS lookup timed outTemporary error — usually resolves itself
Common DKIM failure causes and their fixes. Illustration by Cysoro.
  • Missing or wrong DNS record. The selector in the signature does not match any published key, often after a provider change or a typo in the record name.
  • Message modified after signing. Mailing lists and security gateways that add footers, disclaimers or tracking links change the body or headers after the signature is applied.
  • Key too short. Old 512-bit or 768-bit keys are rejected outright under RFC 8301.
  • DNS problems. A lookup timeout produces a temporary error, not a failure, and receivers usually retry.

Note what RFC 6376 deliberately does not do: a verification failure does not force rejection of the message. DKIM reports a result; local policy decides what happens. That policy layer is DMARC, covered in our guide to DMARC.

How do you set up DKIM under RFC 6376?

Setup is the same for almost every provider: generate a key pair, publish the public key, then turn on signing. The details live in your provider's docs, but the steps are universal.

  1. Generate a key pair. Use 2048-bit RSA or Ed25519. Keep the private key on your signing server only — never publish it, and never email it to yourself.
  2. Choose a selector. Pick a short name such as default or a dated one such as s2026. Dated selectors make rotation obvious.
  3. Publish the TXT record. Add selector._domainkey.yourdomain.com with v=DKIM1; k=rsa; p=.... Wait for DNS propagation, then verify the record resolves.
  4. Enable signing. Turn on DKIM in your mail provider or server, using relaxed/relaxed canonicalization and signing at least the From, To, Subject and Date headers.
  5. Test before enforcing. Send test mail to a mailbox you control, check the Authentication-Results header for dkim=pass, and confirm with the DKIM checker.
  6. Rotate keys yearly. Generate a new selector, publish it, switch signing to it, and delete the old record after a few weeks.

DKIM vs SPF vs DMARC: what is the difference?

DKIM, SPF and DMARC answer different questions, and you need all three. SPF checks whether the sending server is authorized. DKIM checks whether the message content is authentic. DMARC ties them to the From domain and sets the policy.

CheckWhat it provesSurvives forwarding?Defined in
SPFSending server is authorized for the domainNo — the forwarder's IP is not listedRFC 7208
DKIMMessage was signed by the domain and unalteredUsually yesRFC 6376
DMARCFrom domain aligns with SPF or DKIM, plus policyDepends on DKIM survivalRFC 7489

That survival difference is why DMARC depends on DKIM more than on SPF. A forwarded message that fails SPF can still pass DMARC through an aligned DKIM signature. This is also why Gmail and Yahoo's bulk sender rules require DKIM: it is the authentication method that keeps working when mail is relayed. For a fuller picture, see our spear phishing guide, which shows what happens when these checks are missing.

The bottom line

RFC 6376 is a short standard with a long reach. It defines the signature that lets receivers trust a message came from your domain and was not tampered with, using nothing more than DNS and a key pair.

If you send email for a business, publish a 2048-bit DKIM key, sign with relaxed canonicalization, and check the result with the free DKIM checker. Then add SPF and DMARC at p=reject, and your domain stops being an easy target for impersonation.

Frequently asked questions

What does RFC 6376 define?

RFC 6376 defines DKIM, DomainKeys Identified Mail. It specifies the DKIM-Signature header, the DNS key record format, the signing and verification steps, and the canonicalization algorithms. It was published in September 2011 and obsoletes RFC 4871.

Is DKIM the same as DMARC?

No. DKIM is a signing mechanism defined by RFC 6376. DMARC is a separate policy layer that tells receivers what to do when DKIM or SPF checks fail, and it requires the DKIM signing domain to align with the From domain. DKIM proves authenticity; DMARC turns that proof into an enforcement decision.

What key size should DKIM use?

RFC 8301 says signers must use RSA keys of at least 1024 bits and should use at least 2048 bits, and verifiers must not treat signatures from keys under 1024 bits as valid. Ed25519 keys, added by RFC 8463, are the modern alternative and are much shorter for the same security.

Where does the DKIM public key live?

In a DNS TXT record at selector._domainkey.domain, where selector comes from the s= tag and domain from the d= tag in the DKIM-Signature header. The record holds the public key in its p= tag. An empty p= value means the key is revoked.

Does DKIM survive email forwarding?

Usually yes, which is its main advantage over SPF. Forwarding changes the sending IP and breaks SPF, but DKIM signatures travel with the message. A signature only breaks if a forwarder modifies a signed header or the body, for example by adding a footer or changing the subject line.

Why did my DKIM check fail?

Common causes are a missing or wrong DNS key record, a key that is too short, a message modified after signing by a mailing list or footer, or a signature that names the wrong selector. Check the Authentication-Results header for the exact result, then verify the DNS record matches the s= and d= tags.

Do I need DKIM if I already have SPF?

Yes. SPF only checks the sending server's IP address, which forwarding breaks. DKIM survives forwarding and proves the content was not altered. Since February 2024, Gmail and Yahoo also require bulk senders to authenticate with DKIM and publish DMARC, so DKIM is effectively mandatory for volume senders.

Sources

  1. IETF — RFC 6376: DomainKeys Identified Mail (DKIM) Signatures
  2. Wikipedia — DomainKeys Identified Mail
  3. DMARC.ai — What Is DKIM? DKIM Record and Signature Explained
  4. DMARC+ — What Is DKIM? Signatures, Selectors and Key Sizes
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the full text of RFC 6376 on rfc-editor.org, with updates from RFC 8301 and RFC 8463.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free