In S/MIME, how does a detached multipart/signed message differ from an opaque application/pkcs7-mime signed-data message, and when is each chosen?
answer
- where the content travels
- readable without S/MIME?
- two parts against one object
- .p7s against .p7m
basics
~20 smultipart/signed keeps the content readable and adds a detached SignedData part (smime.p7s); opaque application/pkcs7-mime with smime-type=signed-data wraps the content inside SignedData (smime.p7m). Detached is preferred for sending; opaque needs an S/MIME client but survives benign re-encoding.
solid answer
~40 sRFC 8551 defines two signed-only formats. In `multipart/signed` (RFC 1847) the first part is the signed MIME entity, unchanged, and the second is an `application/pkcs7-signature` part (`smime.p7s`) holding a `SignedData` whose `eContent` is absent — a detached signature. The outer `Content-Type` carries `protocol="application/pkcs7-signature"` and a `micalg` naming the digest, such as `sha-256`. Any mail client shows the content; only an S/MIME client verifies it. In the opaque form the content sits inside `SignedData`, sent as `application/pkcs7-mime; smime-type=signed-data` (`smime.p7m`): a client without S/MIME sees only an attachment, but benign intermediaries that rewrap lines or change the transfer encoding no longer touch the signed bytes. RFC 8551 prefers `multipart/signed` for sending and requires receivers to handle both.
code
plaintext · 13 lines[detached form]
Content-Type: multipart/signed; protocol="application/pkcs7-signature";
micalg=sha-256; boundary="..."
(first part: the signed content, unchanged)
Content-Type: application/pkcs7-signature; name=smime.p7s
Content-Disposition: attachment; filename=smime.p7s
[opaque form]
Content-Type: application/pkcs7-mime; smime-type=signed-data;
name=smime.p7m
Content-Disposition: attachment; filename=smime.p7mgo deeper
Recall the two shapes: content readable plus an smime.p7s attachment, or one smime.p7m object that needs an S/MIME client.
Explain the mechanics: eContent absent in the detached SignedData, the protocol and micalg parameters, smime-type=signed-data, and RFC 8551's preference for multipart/signed.
Show you can read a user's report: a lone smime.p7m means opaque S/MIME the client did not process, and a broken clear signature points at a hop that changed the first part.
Weigh the default: clear-signing reaches every correspondent but depends on intact transit, opaque signing survives transit but excludes anyone without S/MIME.
## Two ways to carry one signature RFC 8551, the S/MIME 4.0 message specification, defines two formats for a message that is signed but not encrypted (section 3.5). Both carry the same CMS (Cryptographic Message Syntax, RFC 5652) structure, `SignedData`; they differ only in **where the signed content travels**. - **Detached, or clear-signed:** the `multipart/signed` media type from RFC 1847, the security-multiparts specification. It holds exactly two parts. The first is the signed content, exactly as it was signed, including its own MIME header fields. The second is an `application/pkcs7-signature` part holding a `SignedData` whose `encapContentInfo eContent` field is **absent**: the signature is detached from the content it covers, and the verifier supplies the first part as that content. - **Opaque, or encapsulated:** a single `application/pkcs7-mime` body with `smime-type=signed-data`. The content is stored **inside** `SignedData`, in the `eContent` octet string, and the whole object is DER-encoded binary, usually sent in base64. ## How to recognise each one | | `multipart/signed` | `application/pkcs7-mime` signed-data | |---|---|---| | Where the content is | first part, readable as-is | inside `SignedData` (`eContent`) | | Where the signature is | second part, `application/pkcs7-signature` | in the same object as the content | | Key parameters | `protocol`, `micalg` (plus the multipart boundary) | `smime-type=signed-data` | | Usual file name | `smime.p7s` for the signature part | `smime.p7m` | | Client without S/MIME | shows the message normally, signature as an attachment | shows only an attachment it cannot open | | Re-encoding or rewrapping of the signed content in transit | breaks the signature | cannot reach the signed bytes | The `protocol` parameter must be exactly `"application/pkcs7-signature"`, quoted because the value contains a `/`. The `micalg` parameter names the **digest** algorithm the signer used — `sha-256`, `sha-384` or `sha-512` — so a receiver can hash the first part in one pass while reading it. RFC 8551 lists `md5` and `sha-1` only as historical values that are no longer considered secure, and notes that some early implementations emitted values such as `rsa-sha1`; a receiver should recover gracefully from a `micalg` value it does not recognise. The `smime-type` parameter is optional, but it exists so a client can label a message as signed or encrypted without opening the CMS object. ## Choosing between them RFC 8551 says there are **no hard-and-fast rules** (3.5.1): the choice depends on who receives the message and on how much it matters that S/MIME users can verify it against how much it matters that everyone else can read it. Its general guidance is that `multipart/signed` is **preferred for sending**, and receiving agents **MUST** be able to handle both. 1. **Choose detached** when some recipients may lack S/MIME. They read the message, attachments and all, essentially as if it were unsigned; S/MIME users additionally get a verified signature. This matches RFC 8551's preference for `multipart/signed` when sending. 2. **Choose opaque** when every recipient runs S/MIME and the path includes gateways or relays that rewrap lines or change transfer encodings. The signed bytes are sealed inside the DER object, so those benign changes cannot reach them. 3. **Accept both** on receipt; a compliant client verifies either form. ## The cost of each - **Detached signing depends on every hop leaving the first part byte-for-byte intact.** RFC 1847 says the whole `multipart/signed` container must be treated as opaque in transit, and that agents must not change even its transfer encoding. A relay that changes the first part anyway breaks the signature, and the reader sees a warning rather than a missing message. - **Opaque signing makes the message unreadable** to anyone without S/MIME, which is a real cost for external correspondents and for systems such as archivers or content scanners that need to read the body. - **The inside is identical.** Both forms carry the same `SignedData`, so the signer information, the signed attributes and any certificates the sender includes are the same; only the packaging differs. ## Reading what a user reports When a help-desk ticket says "the email only has a strange smime.p7m attachment", the message was sent in an opaque S/MIME form and the reader's client did not process S/MIME; the `smime-type` value says whether it was `signed-data` or one of the encrypted types, which the material on S/MIME encryption covers. When the reader sees normal text plus an `smime.p7s` attachment, the message was clear-signed and that client simply did not verify it. Neither ticket means the message is damaged; each tells you which format the sender's client chose.
- In a multipart/signed S/MIME message, what must the micalg parameter agree with?With the digest algorithm the signer actually used, which also appears as the `digestAlgorithm` of the `SignerInfo` inside the detached `SignedData`. RFC 1847 says that if the parameter and the control information disagree, it must be treated as an error. The parameter exists so a receiver can hash the first part while reading it, before it reaches the signature part.
- Why does the SignedData in an application/pkcs7-signature part carry no content?Because the content already travels beside it as the first part of the `multipart/signed` message. RFC 8551 requires the `eContent` field to be absent there; the verifier supplies the first part's bytes as the signed content, recomputes their digest and compares it with the `messageDigest` signed attribute.
- Can an S/MIME message signed in the opaque form still be read by a recipient without S/MIME?No. In `application/pkcs7-mime` with `smime-type=signed-data` the content is inside the DER-encoded `SignedData`, and RFC 8551 says such messages cannot be viewed unless the recipient has S/MIME facilities. A client without them shows only an `smime.p7m` attachment. That is the price the opaque form pays for resilience in transit.
A detached signature is a notarised receipt stapled to a letter: anyone can read the letter without the notary, but if someone adds a line to the letter, the receipt no longer matches it. The opaque form seals the letter inside the notary's own envelope: nothing can be added on the way, but only someone with the right opener can read it.
- multipart/signed hides the content until the signature has been verified.
- The opaque signed-data form also encrypts the message body.
- The smime.p7s part carries a full second copy of the message.
- micalg names the signature algorithm, as in the value rsa-sha1.
- A receiving client may support just one of the two signed formats.