Free tech learning for everyone, from basics to pro

Secure ArchitectureSystems ArchitectureAdvanced

Encryption architecture and key management

In short: Good encryption architecture is mostly about keys. Data is encrypted at rest, in transit and sometimes in use, while keys are generated, stored, rotated and destroyed under strict control in a key management service or HSM. Envelope encryption makes this practical at scale.

Where data needs protecting

StateTypical controlsProtects against
In transitTLS 1.3 or 1.2, IPsec, SSH, mutual TLS between servicesEavesdropping and tampering on networks
At restDisk, database and object storage encryption, AES-256Stolen disks, backups and snapshots
In useConfidential computing with trusted execution environmentsMemory access by the host or cloud operator

Encryption at rest provided transparently by a platform protects lost media, but anyone with valid access to the running system still sees plaintext. For sensitive fields, consider application-level encryption, where the application encrypts specific fields, such as national ID numbers, before they reach the database.

Envelope encryption and key hierarchy

Key hierarchy (envelope encryption)Root keyin HSM, never leavesKey encryption keywraps data keysData encryption keyencrypts the dataEncrypted datastored with wrapped DEK
Figure 1. Envelope encryption: data keys encrypt data, and are themselves encrypted by keys higher in the hierarchy.

Encrypting large data directly with a central key would send huge volumes through the key service. Instead, systems use envelope encryption: a fresh data encryption key (DEK) encrypts the data locally, then a key encryption key (KEK) held in the key service encrypts, or wraps, the DEK. The wrapped DEK is stored beside the data. To decrypt, the application asks the key service to unwrap the DEK, which is logged and access-controlled.

Benefits: the master key never leaves secure hardware, rotation of the KEK does not require re-encrypting all data, and every unwrap is an auditable event.

Where keys live

  • Hardware security modules (HSMs): tamper-resistant devices validated to standards such as FIPS 140-3. Keys can be used inside but not exported.
  • Cloud key management services (KMS): managed services backed by HSMs, such as AWS KMS or Azure Key Vault, with IAM policies and audit logs (see AWS KMS and Azure Key Vault).
  • Customer-managed and external keys: options such as bring your own key (BYOK) or hold your own key give more control, at the cost of more responsibility.
  • Secrets managers: store passwords, API keys and certificates, not to be confused with encryption keys, though often in the same platform.

Key lifecycle and governance

Key lifecycleGeneratestrong randomStoreKMS or HSMUsewith access controlRotatenew versionRetiredecrypt onlyDestroywhen safe
Figure 2. Every key moves through a managed lifecycle from creation to secure destruction.
  1. Generate keys with a secure random source, inside the HSM or KMS where possible.
  2. Separate duties: people who manage keys should not be the same people who can read the data.
  3. Grant use of each key to specific workloads only; review policies regularly.
  4. Rotate on a schedule and immediately on suspected compromise; keep old versions for decryption only.
  5. Back up keys securely, or you can lose all data encrypted with them.
  6. Log every key operation to your SIEM and alert on unusual use, such as a spike in decrypt calls.
  7. Destroy keys deliberately, which is also a way to make data unrecoverable (crypto-shredding).

Plan for crypto-agility. NIST published its first post-quantum standards in 2024, including FIPS 203 (ML-KEM) for key establishment. Keep an inventory of where and how you use cryptography, so you can move to new algorithms without redesigning systems (see post-quantum migration).

Tip: the most common failure is not weak algorithms but poor key handling, such as keys in source code, shared admin access to the KMS, or backups encrypted with a key that is stored in the same place.

Practice

In envelope encryption, what encrypts the data and what encrypts that key?
A data encryption key (DEK) encrypts the data; a key encryption key (KEK) held in the KMS or HSM encrypts the DEK.
Why does platform encryption at rest not stop a SQL injection attack from reading data?
The database decrypts data for any valid query, so an attacker using the application sees plaintext. Field-level encryption and secure coding are needed.
What is crypto-shredding?
Making data unrecoverable by securely destroying the keys that encrypt it.

Key takeaways

  • Protect data in transit, at rest and, where needed, in use.
  • Envelope encryption uses data keys wrapped by keys in a KMS or HSM.
  • Manage keys through generate, store, use, rotate, retire and destroy.
  • Separate key administrators from data users and log every key operation.
  • Build crypto-agility for the move to post-quantum algorithms.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.