Every place a secret can live
In the image, in plain or encrypted NVS, behind the DS peripheral, in a secure element, or on the server as a slow hash. What a stolen copy would cost decides which.
Start with one question: what could someone do with a copy of this secret? Then pick the cheapest place that stops that.
- Never in the firmware image. Anything compiled in is on every unit and in every update file. Secrets are per device, provisioned at setup or at the factory.
- A clone costs little (a classroom node on a test broker) → a per-device credential in plain NVS, scoped by the broker's ACL so a stolen one reaches one device's topics.
- A clone costs a site's data or control → the DS peripheral (the key can be used, never read) or encrypted NVS, with secure boot.
- A clone costs someone's safety or property → a secure element, with secure boot and flash encryption.
- On the server, a user's password is never stored at all: only a slow, salted hash.
Whatever the choice, how it gets there matters as much (provisioning in the field or at the factory), and so does how one device's secret is revoked without touching the others.
On the device, from weakest to strongest
Section
Storing secrets on a device
Three attackers (a cable, a lab, replaced firmware) against four places.
Term
eFuse
What keeps an attacker's firmware from using it
Section
Roots of trust and secure boot
A key that can be used but not read stops cloning, not misuse from the same chip; secure boot stops the misuse.
Term
secure boot
How the secret gets there
Section
Provisioning Wi-Fi credentials
The user's network password, entered once, stored in NVS, never in the sketch.
A key pair made on the device, a CSR, and a certificate back.
Section
Manufacturing provisioning
The same at line speed, with the CA's key in an HSM and the counts reconciled.
On the server and in transit
Users' passwords as slow, salted hashes; devices and apps holding tokens.
Term
salt
Section
MQTT over TLS
Without TLS, a password in CONNECT travels as plain bytes.
When one leaks
Term
revocation
Example