What is DKIM canonicalization for, and which algorithms apply when a DKIM-Signature has no c= tag or names only one?
answer
- same bytes on both ends
- prepares hash input only
- two names: header/body
- absent means simple/simple
- one name covers the header
basics
~20 sDKIM canonicalization normalises a message only for hashing, so tolerated transit edits do not break the signature; the delivered message is untouched. A missing c= means simple/simple; a single value such as c=relaxed means relaxed headers and a simple body.
solid answer
~40 sSigner and verifier must hash exactly the same bytes, yet mail systems rewrap long header lines and adjust whitespace in transit. Canonicalization fixes the representation that is fed to the hash. The `c=` tag holds two names, header algorithm then body algorithm, each `simple` (tolerates almost nothing) or `relaxed` (tolerates whitespace changes, header re-folding and header-name case). RFC 6376 section 3.4 says canonicalization only prepares the hash input and MUST NOT change the transmitted message. If `c=` is absent the default is `simple/simple`; if only one name is given it applies to the header and the body uses `simple`, so `c=relaxed` means `c=relaxed/simple`. Verifiers MUST implement both algorithms and MUST ignore a signature that names one they do not recognise.
go deeper
Recall that canonicalization only shapes what gets hashed, that c= has a header half and a body half, and that a missing c= means simple/simple.
Explain the single-value rule, c=relaxed meaning relaxed/simple, and why both ends must apply the signer's recorded algorithm to their own copy.
When a domain's signatures fail on some paths only, read c= on the failing signatures first; a simple header or body half is often the exposure.
Treat the canonicalization choice as part of the signing standard: write the c= value down per mail stream rather than leaving each signer on its default.
## Why a signature needs a canonical form A DKIM signature is a hash of selected header fields and of the message body, signed with the private key of the domain in `d=`. Hashes are unforgiving: one changed space produces a completely different digest, and the signature then no longer verifies. Mail, however, is handled by many systems between the signer and the verifier, and some of them make changes that nobody would call tampering. They rewrap a long header line onto two lines, turn a tab into a space, drop spaces at the end of a line or change the capitalisation of a header field name. **Canonicalization** is the agreed recipe that both ends apply to their copy of the message before hashing, so that changes the signer is willing to tolerate disappear from the hash input. RFC 6376 (September 2011) section 3.4 is explicit about its limits: canonicalization "simply prepares the email for presentation to the signing or verification algorithm" and "MUST NOT change the transmitted data in any way". The recipient's mailbox holds the message as it arrived; only the hash input is normalised. ## The c= tag and its two halves The signer records its choice in the `c=` tag of the `DKIM-Signature` header field. The tag holds up to two names separated by a slash, **header algorithm first, body algorithm second**. RFC 6376 defines two algorithms for each half: - **`simple`** tolerates almost no modification. Header fields are hashed exactly as they are; the body is hashed as it is apart from empty lines at its end. - **`relaxed`** tolerates common modifications: whitespace replacement, header-line rewrapping and, for headers, the case of the field name. The defaulting rules are short and often misremembered: | `c=` as written | Header algorithm | Body algorithm | |---|---|---| | tag absent | `simple` | `simple` | | `c=simple` | `simple` | `simple` | | `c=relaxed` | `relaxed` | `simple` | | `c=relaxed/relaxed` | `relaxed` | `relaxed` | | `c=simple/relaxed` | `simple` | `relaxed` | The trap is the third row. A signer that writes `c=relaxed` intending relaxed handling everywhere gets a body hashed with `simple`, because RFC 6376 section 3.5 says that when only one algorithm is named it is used for the header and `simple` is used for the body. ## What verifiers are required to do 1. **Implement both algorithms.** RFC 6376 says verifiers MUST implement `simple` and `relaxed`, so a signer can pick either for either half. 2. **Apply the signer's choice, not their own.** The verifier reads `c=` from the signature it is checking and canonicalizes its copy the same way. 3. **Ignore unknown algorithms.** Further algorithms may be registered later (IANA keeps a DKIM-Signature canonicalization registry for header and for body), and verifiers MUST ignore a signature that uses an algorithm they do not recognise. The header algorithm also applies to the `DKIM-Signature` field itself, which is hashed last with its `b=` value treated as empty. How the signed header list and the two hashes are built belongs to the material on message signing; this topic keeps the normalisation applied before hashing. ## What canonicalization is not - It is **not a repair step**: it never fixes the delivered copy, and it never makes a broken message look intact to the reader. - It is **not a content filter**: tolerating whitespace does not mean tolerating changed words, added lines or re-encoded attachments. - It is **not negotiated**: the verifier cannot pick a looser algorithm than the signer recorded. - It is **not a format converter**: it assumes CRLF line endings and the transfer encoding the message travels in, and does not translate a host's local storage format. ## Reading c= on a received message The tag sits in clear text in the signature field. In an excerpt such as `DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=example.com; s=s2026a; ...` the single value means relaxed headers and a **simple body**, so any whitespace change a relay makes to the body still breaks this signature even though the signer may have believed it was fully relaxed. A signature with no `c=` at all is the strictest case. ## Choosing as a signer RFC 6376 section 5.4.1 says signers SHOULD choose based on the types of messages they send and their aversion to risk. Its examples: sites sending purchase receipts that no list or other software is expected to modify will generally prefer `simple`, while sites sending mostly person-to-person mail will likely prefer `relaxed` for resilience in transit. Whatever is chosen, it is visible to anyone reading the message's `DKIM-Signature` field, which makes the `c=` value the first thing to check when a domain's signatures fail only on some paths.
- What does a verifier do when a DKIM-Signature's c= names an algorithm it does not recognise?RFC 6376 section 3.4 says verifiers MUST ignore signatures that use unrecognised canonicalization algorithms. Ignoring that signature does not change how any other signature on the message is checked. The rule exists because new algorithms can be registered later, and a verifier cannot reproduce a hash input it does not know how to build.
- Is the DKIM-Signature header field itself canonicalized before hashing?Yes. RFC 6376 section 3.7 has the DKIM-Signature field hashed after the signed header fields, with its b= value treated as empty and canonicalized with the header algorithm from c=. So a relay rewrapping only the long DKIM-Signature line is enough to break a signature made with simple headers.
- A DKIM-Signature without c= is verified as relaxed/relaxed.
- Writing c=relaxed applies relaxed to both header and body.
- Canonicalization rewrites the message so recipients see the normalised copy.
- A verifier may support only relaxed and still conform to RFC 6376.
- Header and body must always use the same canonicalization algorithm.