I was hoping there were best practices available from some reputable source.
Lacking that, I am posting this as a suggestion, and welcome any input on it.
Methods for secure key storage in embedded devices depends on the threat scenario.
Threat scenario 1:
Both remote and physical attacks.
Threat scenario 2:
Only remote attacks.
------------
The best solution in both scenarios
- Single-chip MCU with built-in cryptoprocessor and secure key storage, such as PUF-RAM or tamper-resistant write-only flash accessible only by the dedicated cryptoprocessor.
- Any firmware loaded from off-chip must be signed.
- Ideally no external RAM.
- Use MPU to restrict access to crypto functions to privileged sections of the firmware.
- Blow the JTAG debug fuse if defense against physical attacks is required
The second-best solution, scenario 1 only
- Single-chip MCU, with external security chip.
- All communication with external security chip is encrypted using a device-specific key.
- Any firmware loaded from off-chip must be signed.
- Ideally no external RAM.
- Use MPU to restrict access to crypto functions to privileged sections of the firmware.
- Key for encrypted communication with external security chip is stored in on-chip flash.
- Blow the JTAG debug fuse.
Con: The most complicated to implement, and any bugs in the implementation may compromise security.
Performance may suffer because of the additional encryption.
The second-best solution, scenario 2 only
- Single-chip MCU, with external security chip.
- Any firmware loaded remotely must be signed.
- Use MPU to restrict access to crypto functions to privileged sections of the firmware.
- No need to disable JTAG. Greatly simplifies maintenance.
Con: No defense against physical access. The unencrypted interface of the external security chip is wide open to physical attacks
The third-best solution, both scenarios
- Single-chip MCU.
- All firmware loaded from off-chip must be signed.
- Use MPU to restrict access to crypto functions to privileged sections of the firmware.
- Private keys stored in on-chip flash.
- Blow the JTAG debug fuse if defense against physical attacks is required.
- Ideally no external RAM if defense aganst physical attacks is required.
Con: A successful attack yields the plaintext keys, rather than indirect access to keys.
Pro: Ability to add support for new crypto algorithms by firmware update, as security standards evolve.
------------
Explanations
Two lines of defense against remote attacks
The two lines of defense against remote attacks are identical in all four solutions above.
- Bug-free monolithic main firmware. Remote attacks are only possible if there are bugs in the firmware.
- Bug-free privileged part of main firmware. Even if the main part of the firmware is compromised due to a bug, the MPU provides a partial second layer of protection for the privileged part of the firmware, and the private keys.
This is where your security focus must be, regardless of hardware solution.
External security chips
Dedicated devices with built-in secure key storage and cryptoprocessor capable of performing all required ECC, RSA and AES functions. Typically connected to your MCU using I2C or SPI
These cannot really be said to add any additional lines of defense against attacks. A better description is to say that they change the outcome of a successful attack. Without a security chip, a successful attack yields the plaintext keys. With a security chip, a successful attack yields indirect access to use the keys. The latter is a marginally less damaging outcome.
But ask the cable-TV industry what they think about this kind of protection. Indirect access to keys is sufficient for widespread cable-TV piracy by having the keys indirectly accessible via internet.
Security chips also come with a significant drawback: They expose an easy to access hardware interface to use the keys, actually making physical attacks very easy.
The exception is external security chips with support for encrypted communication with the MCU, and which even over that encrypted interface does not allow reading the private keys. But that creates a new key-storage problem in the MCU.
MCU internal hardware cryptoprocessor and protected key storage
Provides the same advantage as an external security chip, but without the physical attack weakness or performance issues.
Physical attack vectors, and their defenses
Ranked from easiest to hardest attack vector.
- Serial interface to external security chip.
- Use MCU-internal cryptoprocessor and key storage instead.
- Use external security chip with encrypted interface and device-unique encryption key.
- Use no security chip, and store private keys directly in MCU-internal flash instead.
- JTAG debug interface.
- External boot flash.
- Verify signature or hash of loaded firmware.
- External RAM.
- Silicon probing.
- Anti-tampering hardware.
- PUF-RAM.