DKIM Key Size: 1024 vs 2048 Bits and Safe DNS Publishing
A 2048-bit RSA DKIM key is the right default when your sender and DNS provider support it. RFC 8301 requires at least 1024 bits and recommends at least 2048. The longer public key will usually exceed one DNS TXT character-string, so publish it as one TXT record made from multiple quoted strings, not as multiple TXT records.
The difference is measurable. A local fixture run with OpenSSL 3.0.13 generated fresh 1024-bit and 2048-bit RSA keys, exported each public key as DER, and Base64-encoded the result for the DKIM p= value:
| RSA key | p= characters |
Complete record characters | Fits one 255-byte string? |
|---|---|---|---|
| 1024-bit | 216 | 234 | Yes |
| 2048-bit | 392 | 410 | No |
The record length includes v=DKIM1; k=rsa; p=. RSA keys are randomized, but the encoded public-key length is fixed for these sizes and export format. The important operational result is that a normal 2048-bit record needs safe TXT splitting.
The standards decision is shorter than the DNS record
RFC 8301 sets the current RSA baseline for DKIM: signers must use at least 1024 bits, should use at least 2048 bits, and verifiers must handle keys from 1024 through 4096 bits. It also requires rsa-sha256 and retires rsa-sha1.
My decision rule is therefore simple:
- Use a provider-managed 2048-bit key when it is available.
- Use a self-managed 2048-bit key when your authoritative DNS accepts and returns the complete record correctly.
- Treat 1024 bits as a compatibility floor, not a target for new deployments.
- Reject anything below 1024 bits. It cannot produce a valid DKIM result under RFC 8301.
That choice also matches current receiver guidance. Gmail requires at least 1024 bits for mail sent to personal Gmail accounts and recommends 2048 bits when the DNS provider supports it.
The 255-byte limit applies to each quoted string
A DNS TXT record contains one or more character-strings. Each string has a one-byte length field, leaving at most 255 data bytes. A 410-character DKIM value can still be one TXT record because its RDATA may contain several strings.
DKIM defines what happens next: a verifier concatenates those strings with no intervening whitespace.
This hypothetical zone-file shape is correct:
selector2026._domainkey.example.com. 3600 IN TXT (
"v=DKIM1; k=rsa; "
"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."
"...remaining-public-key-characters..."
)
The ellipses are placeholders, so this is not a deployable key. In a real record, every character of the provider-generated or exported public key must appear exactly once.
The dangerous alternative is creating two TXT records at the same selector name. That produces multiple records in the RRset, not two pieces of one record. RFC 6376 requires the DKIM TXT record to be unique for a selector. Duplicate records can make lookup ambiguous or fail verification.
Some DNS control panels accept one long value and split it automatically. Others expect quoted chunks. Cloudflare documents both the 255-character string limit and automatic concatenation. Follow the interface you actually use, then inspect the DNS answer instead of trusting how the form displayed it.
Generate and measure the public value before publishing
If you operate your own DKIM signer, this reproducible shell fixture creates a 2048-bit RSA key and extracts the Base64 public value. The private key stays in dkim-private.pem; it never belongs in DNS.
umask 077
openssl genpkey -algorithm RSA \
-pkeyopt rsa_keygen_bits:2048 \
-out dkim-private.pem
openssl pkey -in dkim-private.pem \
-pubout -outform DER |
openssl base64 -A > dkim-public.txt
wc -c dkim-public.txt
fold -w 200 dkim-public.txt
With OpenSSL 3.0.13, wc returned 392 for the 2048-bit p= value. The fold command creates convenient 200-character chunks, each below the DNS limit. It does not create separate DNS records. Your DNS syntax or API still needs to store those chunks inside one TXT record.
Use your mail platform's supported key-generation workflow in production. A private DKIM key needs access controls, backup and rotation appropriate to a signing secret. The commands above explain the record shape; they are not a substitute for your sender's key-management procedure.
Managed senders may give you CNAMEs instead
If the provider gives you CNAME records, publish those CNAMEs exactly. Do not extract a public key and replace the delegation with a home-made TXT record.
Microsoft 365 uses two selector CNAMEs for custom domains and says TXT records are not supported for that setup. Microsoft currently supports rotating a domain to 2048-bit keys, with each selector changing as it becomes active. Amazon SES uses 2048 bits by default for Easy DKIM and manages the signing keys behind its published configuration.
The fair objection is that DNS chunking should not matter if a provider manages everything. Often it does not. But it matters the moment you bring your own key, migrate DNS, copy a value through infrastructure as code, or troubleshoot a selector that looks complete in a dashboard but is truncated on the wire.
Key size is also not the same problem as key rotation. A safe change needs a new selector or the provider's supported dual-selector process so that receivers can still validate messages signed with the old key. The separate guide to DKIM selectors and rotation owns that cutover sequence.
Verify the record the way a receiver sees it
After publishing, query the exact selector and signing domain from a real DKIM-Signature header:
dig +short TXT selector2026._domainkey.example.com
dig +noall +answer TXT selector2026._domainkey.example.com
A healthy answer has one TXT record. It may display several adjacent quoted strings, which is fine. Read them as one value and check that:
v=DKIM1andk=rsaare intact.- The concatenated
p=value contains the complete Base64 public key with no added or missing characters. - No second TXT record exists at the same selector name.
- A message signed by the matching private key returns
dkim=passin the receiver's authentication results.
A DNS lookup proves publication, not signing. The final message test catches the wrong selector, wrong private key, stale DNS, and signing-service mistakes that a record-only checker cannot see. If DKIM passes but the message still lands in spam, the guide to authentication versus inbox placement explains that separate decision.
Email verification does not inspect your sender's DKIM key size. It evaluates a recipient address and the available domain, provider, and mailbox evidence, which is a different trust boundary. Keep sender authentication tests in the mail pipeline and address-quality decisions in the signup or list workflow.
The deployment is complete when the authoritative DNS answer reconstructs one unbroken public key and a newly sent message verifies with the matching selector. For a new RSA deployment, make that key 2048 bits.