It's a common question I hear when people are diving into the technical details of email authentication: does DKIM sign the email body or just the headers? The short answer is that it signs both. DKIM, which stands for DomainKeys Identified Mail, is designed to protect the integrity of an email message, ensuring that key parts of it haven't been altered on its journey from the sender to the recipient.
At its core, DKIM works by adding a digital signature to an email. This isn't a signature you can see, like a name at the bottom of a message. Instead, it's a cryptographic signature contained within a special email header. As eSecurity Planet explains, when a message arrives with this signature, the receiving server can verify it to confirm the email's authenticity.
The power of DKIM lies in what it chooses to sign. It doesn't just sign the entire email as one big block. Instead, it selectively signs the most important components: a specific set of headers and the message body. This is all managed through the DKIM-Signature header, which is added to the email by the sending mail server.
This special header contains several important tags, but a few are critical to understanding what gets signed:
One of the complexities of email is that different mail servers can make tiny, insignificant changes to a message in transit, like adding extra whitespace or rewrapping long lines of text. Normally, this would change the hash and break the DKIM signature. To prevent this, DKIM uses a process called "canonicalization" to normalize the headers and body before they are hashed.
There are two main canonicalization algorithms: simple and relaxed. The simple algorithm is very strict and tolerates almost no changes, while the relaxed algorithm allows for common modifications like changes in whitespace. Most senders use the relaxed setting for both the header and body to prevent legitimate emails from failing DKIM checks due to minor, harmless modifications made by intermediate mail servers.
So, to come back to the original question: DKIM absolutely signs the email body, and it also signs a selection of the most important email headers. The body's integrity is protected via the body hash (bh=), and the headers' integrity is protected by including them in the final signature hash (b=). This dual approach is what allows DKIM to effectively verify that a message is authentic and has not been maliciously altered.