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
| State | Typical controls | Protects against |
|---|---|---|
| In transit | TLS 1.3 or 1.2, IPsec, SSH, mutual TLS between services | Eavesdropping and tampering on networks |
| At rest | Disk, database and object storage encryption, AES-256 | Stolen disks, backups and snapshots |
| In use | Confidential computing with trusted execution environments | Memory 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
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
- Generate keys with a secure random source, inside the HSM or KMS where possible.
- Separate duties: people who manage keys should not be the same people who can read the data.
- Grant use of each key to specific workloads only; review policies regularly.
- Rotate on a schedule and immediately on suspected compromise; keep old versions for decryption only.
- Back up keys securely, or you can lose all data encrypted with them.
- Log every key operation to your SIEM and alert on unusual use, such as a spike in decrypt calls.
- 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?
Why does platform encryption at rest not stop a SQL injection attack from reading data?
What is crypto-shredding?
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.
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.