In S/MIME, what does a recipient learn, and fail to learn, when a message is signed then encrypted rather than encrypted then signed?
answer
- which layer is outermost
- who can see the signer
- verifying without a private key
- signature over plaintext or over ciphertext
basics
~20 sSigning first hides the signer and binds the signature to the plaintext, though the encryption layer outside it is not covered. Encrypting first exposes the signer and allows verification without a private key, but shows only that the encrypted block is unaltered.
solid answer
~40 sRFC 8551 section 3.7 lets signing and encrypting nest in either order and states the trade-offs. Signed then encrypted: relays cannot see who signed, and after decrypting the recipient can assume the signed message is unaltered and relate the signer to the plaintext, but the encryption layer outside the signature is not authenticated by it. Encrypted then signed: the signer is visible to everyone, and anyone with the signer's certificate can verify without a private key, which suits automatic verification at a gateway, but the recipient cannot relate the signer to the unencrypted contents. `AuthEnvelopedData` adds integrity to the encryption layer but, per RFC 8551, no authentication or non-repudiation, so it does not replace the signature.
go deeper
Recall that S/MIME can sign and encrypt in either order, and that whatever is on the outside is what relays can see.
Explain RFC 8551's stated trade-offs: signing first hides the signer and binds the plaintext; encrypting first exposes the signer but allows verification without a private key.
Match the order to an operational need, such as gateway verification without users' keys, and say exactly what the signature then fails to prove about the plaintext.
Treat the order as a policy decision that balances signer privacy, automated verification and long-term evidence, noting that authenticated encryption complements rather than replaces a signature.
## Nesting in S/MIME S/MIME's signed, enveloped (encrypted) and compressed formats are each a MIME entity that can carry another, so they nest. RFC 8551 section 3.7, Multiple Operations, says the signing, encrypting and compressing operations can be applied in any order, leaves the choice to the implementer and the user, and requires a receiving agent to process arbitrarily nested S/MIME within reasonable resource limits. The order is not cosmetic: the outer layer decides what everyone can see, and the inner layer decides what the signature vouches for. Two terms used below: - **Signing** uses the sender's private key and produces a `SignedData` structure that a recipient verifies with the sender's certificate; the signed formats themselves are a separate subject. - **Enveloping** encrypts content for named recipients with `EnvelopedData` or `AuthEnvelopedData`, opened with a recipient's private key. ## Signed, then encrypted The sender signs the content, then encrypts the signed result. - **Signer hidden:** RFC 8551 says the signatories are securely obscured by the enveloping; a relay sees only ciphertext and the recipients' certificate identifiers. - **Signature over the plaintext:** after decrypting, the recipient can assume the signed message itself has not been altered, and the signature relates the signer to this content. - **Outer layer not covered:** RFC 8551 warns that the unauthenticated portions of the encrypted message could have been changed. With classic `EnvelopedData`, the encryption layer carries no integrity check of its own. - **Verification needs decryption:** only someone able to decrypt, a recipient with a private key, can check the signature. ## Encrypted, then signed The sender encrypts first, then signs the encrypted object. - **Signer exposed:** the signature, and the certificate it names, is visible to everyone who handles the message. - **Verification without private keys:** anyone with the signer's certificate can verify. RFC 8551 notes this can be useful where automatic signature verification is wanted, since no private key material is needed. - **Weaker binding:** the recipient can validate that the encrypted block was unaltered, but cannot determine any relationship between the signer and the unencrypted contents. The signature covers ciphertext. ## Side by side | Question | Signed, then encrypted | Encrypted, then signed | |---|---|---| | Who can see the signer | Only recipients, after decrypting | Anyone handling the message | | Who can verify | Recipients, after decrypting | Anyone with the signer's certificate | | What the signature covers | The plaintext content | The encrypted object | | What it shows about authorship | The signer signed this content | The signer signed this ciphertext | The Enhanced Security Services specification (RFC 2634) also defines a **triple-wrapped** message, signed, then encrypted, then signed again, for cases where a message must be signed, encrypted and then have signed attributes bound to the encrypted body; the inner and outer signers may differ. ## Where authenticated encryption changes the picture S/MIME 4.0 added `AuthEnvelopedData`, whose authenticated encryption gives the encryption layer its own integrity check. That narrows the gap left by an unauthenticated outer layer in signed-then-encrypted mail. RFC 8551 is explicit, though, that `AuthEnvelopedData` provides **no authentication or non-repudiation**: any recipient for whom the message is encrypted could replace its content without detection. It complements a signature; it does not replace one. ## Choosing an order The choice turns on three questions: 1. **Who must verify, and with which keys?** If a gateway or an archive must check signatures without holding users' private keys, only a signature outside the encryption allows that. 2. **Is the signer's identity itself sensitive?** If relays should not learn who signed, the signature must travel inside the encryption. 3. **What must the signature prove later?** Evidence that a person signed a given text needs the signature over the plaintext, the signed-then-encrypted order, or the inner signature of a triple wrap. Whichever order is chosen, the receiving side has to be able to follow it: clients must unwrap layers in the order they were applied, and RFC 8551 asks receivers to cope with any nesting within reasonable resource limits. Two operational consequences follow: - An archive that stores mail as received keeps the outer layer intact, so an inner signature in signed-then-encrypted mail can be re-verified later only by someone who can still decrypt. - A filter that acts on "this message is signed" must actually verify the signature at whatever depth it sits; RFC 8551's security considerations warn against changing message handling on the mere presence of a signature. RFC 8551 prescribes neither order; it states both trade-offs and leaves the decision to the implementer and the user, which in an organisation means to policy.
- Why might a mail gateway that checks signatures before delivery prefer S/MIME messages encrypted then signed?With the signature outside, the gateway verifies it using only the signer's certificate, without any recipient's private key; RFC 8551 notes this suits environments that want automatic signature verification. The price is that the signer is visible to every relay and the signature covers the ciphertext, not the plaintext the recipient reads.
- Does AuthEnvelopedData make an inner S/MIME signature unnecessary?No. It gives the encryption layer an integrity check, but RFC 8551 says it provides no authentication or non-repudiation: any recipient holding the content key could replace the content undetected by the others. Proof that a particular person wrote the text still needs a signature made with the sender's private key.
- What is a triple-wrapped S/MIME message for?RFC 2634 defines it as signed, then encrypted, then signed again. The inner signature binds the signer to the content; the outer signature binds attributes to the encrypted body, so it can be checked without decrypting. The inner and outer signers may be different entities.
- The order of signing and encrypting makes no security difference.
- A signature applied after encryption proves the signer wrote the plaintext.
- With sign-then-encrypt, a gateway can verify the signature without decrypting.
- RFC 8551 requires signing before encrypting.
- Authenticated encryption makes a separate signature unnecessary.