skip to content

In CMS EnvelopedData sent to several recipients, what does each RecipientInfo carry, and how does a recipient's client find its own entry?

level: middleimportance: must knowfreq 32%

answer

  1. one key, many wrapped copies
  2. a SET of per-recipient entries
  3. rid names a certificate, not an address
  4. issuer plus serial, or key identifier

basics

~20 s

Each RecipientInfo carries one wrapped copy of the single content-encryption key, the algorithm that wrapped it, and an identifier of the recipient certificate used. A client finds its entry by matching issuerAndSerialNumber or subjectKeyIdentifier against its own certificates.

solid answer

~40 s

EnvelopedData encrypts the content once under a random content-encryption key and carries `recipientInfos`, a SET of at least one `RecipientInfo`. A key-transport entry (`ktri`) holds `rid`, the `keyEncryptionAlgorithm` and the `encryptedKey`; a key-agreement entry (`kari`) holds the originator's key, an optional `ukm`, the algorithm with its key wrap, and an encrypted key for each recipient sharing that algorithm. The identifier names the recipient's certificate by `issuerAndSerialNumber` or by `subjectKeyIdentifier`; RFC 5652 says recipients MUST support both forms and senders at least one. The client compares each identifier with the certificates whose private keys it holds, unwraps the content key from the matching entry and decrypts. Alternatives it does not implement must be handled gracefully, not treated as fatal.

go deeper

for a junior

Recall that the body is encrypted once and that each recipient gets an entry holding a wrapped copy of the content key, named by certificate rather than by address.

for a middle

Explain the RecipientInfo fields, the issuerAndSerialNumber and subjectKeyIdentifier forms, and the recipient-side rule that both forms must be supported while a sender needs only one.

for a senior

Use the identifiers to diagnose an unreadable message: which certificate the sender used, whether its private key is still held, and whether the client skipped an entry it does not implement.

for a principal

Weigh what the unencrypted entries reveal about who received a message, and how renewal practice decides whether mail encrypted to old certificates stays readable.

## The shape of EnvelopedData `EnvelopedData` is the Cryptographic Message Syntax (CMS, RFC 5652) content type S/MIME uses for an encrypted body. Its fields are: - `version` — a syntax number derived from which optional parts and which `RecipientInfo` types are present. - `originatorInfo` — optional certificates and revocation lists about the originator, present only when the key management algorithm needs them. - `recipientInfos` — a `SET SIZE (1..MAX) OF RecipientInfo`: at least one per-recipient entry. - `encryptedContentInfo` — the content type, the `contentEncryptionAlgorithm` and the `encryptedContent`. RFC 5652 states that the same content-encryption algorithm and key are used for all recipients. - `unprotectedAttrs` — optional attributes that are not encrypted. The `recipientInfos` field comes before the encrypted content on purpose, so that an `EnvelopedData` value can be processed in a single pass: a client reads the entries, recovers the key and decrypts the body as it streams past. ## The five RecipientInfo choices `RecipientInfo` is a CHOICE with one alternative per key management technique, and each recipient of the same message may use a different one. | Choice | Technique | RFC 5652 support | |---|---|---| | `ktri` | Key transport: the content key encrypted under the recipient's public key (RSA) | MUST | | `kari` | Key agreement: a pairwise key derived from the sender's and recipient's keys wraps the content key (ECDH) | MUST | | `kekri` | A previously distributed symmetric key-encryption key | MUST | | `pwri` | A key-encryption key derived from a password | MAY | | `ori` | Any other technique, identified by an object identifier | MAY | Mail between people with certificates uses `ktri` for RSA certificates and `kari` for elliptic-curve certificates. A `ktri` holds `rid`, `keyEncryptionAlgorithm` and `encryptedKey`. A `kari` holds the originator's key, an optional `ukm` (user keying material), the key-encryption algorithm with its key wrap, and `recipientEncryptedKeys`, which can list several recipients that share one key agreement algorithm and set of domain parameters, each with its own identifier and encrypted key. ## How a recipient is named The identifier, `rid` in a `ktri` and in each `recipientEncryptedKeys` entry of a `kari`, names the recipient's **certificate**, not their mail address. Two forms exist: - `issuerAndSerialNumber` — the issuing authority's distinguished name plus the certificate's serial number. A `ktri` using this form has version 0. - `subjectKeyIdentifier` — the value of the certificate's subject key identifier extension (inside a `RecipientKeyIdentifier` in a `kari`). A `ktri` using this form has version 2. For recipient processing, RFC 5652 says implementations **MUST support both** forms; for sender processing they MUST support **at least one**. An auditor reading a message structure therefore cannot assume which form a given sender chose. ## What the recipient's client does 1. Walk `recipientInfos`, handling gracefully any alternative or version it does not implement — RFC 5652 requires unimplemented alternatives, unimplemented versions and unknown `ori` types to be handled gracefully rather than treated as fatal. 2. Compare each identifier with the certificates whose private keys it holds. 3. On a match, use that private key, through key transport or key agreement, to recover the content key from `encryptedKey`. 4. Decrypt `encryptedContent` with the algorithm named in `contentEncryptionAlgorithm`. ## When no entry matches "I can't open this message" usually means that no entry names a certificate whose private key this client holds. Typical causes: - The sender encrypted to an **older certificate** of the user; the entry names that certificate, and only its private key unwraps the copy. Keeping or recovering superseded decryption keys is a key-custody matter. - The message was encrypted to **another certificate** the user holds, for example one for a role address kept on a different device. - The only matching entry uses an alternative **this client does not implement**, so it fails gracefully instead of decrypting. Because the identifiers are not encrypted, a help desk can read them to learn which certificate the sender actually used. ## What the structure exposes The per-recipient entries sit outside the encryption. Anyone holding the message, a relay or a mailbox store included, can read each entry's certificate identifier and key-encryption algorithm, and an issuer name with a serial number can often be tied to a person by whoever holds that certificate. The content key itself never appears in readable form.

  • Why does RFC 5652 place recipientInfos before encryptedContentInfo in EnvelopedData?
    So that an EnvelopedData value can be processed in a single pass. The recipient's agent reads the per-recipient entries first, recovers the content key from its own entry, and can then decrypt the content as it streams past, instead of buffering a large encrypted body before it knows which key to use.
  • A user's certificate was renewed with a new key pair, and their client now holds only the new key. Why can it not open a message a partner encrypted yesterday?
    The partner's client still held the old certificate, so the entry names that certificate by issuer and serial number or key identifier, and the content key is wrapped under the old public key. Only the old private key unwraps it. Reading the identifier shows which certificate was used; recovering the old key is a key-custody matter.
  • What can someone who holds an encrypted S/MIME message, but no private key, learn from its RecipientInfo entries?
    The entries are not encrypted, so they can read each recipient certificate's identifier (issuer name and serial number, or a key identifier) and the key-encryption algorithm used. An issuer and serial can often be matched to a person by anyone holding that certificate. The content key and the body stay protected.

  • Each recipient gets a separately encrypted copy of the whole body.
  • A RecipientInfo names the recipient by their email address.
  • The list of RecipientInfo entries is encrypted along with the content.
  • A client that meets an unknown RecipientInfo type must reject the whole message.
  • The CMS structure itself requires an entry that wraps the content key for the originator.