Use each cryptographic key for exactly one purpose. OWASP's key management guidance lists encryption, authentication, key wrapping, random number generation and signing as separate purposes, and says shared use can weaken security and widens the impact of a compromise.
What the rule says
The OWASP Key Management Cheat Sheet states that a single key should be used for only one purpose. Mixing purposes creates two problems. A weakness in how the key is used for one job can leak information that helps an attack on another. And a compromise of the key now damages every purpose at once.
Examples of mixing
- One secret used both as an AES encryption key and as an HMAC key.
- The same RSA key pair used to sign tokens and to decrypt incoming messages.
- A master key used directly for data encryption and for wrapping other keys.
- A key shared between production and staging, so a leak in the weaker environment hits both.
- One key for all tenants, so one tenant's problem is everyone's.
How to separate keys without managing hundreds of secrets
You do not have to store each key independently. A key derivation function can take one protected root secret and produce separate keys for separate purposes, using distinct labels. A label such as an encryption purpose and a different one for authentication yields unrelated keys from the same root.
Use a standard KDF from a reviewed library with context labels. Do not invent your own scheme by truncating or concatenating strings.
For public-key systems, generate separate key pairs for separate jobs: one for signing, one for encryption.
Benefits you can measure
- Smaller blast radius: leaking a token signing key does not expose stored data.
- Cleaner rotation: you can rotate the signing key on its own schedule. The OWASP page gives different typical cryptoperiods for different key types, for instance private signing keys typically 1 to 3 years and static key agreement keys typically up to 1 to 2 years.
- Cleaner permissions: a service that only needs to verify signatures never needs the encryption key.
- Clearer audit: logs show which purpose a key was used for.
A review checklist
- List each key and write one sentence describing its purpose. If the sentence has an and in it, split the key.
- Check that environments do not share keys.
- Check that access policies grant only the operations needed, such as sign but not decrypt.
- Check that derived keys use distinct context labels.
- Search code for one secret loaded into two different cryptographic calls.
Quick check
Is deriving two keys from one root a violation of the rule?
No, if each derived key is used for one purpose and the derivation uses distinct context. The root itself should be used only to derive.
Can I use one key per environment instead of per purpose?
Per environment is a separate good rule. It does not replace separation by purpose. Do both.
Safeguard's dependency scanning shows which crypto libraries your projects use, and the free scan at gold.safeguard.sh/scan is a quick first step.
Sources
Last reviewed: 19 October 2026.