DKIM key records and key length
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 `
selector1._domainkey.example.com. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..."
The seven tags
| Tag | Meaning | Care |
|---|---|---|
| v | Version. Must be DKIM1 and the first tag. | Missing or wrong makes the whole record invalid. |
| k | Key type. rsa by default, ed25519 allowed. | Omitted means rsa. |
| p | The Base64-encoded public key (SPKI DER). | Empty means revoked. |
| t | Flags. y for testing, s for strict subdomain use. | y lets receivers ignore failures. |
| s | Allowed services. * or email. | Other values are rarely implemented. |
| h | Allowed hashes. sha256, sha1. | sha1 is not recommended. |
| n | An 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.
| Key | Typical Base64 length | Verdict |
|---|---|---|
| RSA 1024 | about 216 characters | Warning; rotate |
| RSA 2048 | about 392 characters | Recommended |
| RSA 4096 | about 736 characters | Usable but a long record |
| Ed25519 | about 60 characters | Recommended where supported |
| empty p= | 0 characters | Revoked key |
Rotation and revocation
- Generate a key pair under a new selector (selector2) and publish the public key first.
- After propagation, switch the sender to sign with the new selector.
- Confirm DKIM passes for the new selector in receiver logs.
- 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 toolThis 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.