Section 20.20

Tree 20: “When can a key be retired or destroyed?”

Setting

A sensor gateway is a small device that collects readings from sensors and passes them on. In this invented example, the gateway also runs a small decision program, and a publisher, the one party authorized to change the gateway’s policy, sends it new programs and management requests. Everything travels through a phone that relays the bytes over a Bluetooth radio link. Each request carries a tag computed with HMAC §5.8 (hash-based message authentication code), a message authentication code §5.7 (MAC): a function that computes a short value, the tag, from a secret key and a message, so that someone without the key should have only a negligible chance of creating a valid tag for a new request.

The gateway’s old active key KaK_a, the key whose tags it accepted on requests, belongs to generation number 7, where the generation number counts key replacements. The publisher computed KaK_a from a root secret RR, which the publisher still keeps. When the gateway activated generation 8, with a new active key, it stopped accepting KaK_a for new requests.

The gateway also keeps an archive: a log in flash memory §6.6, storage that keeps its content without power, in which each entry records a past policy change and is tagged with the key that was active at the time. An auditor must be able to check the generation-7 entries for 90 days. After that, the gateway is decommissioned: taken out of service for good, and perhaps sold or discarded. Three different things happen to KaK_a: retirement, after which it protects no new data; historical processing, in which it still checks old data; and destruction, after which nobody can use it.

Short answer

A key can be retired, meaning that it protects no new data, as soon as its replacement is active. It can be destroyed only when no remaining task needs it, and only once every copy of it and every way to recreate or use it is gone: copies in RAM, records in flash that outlive deletion, backups, the publisher’s copy, any root secret it can be derived from, and any service that can still use it. Retirement is a rule the gateway enforces; destruction is a fact about every copy.

Follow-up questions

Retirement is not deletion

Retirement ends a key’s use for protecting new data; deletion removes the key. A retired key may still be needed, and used, to check old data. NIST Special Publication (SP) 800-57, the key-management guidance of the United States standards agency, calls this the deactivated state: a key in that state is not used to apply protection, but in some cases it is still used to process data protected earlier, for example to decrypt it or to verify its tags.

Here a sensor gateway retired its old active key KaK_a when a new key took over, so requests tagged with KaK_a are now rejected. Its archive still holds log entries tagged with KaK_a, and an auditor must verify them. Keeping KaK_a for that purpose has a cost. KaK_a is a key of a message authentication code (MAC), a symmetric key: the same key computes tags and checks them. Whoever keeps KaK_a to verify the archive can therefore also forge new entries that look old. A digital signature §5.14 avoids this: the signer keeps a private key, and verifiers hold only the public key, which checks signatures but cannot make them.

A retirement rule therefore names what remains permitted, such as verifying archive entries until a stated date; who holds the key for that purpose; and what that holder could misuse.

What is a cryptoperiod?

A cryptoperiod is the time span during which a specific key is authorized for use; the definition comes from NIST Special Publication (SP) 800-57, the key-management guidance of the United States standards agency. It is chosen for each key and each role, not fixed once for all keys. For a symmetric key, one key that both protects data and processes protected data, SP 800-57 divides the cryptoperiod in two:

The whole cryptoperiod runs from the start of the originator-usage period to the end of the recipient-usage period.

The length depends on how much data the key protects, how exposed the key is, the limits of the algorithm §14.1 (such as the number of messages one key may safely protect), how much damage a compromise would do, and how long the protected data must stay verifiable or readable.

Example. A gateway’s active key KaK_a tags new log entries from day 0 to day 30, and an auditor may verify those entries until day 90. The originator-usage period is days 0 to 30, the recipient-usage period days 0 to 90, and the cryptoperiod 90−0=9090 - 0 = 90 days. On day 45 the auditor can check an entry that a trusted archive had already recorded on day 12. The window for verification alone lasts 90−30=6090 - 30 = 60 days. A valid tag alone cannot date an entry first presented on day 45. The auditor needs independent evidence of when it entered the archive, such as a previously retained, authenticated archive checkpoint. After day 90 no permitted use remains, and KaK_a may be destroyed, unless another retention need extends the second window.

Does zeroing one buffer destroy the key?

No: zeroing one buffer, meaning overwriting one region of memory with zero bytes, removes one copy of the key, and other copies and other ways to use the key may remain. Here a sensor gateway wants to destroy its retired active key KaK_a, a 32-byte key for HMAC (hash-based message authentication code), which computes tags that authenticate messages. What may remain after one buffer is zeroed:

The overwrite must also actually happen. A compiler may delete a write to memory that the program never reads again; this compiler optimization §3.39 is called dead-store elimination. A call such as memset(buf, 0, 32) just before buf goes out of use may therefore vanish from the compiled program. Functions such as memset_explicit, added in the 2023 revision of the C standard [309], and explicit_bzero, offered by several C libraries, exist so that the compiler keeps the write. Secret zeroization §5.37 is the whole discipline: find every copy, overwrite each one in a way the compiler keeps, and avoid making unneeded copies in the first place.

What makes flash different?

Flash memory usually keeps an old copy of data after the data is deleted or replaced, because flash cannot overwrite in place. Flash memory is storage that keeps its content without power. Erasing sets every bit of a whole erase block, for example 4096 bytes on a microcontroller §6.1, to 1, and programming can only change bits from 1 to 0. To change a 48-byte key record, the storage software therefore writes a new record elsewhere and marks the old one obsolete; to delete it, the software writes a deletion marker. The old 48 bytes stay physically present until garbage collection §8.16, the process that reclaims space held by obsolete records, copies the live records out of that erase block and erases the block.

Managed flash, such as solid-state drives and memory cards, adds a flash translation layer: a controller that maps the addresses the computer writes to physical locations that the controller chooses. Overwriting an address there writes to a new physical location, and the old copy stays where the computer cannot address it. A successful delete or overwrite promises only what the interface promises: that reads through that interface no longer return the old data. It does not promise that every old physical copy is gone.

A key held in flash can be destroyed in three ways:

NIST Special Publication (SP) 800-88 Revision 2, the media-sanitization guidance of the United States standards agency, names three levels. Clear protects against simple recovery through the device’s normal interface. Purge makes recovery infeasible even with state-of-the-art laboratory techniques. Destroy does the same and leaves the medium unusable. SP 800-88 counts cryptographic erase as a purge technique. Choose the level for the attacker the design names, and keep evidence of what the chosen method actually guarantees on that medium.

What is the last question?

The last question is: after the actions actually performed and verified, which copies of the key, which data it protected, which secrets that can recreate it and which services that can use it remain, and against which attacker does that answer hold? A destruction claim concerns the copies, derivation paths and services within its stated scope. A log protected by a MAC can remain readable after its key is destroyed. Here the key is the retired active key KaK_a of a sensor gateway that is about to be decommissioned, taken out of service for good. KaK_a is a key of a message authentication code (MAC) that tagged its owner’s requests and log entries. The question has five parts:

The honest result is a statement of what trust remains, for example: “KaK_a is gone from the gateway’s RAM and flash, verified by reading back the erased blocks; the publisher’s archive copy will be destroyed on day 90; RR remains and can recreate KaK_a.” One cleanup call does not justify the word destroyed.

Related entries: Secret zeroization (§5.37), Flash memory (§6.6), Garbage collection (§8.16), Digital signature (§5.14), Key rotation (§5.29), Secure element (§5.38), Tree 17: “How do rotation, activation, and revocation work together?” (§20.17). Further reading: [147, 150, 309].