opyeb spfdkim

spfdkim · DKIM

DKIM key records and key length

DKIM signs mail so transit changes are detectable. The public key lives on a selector._domainkey TXT record, and its length and revocation state decide the result.

What DKIM proves

DKIM has the sending server sign selected headers and the body, and the receiving server verify that signature with a public key fetched from DNS. If any signed header changes in transit, verification fails. Where SPF looks at the sending IP, DKIM looks at the integrity of the message itself.

Record name and location

The public key sits on `._domainkey.` TXT. That name combines d= (domain) and s= (selector) from the signature header. Publishing several selectors makes rotation and service separation easier.

selector1._domainkey.example.com. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..."

The seven tags

TagMeaningCare
vVersion. Must be DKIM1 and the first tag.Missing or wrong makes the whole record invalid.
kKey type. rsa by default, ed25519 allowed.Omitted means rsa.
pThe Base64-encoded public key (SPKI DER).Empty means revoked.
tFlags. y for testing, s for strict subdomain use.y lets receivers ignore failures.
sAllowed services. * or email.Other values are rarely implemented.
hAllowed hashes. sha256, sha1.sha1 is not recommended.
nAn operator note.Keep it short; it enlarges the record.

Reading the key size from p=

p= is a Base64-encoded SubjectPublicKeyInfo. Decoding it yields DER, whose BIT STRING holds the public key. For RSA, the modulus integer minus leading zeros, multiplied by eight, is the bit size. A 2048-bit key is typically 294 DER bytes, or roughly 392 Base64 characters.

For Ed25519 the algorithm OID is 1.3.101.112 and the BIT STRING holds a 32-byte key. The Base64 string is around 60 characters and the strength is about 256 bits. Not every receiver supports Ed25519 yet, so check before switching.

KeyTypical Base64 lengthVerdict
RSA 1024about 216 charactersWarning; rotate
RSA 2048about 392 charactersRecommended
RSA 4096about 736 charactersUsable but a long record
Ed25519about 60 charactersRecommended where supported
empty p=0 charactersRevoked key

Rotation and revocation

  1. Generate a key pair under a new selector (selector2) and publish the public key first.
  2. After propagation, switch the sender to sign with the new selector.
  3. Confirm DKIM passes for the new selector in receiver logs.
  4. Empty the old selector's p= or remove its record.

An empty p= revokes a key; deleting the record does not. Without a record, a signed message reports "no key" and may be treated as a verification failure. Keep the revoked record for a while.

Record length and 255 bytes

A 2048-bit RSA p= is 392 characters before any tags, so it cannot fit in one 255-byte TXT string. DNS stores it as several strings that the receiver concatenates. Some providers split automatically; typing it by hand means splitting the quoted strings. The spfdkim generator produces the split and the BIND, Cloudflare and Route53 syntax together.

Questions

What is a selector?

A name that lets one domain publish several keys at once. It must match the s= value in the signature header, so selector1 means a lookup of selector1._domainkey.example.com TXT.

Is a 1024-bit key still acceptable?

It is not recommended. 1024-bit RSA no longer offers enough strength, and major receivers and regulators require 2048 bits or more. Rotating via a new selector allows a zero-downtime change.

What does an empty p= mean?

That the key for this selector is revoked. Even a signed message cannot be verified without a public key, so DKIM fails. It is the way to disable a leaked or lost key.

Paste a p= value and the tool decodes the Base64 SPKI DER to the real key size.

Open the tool

This guide follows RFC 7208 (SPF), RFC 6376 (DKIM), RFC 7489 (DMARC), the BIMI Group specifications and RFC 8617/8616 (ARC and DMARC aggregate reporting). Every example record is synthetic.