Definition
Per-device key derivation is a method that gives every device in a group its own secret key by computing that key from one secret key, called the master key, and the device’s identifier. A key derivation function §5.20, an algorithm §14.1 that turns a secret key and public inputs into new keys, takes the master key and an encoding of the identifier and returns the device key. Each device stores only its own key. Whoever holds the master key can compute every device key from the device’s identifier.
The idea
A company makes 10,000 devices. Each must prove to the company’s server that a message came from that particular device, using a message authentication code §5.7, an algorithm that computes a short tag from a secret key and a message. The keys can be arranged in three ways.
One key in every device. An attacker who reads the key out of one device, for example through a debugging port, can impersonate all 10,000 devices.
An independent random key in each device. Reading one device exposes only that device. But the server must store and protect a table of 10,000 keys of 32 bytes each, bytes, and the factory must record every key it installs.
Per-device key derivation. The server keeps one 32-byte master key and computes any device’s key from the device’s identifier when it needs it. Reading one device still exposes only that device.
The third arrangement combines the isolation of independent keys with the storage cost of a single key. The price is concentration: the master key stands behind every device key, so its disclosure exposes all of them at once. The chip maker NXP describes the technique for smart cards under the name key diversification: deriving keys from a master key using some unique input, so that if one key is broken, the damage is limited to that key on that card rather than the whole system.
How it works
The parties and values are these.
The derivation authority: the party that holds the master key, such as a server or a hardware security module (a physical device that safeguards keys and performs cryptographic processing).
The master key : a uniformly random secret key, for example 32 bytes from a CSPRNG §5.27 (cryptographically secure pseudorandom number generator). NIST calls a key used this way a key-derivation key.
The label: a fixed public string that names the purpose of the derived keys, such as
dev-authfor device authentication §1.6.The identifier: a public value that is unique to each device, such as a serial number, written in a field of fixed length.
The device key : the derived key of the device whose identifier is .
The keys are made and used in four steps.
The authority generates once and keeps it. never leaves the authority.
At manufacture, the authority computes from , the label and the device’s identifier, and the factory installs in the device’s protected storage. This installation is key provisioning §5.28.
In use, the device sends its identifier in the clear, together with a message and the message’s tag computed with .
The server recomputes from the received identifier and checks the tag. A correct tag shows that the sender holds the key of that identifier, so the server treats the message as coming from that device and from no other.
A standard derivation function is the key derivation function in counter mode §15.5 of NIST Special Publication 800-108 [306]. Write for the byte string followed by the byte string . The publication builds its key derivation functions from a pseudorandom function §15.1, a keyed function whose outputs look random to anyone without the key. With HMAC-SHA-256 §5.9 as that function, meaning HMAC §5.8 (hash-based message authentication code) built on the hash function SHA-256 §5.2 (Secure Hash Algorithm with a 256-bit output), each block of output is where is the block counter, starting at 1, Label names the purpose, the byte 0x00 separates Label from Context, Context holds the information the key is bound to, here the device identifier, and is the requested output length in bits. The blocks for are joined, and the first bits are the derived key. The application fixes how many bits encode and . The publication says that the Context may include the identities of the parties who derive or use the key.
Worked example
The values are invented. The master key is the 32 bytes 0x00, 0x01, and so on up to 0x1f. The label is dev-auth, the 8 ASCII bytes 64 65 76 2d 61 75 74 68. The identifier is a 4-byte number written most significant byte first. The device key is 256 bits long, so . One HMAC-SHA-256 call gives 256 bits, so one block is enough: , where means rounded up to a whole number. The counter and the length are each written in 4 bytes: is 00 00 00 01, and is 00 00 01 00, because 256 is 0x100.
For device 42, which is 0x2a, the HMAC message is the counter, the label, the separator, the identifier and the length, bytes:
00 00 00 01 64 65 76 2d 61 75 74 68 00 00 00 00 2a 00 00 01 00
The device key is
=
9660e5adc795011069398e5b39df461ae368255b11a9abd0ce3b8e7f266ddd5c
For device 43, which is 0x2b, only the last byte of the identifier changes, from 2a to 2b, and the key is
=
068329176cbbc4d81f98e0d7bc82f4cdf627b253a2a15fcfc8e62a8415af506c
What the numbers mean:
Device 42 stores only . An attacker who extracts can impersonate device 42. To obtain , the attacker would have to predict an HMAC output under the unknown key , which is infeasible if HMAC is a pseudorandom function.
The server stores only the 32 bytes of , instead of a 320,000-byte table for 10,000 devices, and recomputes with one HMAC call when device 42 sends a message.
An attacker who obtains computes , and the key of every other identifier, with one HMAC call each, including devices that have not been made yet.
Stated precisely
Let be the master key, the label, the fixed-length encoding of the identifier , and the key derivation function. The key of device is Isolation statement. Take an attacker who knows the label and every identifier, has extracted the keys of any set of devices, and has seen any number of messages and tags from those devices. For every other device , that attacker still cannot tell apart from a uniformly random key.
The statement rests on four assumptions.
is uniformly random and secret: only the derivation authority holds it, and the authority never releases it.
is built from a pseudorandom function keyed with , as the functions of NIST Special Publication 800-108 are. A pseudorandom function is a keyed function whose outputs, to anyone without the key, cannot feasibly be told apart from random values, even after seeing its outputs on other inputs.
The encoding is injective and the identifiers are unique, so no two devices share an input to .
Each device receives only its own key.
Under these assumptions the statement follows from the definition of a pseudorandom function: the extracted keys are outputs on other inputs, and they reveal nothing about the output on the input .
Without assumption 1 there is no isolation at all, because is a public computation on and public values. NIST Special Publication 800-57 Part 1 says so directly: if the key-derivation key is known by an adversary, the adversary can generate any of the derived keys, so derived keys are only as secure as the key-derivation key.
Limits and common mistakes
The identifier adds no secrecy. A key computed from the identifier alone, such as a hash of the serial number, is known to anyone who knows the serial number. Only the master key makes secret.
Disclosure of the master key cannot be repaired device by device. It exposes every device key at once, including keys of devices made later, and the repair is a new master key and a new key in every device. Every backup, factory station or test system that holds is one more place from which it can leak.
Duplicate identifiers give duplicate keys. Two devices with the same identifier receive the same key, and a cloned device carries its key along with the rest of its memory. Derivation does nothing against cloning.
Replacing one device’s key needs a new input. Deriving again with the same master key, label and identifier gives the same key, so a replacement needs, for example, a version number in the label or the Context. A replacement derived from the same master key is still exposed if the master key leaks.
The master key must be used for derivation only, as NIST Special Publication 800-108 requires of key-derivation keys in a key hierarchy. If also computed tags over data an attacker chooses, a tag could equal a device key.
Derived keys give no forward secrecy §5.33, which is protection of earlier sessions after a long-term key, a key kept and used across many sessions, leaks. The derivation is deterministic, so if a device key encrypts data directly, an attacker who later learns that key, or the master key, can decrypt data recorded before the leak.
Questions answered
Does deriving distinct keys also isolate compromise of the shared root?
No. Deriving a distinct key for each device isolates the compromise of one device key, not the compromise of the shared root, the master key from which every device key is computed. Each device key is computed from the master key and public inputs only, a label and the device identifier, so whoever learns the master key recomputes every device key, including keys of devices made later, with one key derivation call each. NIST Special Publication 800-57 Part 1 says that keys derived from a key-derivation key are only as secure as that key.
What the distinct keys do isolate is a leak at one device. An attacker who extracts one device’s key cannot compute another device’s key, provided that the master key stays secret and the derivation function is a pseudorandom function (a keyed function whose outputs look random to anyone without the key). Limiting the damage of a root disclosure needs secrets that the root does not determine.
Several independent master keys, one for each group of devices, so that one disclosure exposes one group.
An independent random key for each device, which moves the risk to the table that stores the keys.
Key pairs that each device generates itself, each pair being a private key that signs and a public key that checks signatures, so that the server holds only public keys, which can check a device’s digital signatures §5.14 but cannot produce them.
Related entries: Domain separation (§5.22), Root key and root seed (§5.25), Forward secrecy (§5.33), UICR (User Information Configuration Registers) (§16.1), Key derivation function (KDF) (§5.20), Key provisioning (§5.28), Pseudorandom function (PRF) (§15.1), Key separation (§5.23). Further reading: [147, 148, 306].