Setting
A sensor gateway is a small device that collects readings from sensors and passes them on. In this invented example a factory builds many gateways. A publisher, the one party authorized to change a gateway’s policy, later sends each gateway policy updates through a phone that only carries the bytes. Before a gateway ships, it needs two secrets:
, the active message-authentication key. The publisher holds a copy and uses it to compute a tag on each update, a short value that only holders of the key can compute, so that the gateway can tell genuine updates from forged ones.
, the recovery credential: a separate secret, kept by the publisher apart from and used only to authorize a replacement for if is lost or stolen.
A technician proposes two shortcuts. First, compute each gateway’s as the SHA-256 §5.2 digest of the gateway’s serial number followed by the second at which the gateway left the production line. SHA-256 (Secure Hash Algorithm with a 256-bit output) turns any input into a 32-byte value called a digest. The serial number is printed on the gateway’s label, and every gateway of a batch leaves the line within one known hour. Second, seed the random number generator once on a workstation and copy the resulting generator state into every gateway’s firmware, the software stored on the gateway. An engineer proposes a third design: compute every gateway’s from one secret root key §5.25 and the gateway’s public device ID.
The guiding question is what the attacker does not know. The number of bytes in a printed key answers a different question.
Short answer
Good keys come from a cryptographically secure random generator seeded with enough unpredictable input, run inside the device or in protected equipment. Provisioning then installs each key, bound to one device and one purpose, over a protected path, and records who holds copies. A key’s strength is the number of guesses an attacker needs, not its length: a 32-byte digest of a public serial number and a second within a known hour has only possible values.
Follow-up questions
Start with entropy §5.26
Start by counting what the attacker cannot predict, because a key is never harder to guess than the inputs it was computed from, whatever its length. Entropy measures that unpredictability in bits. If the attacker can narrow the possible inputs to equally likely candidates, the input has bits of entropy, and each extra bit doubles the number of candidates.
Apply this to a key computed as the SHA-256 (Secure Hash Algorithm with a 256-bit output) digest of a gateway’s serial number followed by the second at which the gateway left the production line. The serial number is printed on the label, so it adds nothing secret. The exit time lies within one known hour, so there are candidates and bits of entropy. The digest is bits long, but there are at most 3600 different digests, one per candidate time. An attacker who has recorded one tagged update computes the 3600 candidate keys and tests each against the tag, which takes a laptop a small fraction of a second. Hashing cannot add candidates. If two candidates happen to give the same digest, the number of distinct keys only falls. With 4 equally likely seeds, the same reasoning gives bits and at most 4 keys.
When the candidates are not equally likely, the measure that matters for guessing is min-entropy: where is the probability of the most likely candidate. Take four candidates with probabilities , , and . Then and bit: the attacker’s first guess is right half the time. Shannon entropy, , where is the probability of candidate , is the average uncertainty. Here it is bits, which overstates how hard the first guess is.
For the attacker’s best single guess to succeed with probability at most , the key must come from a source with at least 128 bits of min-entropy. On a gateway, that unpredictability comes from a physical noise source on the chip, a circuit that samples electrical noise. A cryptographically secure pseudorandom number generator §5.27 then turns it into keys.
What does a CSPRNG supply?
A CSPRNG (cryptographically secure pseudorandom number generator) supplies as many output bytes as requested, which nobody without its internal state can predict or tell apart from random bytes; it does not supply new unpredictability. It is a deterministic algorithm §14.1. It starts from a seed, input taken from an entropy source such as a noise circuit, and keeps a secret internal state. Each request returns bytes computed from the state and then updates the state.
NIST Special Publication (SP) 800-90A, the recommendation of the United States standards agency for such generators, calls such a generator a DRBG (deterministic random bit generator) [305]. It defines three designs, built on a hash function, on HMAC §5.8 (hash-based message authentication code) and on a block cipher §15.3. It requires the seed to carry at least as much entropy as the security strength that the generator claims, for example at least 128 bits for a strength of 128 bits.
If the seed had that much min-entropy and the state stays secret, the outputs are computationally unpredictable: no feasible computation predicts the next output from all earlier outputs. Two further properties concern an attacker who reads the state at some moment.
Backtracking resistance, in the terms of SP 800-90A: the state read at that moment does not reveal earlier outputs. The generator gets this property by updating its state after every request.
Prediction resistance: the state read at that moment does not reveal later outputs. This property requires reseeding, mixing fresh entropy into the state, before the output in question.
A CSPRNG cannot create entropy: an attacker who can guess the seed computes every output. The technician’s second proposal copies one generator state into every gateway. Given the same state and the same inputs, the algorithm returns the same bytes, so gateway 1 and gateway 2 generate identical keys, and anyone who reads the state from one gateway, or from the workstation, predicts the keys of all of them. The same repetition occurs without copying when a device goes back to an earlier saved state, for example by restoring a backup: the generator then gives again outputs it gave before. A generator that produces keys at start-up, before its noise source has delivered enough entropy, gives guessable keys.
The repair is to seed each gateway from its own noise source, never to ship or restore a saved generator state, to reseed from time to time, and to make the generator refuse output until it has been seeded.
What is provisioning?
Provisioning is the process that gives a device its identity and its first secrets and records both with the parties that will rely on them; it is also called enrollment §5.28. In this setting a factory provisions sensor gateways. Each needs , the active message-authentication key that it shares with the publisher of its policy updates, and , a separate recovery credential that authorizes a replacement for . Provisioning a gateway takes these steps:
Identify the device. Establish that the unit receiving the keys is a genuine gateway and is the unit that the records will name: for example, it sits in a controlled station on the production line, or it proves that it holds a key installed by the chip maker.
Generate the secrets. Generate each key with a cryptographically secure generator seeded with enough entropy, either inside the gateway, so that the key never travels, or inside a hardware security module (HSM), a tamper-resistant device built to generate, store and use keys inside its own protected hardware.
Transfer over a protected path. A key that must travel, such as the publisher’s copy of , is encrypted and authenticated from end to end, and no tool on the way writes it to a log.
Record the binding. The publisher records which device ID holds which key, for which role ( for policy updates, for recovery), and the generation number , a counter of key replacements that starts at 1 for the first and increases by 1 at each replacement.
Decide who keeps copies. The publisher must hold to compute tags, so one copy lives outside the gateway, in protected storage. is kept offline, apart from . Nobody else, such as the technician’s workstation, keeps a copy.
Lock the device. Close the debug port, or turn on readout protection §16.5, a chip setting that blocks reading the chip’s memory through the debug port, so that the keys cannot be read back out.
Handle failure. A unit whose provisioning stops halfway is either completed with freshly generated keys or erased and marked unprovisioned. Keys that may have been exposed in the failed attempt are not reused.
A cable is a transport, not a security property. Writing over a cable from a workstation proves that the bytes arrived. It does not prove that nobody else read them, on the workstation, in its logs or on the cable; that the intended gateway received them; or that the publisher’s records match the gateway.
Does per-device derivation isolate every compromise?
No: deriving each gateway’s key from a shared root key isolates the leak of one gateway’s key, but a leak of the root exposes every gateway, because the device-specific inputs are public. Per-device key derivation §5.24 computes each device’s key from a root key and the device’s identity with a key derivation function §5.20 (KDF), an algorithm that turns one secret into keys for stated purposes. In this setting a publisher sends tagged policy updates to sensor gateways, and each gateway needs its own message-authentication key. With root key and public device IDs, gateway 1 gets and gateway 2 gets , where and are the device IDs and joins byte strings. Only the publisher holds ; each gateway receives only its own key.
One gateway’s key leaks. An attacker extracts from gateway 1. If the KDF behaves as a pseudorandom function §15.1 keyed with , meaning that its outputs look random to anyone without , even after seeing outputs for other inputs, then reveals nothing useful about or . The damage stays with gateway 1.
The root leaks. Device IDs are printed on labels and sent over the radio, so an attacker who learns computes , and the key of every other gateway, including gateways not yet built.
The root sits on the gateways. If each gateway held to derive its own key, extracting from any one gateway would be a root leak.
A device ID separates contexts: different IDs give different keys. It adds no secret, because the attacker knows it. The damage of a root leak is limited by keeping only in protected equipment such as a hardware security module (HSM), a tamper-resistant device built to store and use keys inside its own protected hardware; by using a separate root for each batch or region; or by giving each gateway an independent random key with no root at all, at the cost of a table of keys at the publisher.
What if the firmware image contains roots?
If the firmware image contains a secret root key, anyone who obtains the image holds that root, and every key derived from it must be treated as compromised. The firmware image is the software file installed on every gateway. It is identical on every unit and is copied to update servers, build machines and workstations. An attacker can obtain it from any of these, or by reading the flash memory §6.6 of one gateway whose readout protection is off. Hiding the root inside the image by obfuscation only delays an analyst.
In this setting each sensor gateway’s active message-authentication key , the key that authenticates policy updates from the publisher, is derived from a root key and the gateway’s public device ID. With taken from the image, the attacker computes every gateway’s and forges policy updates that every gateway accepts. New public labels in the derivation do not help, since the attacker can read them too. Nor does a firmware update that installs a new root, if that update is itself authenticated with keys derived from : the attacker can forge such an update, and can read the new root from the new image.
Recovery needs a trust path outside the compromise. Suppose each gateway also holds a recovery credential , generated at random for that gateway alone at provisioning, stored only in the gateway’s protected storage and in the publisher’s offline storage, never in the image and never derived from . The publisher can then use to authorize freshly generated replacement keys. If was also derived from , or stored in the image, no remote recovery exists, and each gateway must be provisioned again by hand.
Public roots are a different matter. A public key that the gateway uses only to verify signatures may sit in the image; signature-based secure boot §6.31 uses that public key to verify firmware before running it. Anyone can have the verification key. By contrast, anyone who obtains an image containing a secret root can use that root. Distributing such an image therefore distributes the secret to every recipient.
Related entries: HKDF (§5.21), Per-device key derivation (§5.24), Root key and root seed (§5.25), Entropy and min-entropy (§5.26), CSPRNG (§5.27), Key provisioning (§5.28), Readout protection (§16.5), Secure boot (§6.31), Secure element (§5.38), Pseudorandom function (PRF) (§15.1). Further reading: [148, 305].