DKIM key length and rotation: 1024 or 2048 bits?

Which key size to use, why SHA-1 and 512-bit keys fail, and how to rotate keys without breaking mail.

Which key size

KeyStatus
RSA 512 or 768 bitsRejected. Receivers treat signatures with these keys as failed; they can be cracked.
RSA 1024 bitsThe minimum receivers still accept. Fine for now, but plan to move up.
RSA 2048 bitsRecommended. Supported everywhere.
Ed25519Modern and short, but not every receiver verifies it yet. Only use it next to an RSA signature.

Also check the hash algorithm: signatures must use rsa-sha256. SHA-1 is no longer trusted, and a key record restricted to h=sha1 makes every signature fail.

A 2048-bit key doesn't fit in one 255-character TXT string. Your DNS panel has to split it into several strings in one record; most do this automatically. Check the result, because a broken split means no valid key.

Rotating keys without breaking mail

Rotating means replacing your signing key periodically, typically every six to twelve months, or immediately if a key may have leaked. Use a new selector for each key so the old and new key can exist side by side:

  1. Generate a new key pair and publish the public key at a new selector, for example s202610._domainkey.
  2. Wait until DNS has propagated (at least the TTL of the record, a day to be safe).
  3. Switch your mail server to sign with the new selector.
  4. Keep the old public key published for another week or so: messages signed with it may still be in transit or checked later.
  5. Revoke the old key by publishing it with an empty value (v=DKIM1; p=), or remove it.

Hosted services (Microsoft 365, Google Workspace, most email platforms) rotate for you once DKIM is set up with their CNAME records. If you publish TXT keys yourself, rotation is your job.

Testing mode

A key record with t=y says the domain is testing DKIM, and receivers may ignore its signatures. Remove the flag once signing works.