← All posts

· MCU

Why the key is never injected

Generating P-256 keys on the chip across 134 targets, and the boards that have no TRNG at all.

There are two ways to give a microcontroller its identity. A factory station can generate a key pair, sign a certificate and write both into flash. Or the chip can generate the key itself, keep the private half, and send out only a certificate request.

Rootheon only does the second. The iotd-devid module calls psa_generate_key on the device, builds the CSR there, and the private key never exists anywhere else: not on the programming station, not in a log, not in our database. A stolen station or a leaked backup cannot clone a device that way.

What that needs from the chip

On-chip generation is only as good as the randomness behind it. The key must come from a true random number generator, so iotd-devid is built only against an entropy source the hardware actually provides:

  • Real TRNG – nRF52 and nRF54L, STM32 parts with an RNG peripheral, NXP RW612 and LPC55S0x/S1x/S2x, ESP32-S3/C6/P4, SAM E54/E70/V71, PIC32CX, Raspberry Pi Pico 2.
  • No TRNG in the part – for example STM32F303/F401/F411/F446, LPC55S36, the RP2040 Pico. These are build checks only: the module compiles for them so the code stays portable, but a production build stops with an error instead of falling back to a software generator.

That is 134 build targets across three Zephyr workspaces.

What protects the key afterwards

A key generated on the chip still sits in the chip’s storage. Locking the debug port and setting the protection fuses is the job of the production programmer, after the key is made, so that nobody can read it out over SWD later. That step is per-vendor and part of the factory process, not something a library can do for you.

The result is a device whose identity was born on the device and stays there. Everything else — the birth certificate from the factory line, the operational certificate in the field, its renewals — is built on top of that one decision.