A research institute S/MIME-encrypts one summary to three partners, one holding an RSA certificate and two holding elliptic-curve certificates; how does the single message deliver the content key to each?
answer
- two ways to deliver one key
- RSA encrypts the key directly
- a fresh key pair per message
- derive a key-encryption key, then wrap
- wrap size matches the content cipher
basics
~20 sOne content key encrypts the body once. The RSA partner gets a key-transport entry: the key encrypted under their RSA public key. Each elliptic-curve partner gets a key-agreement entry: ephemeral-static ECDH derives a key-encryption key that wraps the content key.
solid answer
~50 sThe body is encrypted once under a random content key, and each partner gets a `RecipientInfo`. For the RSA partner it is a `ktri`: the content key encrypted with RSA PKCS #1 v1.5 (MUST- in S/MIME 4.0) or RSAES-OAEP (SHOULD+). For each elliptic-curve partner it is a `kari`: the sender generates an ephemeral key pair on the partner's curve, runs ECDH against the static key in the partner's certificate, derives a key-encryption key (HKDF-256 for X25519), and wraps the content key with an AES key wrap whose size matches the content cipher; the ephemeral public key travels in `originatorKey`. Two partners on the same curve can share one `kari`; P-256 and X25519 need separate entries. RFC 8551 makes both ECDH variants MUST. The ephemeral key does not identify the sender, so authorship still needs a signature.
go deeper
Recall that RSA and elliptic-curve recipients receive the same content key delivered two ways: encrypted directly for RSA, wrapped under an agreed key for elliptic curves.
Explain ktri against kari: what originatorKey carries, why the sender's key pair is ephemeral, and how a derived key-encryption key wraps the content key.
Read a mixed-recipient structure: one kari per curve, RSA as MUST- and OAEP as SHOULD+, the key wrap size matched to the content cipher, and no sender authentication from ephemeral-static agreement.
Decide which certificate types to issue and accept for new partners, given that S/MIME 4.0 makes ECDH mandatory while RSA key transport is expected to weaken.
## One content key, two ways to deliver it The institute's client creates one random **content-encryption key** (CEK) and encrypts the summary once, for example with AES-256 GCM. It then has to give each partner a protected copy of that CEK. CMS (RFC 5652) provides different `RecipientInfo` alternatives for this, and each partner's certificate decides which one applies: - An **RSA** certificate leads to **key transport** (`ktri`): the CEK is encrypted directly under the partner's RSA public key. - An **elliptic-curve** certificate leads to **key agreement** (`kari`): in S/MIME an elliptic-curve key does not encrypt the CEK directly; the sender agrees a shared secret with the partner's key and uses a key derived from it to wrap the CEK. The certificate's key usage has to allow the operation, `keyEncipherment` for key transport and `keyAgreement` for key agreement; the certificate profile is a separate subject. ## Key transport for the RSA partner The `KeyTransRecipientInfo` holds: - `rid` — the partner's certificate, by issuer and serial number or by subject key identifier; - `keyEncryptionAlgorithm` — RSA encryption with PKCS #1 v1.5 padding (`rsaEncryption`, RFC 3370) or RSAES-OAEP (`id-RSAES-OAEP`, RFC 3560); - `encryptedKey` — the CEK encrypted under the partner's public key. RFC 3560 records that PKCS #1 v1.5 key transport is vulnerable to adaptive chosen-ciphertext attacks, notes they are significantly less feasible in store-and-forward settings such as S/MIME, and defines OAEP for CMS as the alternative. Against that background RFC 8551 marks RSA encryption **MUST-** and RSAES-OAEP **SHOULD+**. ## Key agreement for the elliptic-curve partners **Ephemeral-static** ECDH means the sender's side uses a fresh key pair and the recipient's side uses the static public key in their certificate. For each elliptic-curve partner the sender's client: 1. Generates an ephemeral key pair on the same curve as the partner's public key; RFC 8418 requires this for X25519 and says the pair is used for a single CMS-protected content and then discarded. 2. Performs ECDH between its ephemeral private key and the partner's static public key. 3. Derives a pairwise **key-encryption key** (KEK) from the shared secret with a key derivation function: HKDF-256 for X25519 under RFC 8418, and for P-256 the SEC 1 function that RFC 5753 specifies. 4. Wraps the CEK under the KEK with the key wrap algorithm named inside `keyEncryptionAlgorithm`. 5. Places its ephemeral public key in the `originator` field as `originatorKey`, and the partner's certificate identifier and wrapped CEK in `recipientEncryptedKeys`. The partner's client reverses this: it takes the ephemeral public key from `originatorKey`, performs ECDH with its own private key, derives the same KEK and unwraps the CEK. One `kari` can deliver the CEK to several recipients that share the same key agreement algorithm and domain parameters. If both elliptic-curve partners hold P-256 certificates, one entry with one ephemeral key can list both; if one holds P-256 and the other X25519, the message carries two `kari` entries. ## What S/MIME 4.0 requires | Key-encryption method | RFC 8551 section 2.3 | Specified in | |---|---|---| | ECDH ephemeral-static with P-256 | MUST | RFC 5753 | | ECDH ephemeral-static with X25519 and HKDF-256 | MUST | RFC 8418 | | RSA encryption (PKCS #1 v1.5) | MUST- | RFC 3370 | | RSAES-OAEP | SHOULD+ | RFC 3560 | RFC 8551 also ties the key wrap to the content cipher: with ECDH, the key wrap and content-encryption algorithms must share the underlying cipher and key size (an AES-128 key wrap with AES-128 content encryption), and since both AES-128 and AES-256 GCM are mandatory, both key wrap sizes must be supported. S/MIME 3.2 (RFC 5751) required only RSA encryption and rated Diffie-Hellman SHOULD-. ## What the mixed recipient list costs - **One common content cipher.** All three partners must be able to decrypt the same content algorithm. RFC 8551 says that when recipients' capabilities do not overlap the sender is forced to send more than one message, and warns against sending a weaker copy of a message beside a stronger one. - **No sender authentication from key agreement.** The sender's half is ephemeral and travels uncertified in `originatorKey`, so nothing in the key exchange identifies the institute; RFC 8551's security considerations say S/MIME's ephemeral-static use does not meet the conditions for authenticated encryption to show origin. Authorship needs a signature. - **Auditability.** The structure shows which partner received which method: `ktri` against `kari`, the `keyEncryptionAlgorithm` identifiers and the key wrap named inside them.
- Why does ephemeral-static ECDH in S/MIME not tell the recipient who sent the message?The sender's side of the agreement is a key pair created for this one message and carried uncertified in originatorKey, so nothing ties it to a person. RFC 8551's security considerations note that S/MIME almost universally uses ephemeral-static agreement, which fails the precondition that the starting key be bound to a single entity. Authorship needs a signature.
- In that institute's message, the two elliptic-curve partners hold P-256 and X25519 certificates respectively. What does the sender's client build?Two KeyAgreeRecipientInfo entries. One entry serves only recipients sharing a key agreement algorithm and domain parameters, and the ephemeral key must be on the recipient's curve, so the client makes one P-256 entry under RFC 5753 and one X25519 entry with HKDF-256 under RFC 8418, each with its own ephemeral public key, both wrapping the same content key.
- Under RFC 8551, what constraint links the key wrap algorithm to the content cipher when ECDH is used?Section 2.3 says the key wrap and content-encryption algorithms must use the same underlying cipher and key size, for example AES-128 key wrap with AES-128 content encryption. Because AES-128 GCM and AES-256 GCM are both mandatory, both AES key wrap sizes must be supported whenever ECDH ephemeral-static is used.
- Elliptic-curve recipients get the content key encrypted directly under their public key, just like RSA.
- ECDH in S/MIME uses the sender's certified long-term key, so it authenticates the sender.
- RFC 8551 forbids RSA key transport.
- A mixed RSA and elliptic-curve recipient list forces a separately encrypted body per recipient.
- The key wrap can be AES-256 while the content is encrypted with AES-128 GCM.
Assumes S/MIME 4.0 (RFC 8551, 2019), which made ECDH ephemeral-static with P-256 and X25519 a MUST for key encryption; S/MIME 3.2 required only RSA and rated Diffie-Hellman SHOULD-.