For S/MIME mail read on a laptop and a phone, what must a PKCS #12 file carry to each client, and how is it handled?
answer
- same key on every device
- key bag, certificate bag
- localKeyId pairs them
- password travels separately
basics
~20 sEach device needs the same private decryption key, every superseded one, and the matching certificates with their chain, carried in a password-protected PKCS #12 file. Send the password separately, delete the file after import and mark keys non-exportable.
solid answer
~40 sPKCS #12 (RFC 7292) is the transfer syntax for moving a private key together with its certificate between platforms. For S/MIME the file holds the private key in a `PKCS8ShroudedKeyBag`, the user's certificate and the issuing chain in `CertBag`s, and a `localKeyId` attribute that pairs each key with its certificate. Every device must receive the *same* decryption key, not a fresh one per device, because a sender encrypts to one key-management certificate per recipient; it also needs each superseded decryption key, or old mail will not open there. Handle the file as the key itself: a strong password delivered by a different channel, removal from download folders and mail after import, and non-exportable storage where the client offers it. The signing key travels only to devices that sign.
go deeper
Recall that PKCS #12 is the file format that moves a private key and its certificate together from one device to another, and that it must be password-protected.
Explain why every reading device needs the same decryption key, what the key bag, certificate bag and localKeyId do, and why superseded keys travel too.
Show handling judgment: password out of band, no copies left in the mail store, non-exportable import, and an inventory so a lost device can be assessed.
Weigh portable software keys against keys locked in hardware: recovery and multi-device reading favour exporting, custody favours the card, and splitting signing from decryption gets both.
## Why the key has to travel at all An S/MIME message encrypted to a user carries one `RecipientInfo` for that user, naming one of their certificates by issuer and serial number or by subject key identifier, and the content key inside it is wrapped for that certificate's public key. Whichever device opens the message needs the **matching private key**. Generating a separate key on each device does not work for decryption: RFC 8551 (section 2.5.3.1) has a sending client pick a single key-management certificate per recipient, and if it finds several it may choose arbitrarily. Mail encrypted to the laptop's key would then be unreadable on the phone. So the same decryption key has to be **copied** onto every device that reads mail. ## What goes into the file PKCS #12 v1.1 (RFC 7292, 2014, an informational RFC) defines a transfer syntax for "personal identity information": private keys, certificates and other secrets, packed so that one platform can export them and another import them. The top-level structure is the **PFX**; inside it, each item sits in its own **SafeBag**. | Bag or attribute | What it carries for S/MIME | |---|---| | `PKCS8ShroudedKeyBag` | the private key, encrypted under a key derived from a password | | `KeyBag` | a private key with no encryption at the bag level, relying on the surrounding contents being encrypted | | `CertBag` | the user's certificate, and the intermediate certificates of the issuer | | `localKeyId` | an identifier that pairs a key bag with its certificate bag | | `friendlyName` | a display name, so the user can tell keys apart | What protects the key inside the file (the privacy and integrity modes and the strength of the password-based encryption) is covered with key management in public-key infrastructure; for custody it is enough that the file is only as safe as its password and its handling. ## Which keys each device needs - **The current decryption key** and its certificate, on every device that reads encrypted mail. - **Every superseded decryption key**, on every device that must open older mail. Each certificate renewal that generated a new key pair leaves mail that only the previous key opens. - **The signing key**, only on devices where the user actually signs. Copying it further adds exposure and no capability, since verification needs only the public key. - **The issuer's chain**, so the client can present a complete path when it signs. Where signing and encryption use separate key pairs, they can travel in separate files, which keeps the signing key off devices that only read. ## Handling the file 1. **Export from where the key lives.** Usually the first device, or an organisation's key-recovery system when keys are generated centrally. 2. **Protect it with a strong password** and deliver that password through a different channel from the file. When a CA generates the key for a subscriber, the CA/Browser Forum's S/MIME Baseline Requirements (1.0.16, section 6.1.2) set the floor: either hardware transport whose activation material (a PKCS #12 password is their example) reaches the subscriber securely and separately, or encryption of the key at **at least 112 bits of strength**, with a PKCS #12 file whose password and algorithm reach that level as an illustration. Separate delivery of the password is good practice in every case. 3. **Import, then remove every copy** from downloads, mail attachments and shared folders. A PKCS #12 file attached to an email is a copy of the key in the mail store. 4. **Mark the key non-exportable** where the client or platform key store offers it, so the device does not become the next export source by accident. 5. **Record which keys went where**, so a lost phone can be assessed: losing a device that held a decryption key is a question of whether that key is now exposed. ## When a key cannot travel A key generated on a **smart card or hardware token** never leaves it, which is good for custody and bad for portability and recovery. Every device that reads mail then needs to reach the card (a reader, a contactless interface or a token that plugs into the phone), and there is no second copy to restore if the card fails. Organisations that want both often generate the **decryption key** off the card, keep a recovery copy, and load it onto the card, while the **signing key** is generated on the card and never copied. That split is a practice that separate key pairs make possible, not a requirement of the S/MIME standards.
- A user mails themselves their PKCS #12 file to set up a new phone. What is the residual risk once the import works?The file now sits in the mail store, in sent and received copies, in backups and possibly in search indexes, protected only by its password, and exposed to offline guessing for as long as any copy survives. Delete every copy, consider whether the password was strong, and for a high-value key treat it as exposed and issue a new decryption certificate, keeping the old key for old mail.
- Why not give each device its own decryption key and certificate?A sending client chooses one key-management certificate per recipient and may choose arbitrarily among several, so mail would be readable only on whichever device's key was picked. Per-device keys suit signing, where each device can sign independently, but not decryption.
- Each device should generate its own decryption key and certificate.
- Only the current key matters; old keys can stay on the old laptop.
- Mailing the PKCS #12 file to yourself is a safe way to move it.
- The password can travel in the same message as the file.
- The signing key must be copied to every device that reads mail.