What DKIM key length should you use?
Use a 2048-bit RSA key for DKIM wherever the sending platform and DNS host support it. RFC 8301 makes 1024 bits the minimum DKIM key length and says signers should use at least 2048 bits. A 1024-bit key still verifies today, but it is the floor, not the target, and 4096 bits adds DNS cost without a practical benefit for most domains.
This guide covers what the standards say about DKIM (DomainKeys Identified Mail) key sizes, where Ed25519 fits, why a 2048-bit key has to be split across several quoted strings in a DNS TXT record, what Microsoft 365, Google Workspace and Mailgun actually do, how to measure the key length of any selector with one command, and how an MSP (managed service provider) moves a portfolio from 1024 to 2048 without a signing gap. For the protocol basics, start with the DKIM pillar guide. If you have not configured signing yet, how to set up DKIM walks through each platform first.
Key takeaways
- RFC 8301 says signers MUST use RSA keys of at least 1024 bits and SHOULD use at least 2048 bits. Verifiers MUST handle keys from 1024 to 4096 bits, and
rsa-sha1must not be used at all. - A 2048-bit public key is about 392 base64 characters, so it cannot fit in one 255-character TXT string. It must be published as two or more quoted strings in the same record.
- Microsoft Learn still documents
1024as the default-KeySizeforNew-DkimSigningConfig. Check every Microsoft 365 tenant and upgrade withRotate-DkimSigningConfig -KeySize 2048. - Change key length by publishing a new selector, switching signing to it, and retiring the old one. Never overwrite a live key in place.
- Ed25519 (RFC 8463) is a valid addition alongside RSA, not a replacement, because receiver support is uneven.
What do the standards actually require for DKIM key length?
RFC 8301 sets the rules: signers must use RSA keys of at least 1024 bits, should use at least 2048 bits, and must sign with rsa-sha256. Verifiers must validate keys from 1024 to 4096 bits. It also states that rsa-sha1 must not be used for signing or verifying, which ended the old SHA-1 option from RFC 6376.
The original RFC 6376 allowed keys as small as 512 bits and permitted rsa-sha1. RFC 8301, published in 2018, updated it because both had become too weak. The relevant lines from section 3 are short enough to quote:
- "Signers MUST use RSA keys of at least 1024 bits for all keys."
- "Signers SHOULD use RSA keys of at least 2048 bits."
- "Verifiers MUST be able to validate signatures with keys ranging from 1024 bits to 4096 bits."
- "rsa-sha1 MUST NOT be used for signing or verifying."
In standards language, SHOULD means you need a good reason to deviate. A DNS host that cannot store a long TXT record is one; habit is not.
National guidance agrees. The UK NCSC (National Cyber Security Centre) DKIM guidance says "We recommend you use a 2048-bit key" and suggests rotating keys every 12 months.
Does DMARCbis change anything about key length?
No. RFC 9989, the DMARCbis core standard that replaced RFC 7489, does not set a DKIM key size. It only needs a valid, aligned DKIM signature. Key length matters indirectly: a weak or broken key that stops verifying removes one of your two paths to a DMARC pass, which hurts most when SPF breaks on forwarding.
How do 1024, 2048 and 4096-bit keys compare?
A 2048-bit key is the practical sweet spot: it meets the RFC 8301 recommendation, fits in a normal DNS response, and every major receiver verifies it. A 1024-bit key is compliant but below recommendation. A 4096-bit key is allowed but makes the DNS record roughly twice as large for little practical gain.
The base64 lengths below come from encoding real public keys of each size (the p= value only, before v=DKIM1; k=rsa; is added).
| Key type | p= length (base64 chars) |
TXT strings needed (255 max each) | RFC 8301 status | Practical verdict |
|---|---|---|---|---|
| RSA 1024 | about 216 | 1 | Minimum (MUST) | Upgrade when you next rotate |
| RSA 2048 | about 392 | 2 | Recommended (SHOULD) | Default choice |
| RSA 4096 | about 736 | 3 | Verifiers MUST support | Rarely worth it |
| Ed25519 | 44 | 1 | Separate standard (RFC 8463) | Add alongside RSA only |
Is a 1024-bit DKIM key unsafe?
A 1024-bit key is not known to be publicly broken for DKIM, but it has a much smaller security margin than 2048 bits, and standards bodies have recommended moving away from 1024-bit RSA for years. Because DKIM keys are long-lived and public, treat 1024 bits as technical debt to clear at the next planned rotation, not as an emergency.
Why is 4096 usually not worth it?
A 4096-bit key roughly doubles the size of the DNS answer compared with 2048 bits, which raises the chance that a response needs EDNS(0) or a retry over TCP. RFC 8301 only obliges verifiers to support up to 4096 bits, so you also have no headroom. The security gain over 2048 bits is not what limits DKIM in practice.
The DNS detail is worth being precise about. Classic DNS over UDP was limited to 512 bytes by RFC 1035. EDNS(0), RFC 6891 lets resolvers advertise larger UDP buffers, and when a response still does not fit, the server sets the truncation flag and the resolver retries over TCP. Modern resolvers handle all of this, so a 4096-bit record usually resolves. But it adds a failure surface (firewalls that drop fragments or block TCP port 53, older appliances, small buffer sizes) that a 2048-bit record mostly avoids.
Should you use Ed25519 for DKIM?
Ed25519 (RFC 8463) is a valid DKIM algorithm with a 44-character public key, but you should only add it as a second signature next to an RSA one. Receiver support is not universal, and a receiver that does not support Ed25519 cannot use that signature, so the RSA signature still has to carry the message.
RFC 8463 defines the ed25519-sha256 algorithm and the k=ed25519 key type. Its example key record looks like this:
brisbane._domainkey.football.example.com. IN TXT "v=DKIM1; k=ed25519; p=11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo="
Section 6 of the RFC lets signers "add multiple signatures that use old and new signing algorithms", and its appendix notes the signatures are independent, so either is valid without the other. This is dual signing: one RSA signature at one selector, one Ed25519 signature at another.
In practice, most hosted platforms (Microsoft 365, Google Workspace and most ESPs, email service providers) sign only with RSA and give you no Ed25519 option. Dual signing is mainly relevant for self-hosted MTAs (mail transfer agents) such as Postfix with a signing milter. Before relying on it, send test messages to the mailbox providers your clients care about and read the Authentication-Results header for each signature. We have not verified a current, authoritative support list for every major receiver, so test rather than assume.
How is a 2048-bit key published in a DNS TXT record?
A single TXT character string can hold at most 255 characters, so a 2048-bit DKIM key is published as one TXT record containing two or more quoted strings. Receivers join the strings together with no separator before parsing. The record is still one record; only its value is split.
RFC 6376 section 3.6.2.2 says that when a key record has multiple strings, they are concatenated together without adding spaces. Google's DKIM troubleshooting page puts it plainly: you "can not enter a 2048-bit key as a single text string with a 255-character TXT record limit", and if you try, the key "might be truncated".
What does a correct 2048-bit record look like?
Here is a correctly split record, as returned by dig (the key is a real 2048-bit test key generated for this article):
$ dig TXT s2026._domainkey.example.com +noall +answer
s2026._domainkey.example.com. 3600 IN TXT "v=DKIM1; k=rsa; " "p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxOKihClOuCtH6tabHcBRhj8hilnJ0xoVey9ycp1hdn6SoNMQu4phnR6mlf9F3R5wcRIv5fhVMtQ+2p3dqgS/baB11c5l1kR+ZVQFS6G9s/dMImL/B+61YTJMQRjbEftrFGcP7JIdK2PTGd4jbbyPwpLYilJ2" "JIPIy6YTfGmytKc0EOltoBKpKR4kNT5nPAKxUWSJqJpUk9pX5yIeiqNKgSMLJ45d010HuEStIYJqEAStM/SahjHkZ1BiFEiHYH1vNp1GGmFpKYLtAHiyQy3MaSL53S+I0JlQTaeX5eOCd0iNzgLEmruGzCyYTsW7EEqJUyZQ2XXChlV+BlD8mjhmkwIDAQAB"
Three strings, each under 255 characters, in one answer. The split point does not matter because the strings are rejoined exactly. What does matter:
- One record, not several. Two separate TXT records at the same selector name is a different (and broken) setup.
- No added characters. A space, line break or stray quote inside the key changes the decoded bytes and the signature fails.
- Order preserved. The strings must come back in the order you entered them.
On Windows, Resolve-DnsName -Type TXT s2026._domainkey.example.com lists each segment in its Strings property.
Which DNS providers split the value for you?
DNS hosts fall into two groups: those whose control panel accepts the full key and splits it into strings on save, and those that expect you to enter the quoted segments yourself. Behaviour also changes between panel versions, so check what your host does today and test the result with dig.
Amazon Route 53 is in the second group. AWS's knowledge centre article on DKIM TXT errors says a TXT string can contain up to 255 characters, and tells you to split the key into parts and enclose each in double quotes in the Value field. Google gives the same manual-split advice for any host that needs it, and suggests asking your host whether longer TXT values are supported.
The safest MSP rule is host-agnostic:
- Paste the record, save, then query it from outside with
digor our DNS lookup tool. - Run the key-length check below. If it decodes to the expected bit length, the split is correct.
- If decoding fails, look for an inserted space or doubled quotes at the split point.
Where a platform offers CNAME delegation (Microsoft 365, Mailgun Automatic Sender Security and most ESPs), the long key lives in the provider's DNS and the 255-character problem disappears from your zone.
What key length do the major providers use?
Provider defaults differ, and some documented defaults are still 1024 bits. Google Workspace and Mailgun steer you to 2048 bits. Microsoft Learn documents 1024 as the default key size for new DKIM configurations created in PowerShell, so every Microsoft 365 tenant is worth checking.
| Platform | What the vendor documents | How to get 2048 | Publishing method |
|---|---|---|---|
| Microsoft 365 | -KeySize accepts 1024 or 2048; Microsoft Learn lists 1024 (default) for New-DkimSigningConfig |
New-DkimSigningConfig -KeySize 2048, or Rotate-DkimSigningConfig -KeySize 2048 for existing domains |
2 x CNAME (selector1, selector2) |
| Google Workspace | Admin console offers 2048 and 1024; recommends 2048 if the DNS host supports it | Generate a new 2048-bit record in Admin console | 1 x TXT (split strings) |
| Mailgun | Automatic Sender Security uses 2048-bit keys, rotated every 120 days by default | Enable Automatic Sender Security, or manually create a 2048-bit key on a new selector | 2 x CNAME (automatic) or TXT (manual) |
How do you move Microsoft 365 from 1024 to 2048 bits?
Run Rotate-DkimSigningConfig -Identity <domain> -KeySize 2048 in Exchange Online PowerShell. Microsoft documents that the new size applies to the next active selector at the first rotation, and that a rotation takes four days (96 hours) to take effect. A second rotation later upgrades the other selector.
From Microsoft's DKIM configuration article on Microsoft Learn:
# See the current key size of both selectors
Get-DkimSigningConfig -Identity example.com |
Format-List Name,Enabled,Selector1KeySize,Selector2KeySize,RotateOnDate,SelectorAfterRotateOnDate
# Rotate to a 2048-bit key (applies to the next active selector)
Rotate-DkimSigningConfig -Identity example.com -KeySize 2048
Because Microsoft 365 uses CNAMEs, no DNS change is needed for the rotation itself. You cannot start another rotation while one is in progress. If you are creating DKIM for a new domain in PowerShell, pass -KeySize 2048 explicitly. The Defender portal procedure on the same page does not state a key size, so read Selector1KeySize and Selector2KeySize after enabling rather than assuming.
How do you move Google Workspace to 2048 bits?
In the Google Admin console, go to Apps > Google Workspace > Gmail > Authenticate email and generate a new record with 2048 selected. Google's Set up DKIM page confirms that "If you previously used a 1024-bit key, you can switch to a 2048-bit key if your domain provider supports them."
Use a new selector prefix (for example google2026) instead of overwriting google, so the old key keeps verifying mail already in transit. Publish the split TXT record, wait until it resolves, then click Start authentication.
What does Mailgun do?
Mailgun's DKIM security documentation says Automatic Sender Security uses 2048-bit keys behind two CNAME records and rotates them every 120 days by default (minimum interval five days). Manual keys can be 1024 or 2048 bits, and Mailgun describes upgrading by creating a 2048-bit key on a unique selector, testing, then deleting the old key. The Mailgun DMARC alignment guide covers the rest of that setup.
How do you check a domain's DKIM key length?
Fetch the TXT record for the selector, strip the quotes, extract the p= value, base64-decode it and let OpenSSL report the size. The one-liner below prints a line such as Public-Key: (2048 bit) for any RSA DKIM key, including CNAME-delegated ones, because dig follows the CNAME.
SEL=selector1; DOM=example.com
dig +short TXT "${SEL}._domainkey.${DOM}" | grep '^"' | tr -d '" n'
| sed 's/.*p=//; s/;.*//' | base64 -d
| openssl pkey -pubin -inform DER -noout -text | head -1
grep drops any CNAME line, tr removes quotes and spaces (which also rejoins split strings), sed keeps the p= value, and openssl pkey decodes it and prints the bit length (tested with OpenSSL 3.0).
If the command errors, the record is malformed, which is a finding in itself. An empty p= means the key has been revoked. For Ed25519 keys the decoded value is a raw 32-byte key rather than DER, so just check for k=ed25519 and a 44-character p=. You need the selector names first: read them from the s= tag of real message headers or from the selector field in DMARC aggregate reports. DKIM selectors explained covers where to find them, and our DKIM validator does the lookup in a browser.
How do you migrate from 1024 to 2048 bits safely?
Migrate with a new selector, never by replacing the key at the existing one. Publish the 2048-bit public key under a fresh selector, confirm it resolves and decodes to 2048 bits, switch signing to it, watch the results, and only then remove the 1024-bit record. Each step is reversible until the last.
This is the same dual-publish pattern described in how to rotate DKIM keys safely, applied to a size change:
- Inventory. List every sender for the domain and its selector from DMARC aggregate (RUA) reports and message headers.
- Generate. Create a 2048-bit key in the platform, or with
openssl genrsa 2048for a self-hosted MTA. Give it a new selector such ass2026. - Publish. Add the TXT record (split strings) or the provider's CNAMEs. Keep the old 1024-bit record untouched.
- Verify DNS. Run the key-length one-liner from outside the client's network. It must print
2048 bit. - Switch signing. Point the platform at the new selector. Microsoft 365 does this through
Rotate-DkimSigningConfig; Google through Start authentication. - Confirm in headers. Send to a test mailbox and check
s=s2026in theDKIM-Signatureanddkim=passinAuthentication-Results. - Watch reports. Give aggregate reports a few days. The DKIM pass rate for that source should not drop.
- Retire. After a clean week or two, remove the old selector's record or publish it with an empty
p=to revoke it.
Do one sender at a time: Microsoft 365, a CRM and a marketing platform are three migrations, each with its own selector.
How should an MSP audit key length across a client portfolio?
Build one row per domain and selector, record the key type, bit length and how the key is published, then sort by risk. CNAME-delegated keys are fixed in the provider's console; self-published TXT keys are fixed in the client's DNS. The table below is a template with fictional example data.
| Client domain | Sender | Selector | Key | Published as | Action |
|---|---|---|---|---|---|
| example-law.co.uk | Microsoft 365 | selector1 | RSA 1024 | CNAME | Rotate-DkimSigningConfig -KeySize 2048, rotate again later |
| example-law.co.uk | Marketing ESP | k1 | RSA 2048 | CNAME | None |
| example-dental.com | Google Workspace | RSA 1024 | TXT | New 2048-bit key on google2026 selector |
|
| example-dental.com | Self-hosted web server | default | RSA 1024 | TXT | Generate 2048 key, new selector, retire default |
| example-build.com | Mailgun (manual key) | mx | RSA 2048 | TXT | Consider Automatic Sender Security for rotation |
Practical points for running this at scale:
- Selectors come from data, not guesses. Aggregate reports list the selector of every DKIM result, which catches senders nobody documented. Our guide on auditing client domains for DMARC risk covers the wider audit.
- Track key age and change control. Record key creation dates against the NCSC 12-month suggestion, and treat each migration as a scheduled change with a rollback to the old selector.
- Common failures. Truncated keys, duplicate records and stale selectors are covered in DKIM management for MSPs.
dmarc.ai processes DMARC aggregate reports for many client domains in one place, which makes it easier to see which selectors each source actually signs with before and after a migration. See DMARC for MSPs for how that fits a managed service.
FAQ
Is a 1024-bit DKIM key still accepted?
Yes. RFC 8301 sets 1024 bits as the minimum for signers, and verifiers must accept keys from 1024 to 4096 bits, so a 1024-bit signature still verifies at major receivers. It is below the 2048-bit recommendation in RFC 8301 and NCSC guidance, so plan an upgrade at your next scheduled rotation rather than leaving it indefinitely.
Why does my 2048-bit DKIM record fail after I paste it?
The usual cause is the 255-character string limit. Either the host truncated the key, or it inserted a space or extra quotes where it split the value. Query the record with dig, rejoin the strings and decode the p= value with OpenSSL. If decoding fails or reports the wrong size, re-enter the key as correctly quoted segments.
Does a longer DKIM key improve deliverability?
Not directly. Mailbox providers check whether the signature verifies and aligns with the From domain; they do not reward 4096 bits over 2048. A key that verifies reliably matters more than its size. A 2048-bit key meets the standard's recommendation and the NCSC's, and avoids the DNS size issues that very long records can cause.
Can I change key length without changing the selector?
You can, but you should not. Replacing the key at a live selector makes messages already signed with the old key fail verification while they are still in transit or being re-checked. Publishing the new key under a new selector lets both keys verify during the overlap, and lets you switch back instantly if something goes wrong.
Do Microsoft 365 and Google Workspace support Ed25519?
Their DKIM documentation describes RSA keys only: Microsoft offers 1024 or 2048-bit RSA, and Google offers 2048 or 1024-bit keys. Ed25519 dual signing is mainly an option for self-hosted mail servers. If you add it, keep the RSA signature, because receivers that do not support Ed25519 rely on the RSA one.